structured-fw 0.8.42 → 0.8.43

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 (89) hide show
  1. package/package.json +10 -3
  2. package/app/models/README.md +0 -9
  3. package/app/routes/README.md +0 -19
  4. package/app/views/README.md +0 -1
  5. package/app/views/layout.html +0 -1
  6. package/build/Config.d.ts +0 -2
  7. package/build/Config.js +0 -30
  8. package/build/app/Types.d.ts +0 -5
  9. package/build/app/Types.js +0 -1
  10. package/build/app/global.d.ts +0 -3
  11. package/build/app/global.js +0 -1
  12. package/build/app/models/Users.d.ts +0 -0
  13. package/build/app/models/Users.js +0 -1
  14. package/build/app/routes/Auth.d.ts +0 -0
  15. package/build/app/routes/Auth.js +0 -1
  16. package/build/app/routes/Test.d.ts +0 -2
  17. package/build/app/routes/Test.js +0 -101
  18. package/build/app/routes/Todo.d.ts +0 -0
  19. package/build/app/routes/Todo.js +0 -1
  20. package/build/app/routes/Upload.d.ts +0 -0
  21. package/build/app/routes/Upload.js +0 -1
  22. package/build/app/routes/Validation.d.ts +0 -2
  23. package/build/app/routes/Validation.js +0 -34
  24. package/build/app/routess/Auth.d.ts +0 -0
  25. package/build/app/routess/Auth.js +0 -1
  26. package/build/app/routess/Test.d.ts +0 -2
  27. package/build/app/routess/Test.js +0 -101
  28. package/build/app/routess/Todo.d.ts +0 -0
  29. package/build/app/routess/Todo.js +0 -1
  30. package/build/app/routess/Upload.d.ts +0 -0
  31. package/build/app/routess/Upload.js +0 -1
  32. package/build/app/routess/Validation.d.ts +0 -2
  33. package/build/app/routess/Validation.js +0 -34
  34. package/build/app/views/components/ClientImport/ClientImport.client.d.ts +0 -2
  35. package/build/app/views/components/ClientImport/ClientImport.client.js +0 -4
  36. package/build/app/views/components/ClientImport/Export.d.ts +0 -1
  37. package/build/app/views/components/ClientImport/Export.js +0 -1
  38. package/build/app/views/components/Conditionals/Conditionals.client.d.ts +0 -2
  39. package/build/app/views/components/Conditionals/Conditionals.client.js +0 -43
  40. package/build/app/views/components/FormTest/FormTestNested/FormTestNested.d.ts +0 -8
  41. package/build/app/views/components/FormTest/FormTestNested/FormTestNested.js +0 -7
  42. package/build/app/views/components/ModelsTest/ModelsTest.client.d.ts +0 -2
  43. package/build/app/views/components/ModelsTest/ModelsTest.client.js +0 -5
  44. package/build/app/views/components/MultipartForm/MultipartForm.client.d.ts +0 -0
  45. package/build/app/views/components/MultipartForm/MultipartForm.client.js +0 -1
  46. package/build/app/views/components/PassObject/PassObject.d.ts +0 -10
  47. package/build/app/views/components/PassObject/PassObject.js +0 -10
  48. package/build/app/views/components/PassObject/ReceiveObj/ReceiveObj.d.ts +0 -6
  49. package/build/app/views/components/PassObject/ReceiveObj/ReceiveObj.js +0 -6
  50. package/build/app/views/components/RedrawAbort/RedrawAbort.client.d.ts +0 -2
  51. package/build/app/views/components/RedrawAbort/RedrawAbort.client.js +0 -6
  52. package/build/app/views/components/RedrawAbort/RedrawAbort.d.ts +0 -8
  53. package/build/app/views/components/RedrawAbort/RedrawAbort.js +0 -8
  54. package/build/app/views/components/ServerSideContext/ServerSideContext.d.ts +0 -7
  55. package/build/app/views/components/ServerSideContext/ServerSideContext.js +0 -10
  56. package/build/assets/ts/Export.d.ts +0 -1
  57. package/build/assets/ts/Export.js +0 -1
  58. package/build/index.d.ts +0 -1
  59. package/build/index.js +0 -8
  60. package/build/tsconfig.tsbuildinfo +0 -1
  61. package/jsr.json +0 -35
  62. package/system/EventEmitter.ts +0 -38
  63. package/system/Helpers.ts +0 -97
  64. package/system/Symbols.ts +0 -6
  65. package/system/Types.ts +0 -232
  66. package/system/Util.ts +0 -488
  67. package/system/bin/structured.ts +0 -115
  68. package/system/client/App.ts +0 -11
  69. package/system/client/Client.ts +0 -9
  70. package/system/client/ClientComponent.ts +0 -1107
  71. package/system/client/DataStore.ts +0 -101
  72. package/system/client/DataStoreView.ts +0 -82
  73. package/system/client/Net.ts +0 -58
  74. package/system/client/NetRequest.ts +0 -64
  75. package/system/global.d.ts +0 -12
  76. package/system/server/Application.ts +0 -239
  77. package/system/server/Component.ts +0 -409
  78. package/system/server/Components.ts +0 -114
  79. package/system/server/Cookies.ts +0 -29
  80. package/system/server/Document.ts +0 -163
  81. package/system/server/DocumentHead.ts +0 -150
  82. package/system/server/FormValidation.ts +0 -231
  83. package/system/server/Handlebars.ts +0 -51
  84. package/system/server/Request.ts +0 -502
  85. package/system/server/Session.ts +0 -151
  86. package/system/server/dom/DOMFragment.ts +0 -7
  87. package/system/server/dom/DOMNode.ts +0 -140
  88. package/system/server/dom/HTMLParser.ts +0 -238
  89. package/tsconfig.json +0 -31
package/package.json CHANGED
@@ -14,13 +14,12 @@
14
14
  "license": "MIT",
15
15
  "type": "module",
16
16
  "main": "build/index",
17
- "version": "0.8.42",
17
+ "version": "0.8.43",
18
18
  "scripts": {
19
19
  "develop": "tsc --watch",
20
20
  "startDev": "cd build && nodemon --watch '../app/**/*' --watch '../build/**/*' -e js,html,css index.js",
21
21
  "start": "cd build && node index.js",
22
- "prepublish": "tsc",
23
- "postinstall": "rm tsconfig.json"
22
+ "prepublish": "tsc"
24
23
  },
25
24
  "bin": {
26
25
  "structured": "./build/system/bin/structured.js"
@@ -35,6 +34,14 @@
35
34
  "mime-types": "^3.0.0",
36
35
  "ts-md5": "^1.3.1"
37
36
  },
37
+ "files": [
38
+ "build/system/*",
39
+ "app/Types.ts",
40
+ "index.ts",
41
+ "Config.ts",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
38
45
  "exports" : {
39
46
  "./Types": "./build/system/Types.js",
40
47
  "./Symbols": "./build/system/Symbols.js",
@@ -1,9 +0,0 @@
1
- You don't have to use this directory, but if you are keen on MVC concept, this would be the place for your models.
2
-
3
- There are not specific rules for these files. They are never loaded automaticallt by the framework, instead you should
4
- load them where you want to use them.
5
-
6
- Usually a model will export a class or a class instance, but it could be a function, set of functions, or anything really.
7
-
8
- Models are meant to abstract the logic and data layer for a specific entity of your app. For example a web shop would likely
9
- have a model Product.ts which exports a class with methods such as create(productData: ProductData) to create a new product and delete(productId: number) to delete an existing product.
@@ -1,19 +0,0 @@
1
- Routes:
2
-
3
- You can add routes directly in index.ts using app.request.on
4
- but in order to avoid clutter and keep the code structured, you should add the routes here (/app/routes)
5
-
6
- All files in this directory will be loaded once the server is started,
7
- so feel free to separate your routes in as many files as you feel makes sense, eg. it would make sense
8
- to have Auth.ts that would add routes for everything auth related, such as /login, /register, etc...
9
-
10
- Example:
11
-
12
- export default async function(app: Application) {
13
-
14
- app.request.on('GET', '/login', async (ctx) => {
15
- // ctx is a RequestContext
16
- ctx.response.write('Login page');
17
- });
18
-
19
- }
@@ -1 +0,0 @@
1
- Place for pages and components
@@ -1 +0,0 @@
1
- {{{layoutComponent component data attributes}}}
package/build/Config.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { StructuredConfig } from 'structured-fw/Types';
2
- export declare const config: StructuredConfig;
package/build/Config.js DELETED
@@ -1,30 +0,0 @@
1
- export const config = {
2
- envPrefix: 'STRUCTURED',
3
- autoInit: true,
4
- url: {
5
- removeTrailingSlash: true,
6
- componentRender: '/componentRender',
7
- isAsset: function (uri) {
8
- return uri.indexOf('/assets/') === 0;
9
- }
10
- },
11
- routes: {
12
- path: '/app/routes'
13
- },
14
- components: {
15
- path: '/app/views',
16
- componentNameAttribute: 'structured-component'
17
- },
18
- session: {
19
- cookieName: 'session',
20
- keyLength: 24,
21
- durationSeconds: 60 * 60,
22
- garbageCollectIntervalSeconds: 60
23
- },
24
- http: {
25
- port: 9191,
26
- host: '0.0.0.0',
27
- linkHeaderRel: 'preload'
28
- },
29
- runtime: 'Node.js'
30
- };
@@ -1,5 +0,0 @@
1
- export {};
2
- declare global {
3
- interface RequestContextData {
4
- }
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export interface RequestContextData {
2
- user: string;
3
- }
@@ -1 +0,0 @@
1
- export {};
File without changes
@@ -1 +0,0 @@
1
- "use strict";
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- import { Application } from '../../system/server/Application.js';
2
- export default function (app: Application): void;
@@ -1,101 +0,0 @@
1
- import { Document } from '../../system/server/Document.js';
2
- import { Request } from '../../system/server/Request.js';
3
- export default function (app) {
4
- app.request.on('GET', '/test/form', async (ctx) => {
5
- const doc = new Document(app, 'Form test', ctx);
6
- await doc.loadComponent('FormTestNested', { test: 3 });
7
- return doc;
8
- });
9
- app.request.on('POST', '/test/form', async (ctx) => {
10
- console.log(JSON.stringify(ctx.body, undefined, 4));
11
- const userImage = ctx.files.user.image[0];
12
- ctx.response.setHeader('Content-Type', userImage.type);
13
- ctx.respondWith(userImage.data);
14
- });
15
- app.request.on('GET', '/test/client_import', async (ctx) => {
16
- const doc = new Document(app, 'Test', ctx);
17
- await doc.loadComponent('ClientImport', { xyz: 10, asd: 12 });
18
- ctx.respondWith(doc);
19
- });
20
- app.request.on('GET', '/test/redraw', async (ctx) => {
21
- const doc = new Document(app, 'Test', ctx);
22
- await doc.loadComponent('RedrawAbort');
23
- ctx.respondWith(doc);
24
- });
25
- app.request.on('GET', '/test/models', async (ctx) => {
26
- const doc = new Document(app, 'Test', ctx);
27
- await doc.loadComponent('ModelsTest');
28
- ctx.respondWith(doc);
29
- });
30
- app.request.on('GET', '/getargs', async (ctx) => {
31
- ctx.respondWith(ctx.getArgs);
32
- });
33
- app.request.on('GET', '/form/multipart', async (ctx) => {
34
- const doc = new Document(app, 'Test multipart form', ctx);
35
- await doc.loadComponent('MultipartForm');
36
- ctx.respondWith(doc);
37
- });
38
- app.request.on('POST', '/form/multipart', async (ctx) => {
39
- console.log(ctx.files);
40
- ctx.respondWith(ctx.body);
41
- });
42
- app.request.on('GET', '/conditional', async (ctx) => {
43
- const doc = new Document(app, 'Test multipart form', ctx);
44
- await doc.loadComponent('Conditionals');
45
- ctx.respondWith(doc);
46
- });
47
- app.request.on('GET', '/urldecode', async (ctx) => {
48
- const noVal = 'noVal';
49
- const noValNested = 'filters[beds][min]';
50
- const simple = 'simple=2';
51
- const simpleObj = 'person[name]=fname&person[last_name]=lname';
52
- const simpleArray = 'colors[]=red&colors[]=blue';
53
- const orderedArray = 'colorsOrdered[1]=red&colorsOrdered[0]=blue';
54
- const indexedArray = 'months[0]=Jan&months[1]=Feb&months[2]=Mar';
55
- const arrayOfObjects = 'users[0][name]=John&users[0][email]=johndoe@gmail.com&users[1][name]=Tim&users[1][email]=tim@gmail.com';
56
- const objectWithArrayValues = 'user[name]=John&user[last_name]=Doe&user[sports][]=table tennis&user[sports][]=football';
57
- const objectWithObjectValues = 'data[paper][props][size]=10x13&data[paper][props][type]=matte';
58
- const nestedArraySimple = 'colorStack[0][]=red&colorStack[0][]=blue&colorStack[1][]=green';
59
- const arrayOfObjectsWithArrayValues = 'usersArr[0][name]=John&usersArr[0][email]=johndoe@gmail.com&usersArr[0][sports][]=football&usersArr[0][sports][]=basketball&usersArr[1][name]=Too&usersArr[1][email]=tootoo@gmail.com&usersArr[1][sports][]=bocce&usersArr[1][sports][]=cricket&usersArr[1][sports][]=dancing';
60
- const missingValue = 'missing=';
61
- const missingArrayValue = 'missingArr[]=';
62
- const objBlankValue = `objBlank[0][email]=`;
63
- const spaces = `spaces=value%20with%20spaces`;
64
- const special = `garbage=` + encodeURIComponent('value!@#&$%^*()');
65
- const nonLatin = `key3=` + encodeURIComponent('привет');
66
- const t = new Date().getTime();
67
- const test = Request.queryStringDecode([noVal, noValNested, simple, simpleObj, simpleArray, orderedArray, indexedArray, arrayOfObjects, objectWithArrayValues, objectWithObjectValues, nestedArraySimple, arrayOfObjectsWithArrayValues, missingValue, nonLatin, spaces, special, objBlankValue, missingArrayValue, simple].join('&'));
68
- const dur = new Date().getTime() - t;
69
- console.log(dur);
70
- ctx.respondWith(test);
71
- });
72
- app.request.on('GET', '/client_import', async (ctx) => {
73
- const doc = new Document(app, 'Test multipart form', ctx);
74
- await doc.loadComponent('ClientImport');
75
- doc.head.add(`
76
- <script type="importmap">
77
- {
78
- imports: {
79
- 'components/*' : '/build/app/views/components/*'
80
- }
81
- }
82
- </script>
83
- `);
84
- ctx.respondWith(doc);
85
- });
86
- app.request.on('GET', '/serverclass', async (ctx) => {
87
- const doc = new Document(app, 'Test multipart form', ctx);
88
- await doc.loadComponent('ServerSideContext');
89
- ctx.respondWith(doc);
90
- });
91
- app.request.on('GET', '/routes/new', async (ctx) => {
92
- const doc = new Document(app, 'Test multipart form', ctx);
93
- await doc.loadComponent('Conditionals');
94
- return doc;
95
- });
96
- app.request.on('GET', '/passObj', async (ctx) => {
97
- const doc = new Document(app, 'Test pass obj', ctx);
98
- await doc.loadComponent('PassObject');
99
- ctx.respondWith(doc);
100
- });
101
- }
File without changes
@@ -1 +0,0 @@
1
- "use strict";
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- import { Application } from "../../system/server/Application.js";
2
- export default function (app: Application): void;
@@ -1,34 +0,0 @@
1
- import { FormValidation } from '../../system/server/FormValidation.js';
2
- import { Document } from "../../system/server/Document.js";
3
- export default function (app) {
4
- let validator = new FormValidation();
5
- validator.singleError = true;
6
- validator.addRule('name', 'Name', ['required', ['minLength', 3]]);
7
- validator.addRule('email', 'Email', ['validEmail']);
8
- validator.addRule('number', 'Number', ['number', 'required']);
9
- validator.addRule('numeric', 'Numeric', ['numeric', 'required']);
10
- validator.addRule('float', 'Float', ['float', 'required']);
11
- app.request.on('POST', '/validation', async (ctx) => {
12
- if (ctx.body) {
13
- let validationResult = await validator.validate(ctx.body);
14
- if (validationResult.valid) {
15
- ctx.response.write('Valid');
16
- }
17
- else {
18
- app.session.setValue(ctx.sessionId, 'validationErrors', validationResult.errors);
19
- app.session.setValue(ctx.sessionId, 'formValues', ctx.body);
20
- app.request.redirect(ctx.response, '/validation');
21
- }
22
- }
23
- });
24
- app.request.on('GET', '/validation', async (ctx) => {
25
- let doc = new Document(app, 'Form validation');
26
- await doc.loadView('pages/validation', app.session.extract(ctx.sessionId, [
27
- { validationErrors: 'errors' },
28
- { formValues: 'values' }
29
- ]));
30
- ctx.response.write(doc.toString());
31
- app.session.removeValue(ctx.sessionId, 'validationErrors');
32
- app.session.removeValue(ctx.sessionId, 'formValues');
33
- });
34
- }
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- import { Application } from '../../system/server/Application.js';
2
- export default function (app: Application): void;
@@ -1,101 +0,0 @@
1
- import { Document } from '../../system/server/Document.js';
2
- import { Request } from '../../system/server/Request.js';
3
- export default function (app) {
4
- app.request.on('GET', '/test/form', async (ctx) => {
5
- const doc = new Document(app, 'Form test', ctx);
6
- await doc.loadComponent('FormTestNested', { test: 3 });
7
- ctx.respondWith(doc);
8
- });
9
- app.request.on('POST', '/test/form', async (ctx) => {
10
- console.log(JSON.stringify(ctx.body, undefined, 4));
11
- const userImage = ctx.files.user.image[0];
12
- ctx.response.setHeader('Content-Type', userImage.type);
13
- ctx.respondWith(userImage.data);
14
- });
15
- app.request.on('GET', '/test/client_import', async (ctx) => {
16
- const doc = new Document(app, 'Test', ctx);
17
- await doc.loadComponent('ClientImport', { xyz: 10, asd: 12 });
18
- ctx.respondWith(doc);
19
- });
20
- app.request.on('GET', '/test/redraw', async (ctx) => {
21
- const doc = new Document(app, 'Test', ctx);
22
- await doc.loadComponent('RedrawAbort');
23
- ctx.respondWith(doc);
24
- });
25
- app.request.on('GET', '/test/models', async (ctx) => {
26
- const doc = new Document(app, 'Test', ctx);
27
- await doc.loadComponent('ModelsTest');
28
- ctx.respondWith(doc);
29
- });
30
- app.request.on('GET', '/getargs', async (ctx) => {
31
- ctx.respondWith(ctx.getArgs);
32
- });
33
- app.request.on('GET', '/form/multipart', async (ctx) => {
34
- const doc = new Document(app, 'Test multipart form', ctx);
35
- await doc.loadComponent('MultipartForm');
36
- ctx.respondWith(doc);
37
- });
38
- app.request.on('POST', '/form/multipart', async (ctx) => {
39
- console.log(ctx.files);
40
- ctx.respondWith(ctx.body);
41
- });
42
- app.request.on('GET', '/conditional', async (ctx) => {
43
- const doc = new Document(app, 'Test multipart form', ctx);
44
- await doc.loadComponent('Conditionals');
45
- ctx.respondWith(doc);
46
- });
47
- app.request.on('GET', '/urldecode', async (ctx) => {
48
- const noVal = 'noVal';
49
- const noValNested = 'filters[beds][min]';
50
- const simple = 'simple=2';
51
- const simpleObj = 'person[name]=fname&person[last_name]=lname';
52
- const simpleArray = 'colors[]=red&colors[]=blue';
53
- const orderedArray = 'colorsOrdered[1]=red&colorsOrdered[0]=blue';
54
- const indexedArray = 'months[0]=Jan&months[1]=Feb&months[2]=Mar';
55
- const arrayOfObjects = 'users[0][name]=John&users[0][email]=johndoe@gmail.com&users[1][name]=Tim&users[1][email]=tim@gmail.com';
56
- const objectWithArrayValues = 'user[name]=John&user[last_name]=Doe&user[sports][]=table tennis&user[sports][]=football';
57
- const objectWithObjectValues = 'data[paper][props][size]=10x13&data[paper][props][type]=matte';
58
- const nestedArraySimple = 'colorStack[0][]=red&colorStack[0][]=blue&colorStack[1][]=green';
59
- const arrayOfObjectsWithArrayValues = 'usersArr[0][name]=John&usersArr[0][email]=johndoe@gmail.com&usersArr[0][sports][]=football&usersArr[0][sports][]=basketball&usersArr[1][name]=Too&usersArr[1][email]=tootoo@gmail.com&usersArr[1][sports][]=bocce&usersArr[1][sports][]=cricket&usersArr[1][sports][]=dancing';
60
- const missingValue = 'missing=';
61
- const missingArrayValue = 'missingArr[]=';
62
- const objBlankValue = `objBlank[0][email]=`;
63
- const spaces = `spaces=value%20with%20spaces`;
64
- const special = `garbage=` + encodeURIComponent('value!@#&$%^*()');
65
- const nonLatin = `key3=` + encodeURIComponent('привет');
66
- const t = new Date().getTime();
67
- const test = Request.queryStringDecode([noVal, noValNested, simple, simpleObj, simpleArray, orderedArray, indexedArray, arrayOfObjects, objectWithArrayValues, objectWithObjectValues, nestedArraySimple, arrayOfObjectsWithArrayValues, missingValue, nonLatin, spaces, special, objBlankValue, missingArrayValue, simple].join('&'));
68
- const dur = new Date().getTime() - t;
69
- console.log(dur);
70
- ctx.respondWith(test);
71
- });
72
- app.request.on('GET', '/client_import', async (ctx) => {
73
- const doc = new Document(app, 'Test multipart form', ctx);
74
- await doc.loadComponent('ClientImport');
75
- doc.head.add(`
76
- <script type="importmap">
77
- {
78
- imports: {
79
- 'components/*' : '/build/app/views/components/*'
80
- }
81
- }
82
- </script>
83
- `);
84
- ctx.respondWith(doc);
85
- });
86
- app.request.on('GET', '/serverclass', async (ctx) => {
87
- const doc = new Document(app, 'Test multipart form', ctx);
88
- await doc.loadComponent('ServerSideContext');
89
- ctx.respondWith(doc);
90
- });
91
- app.request.on('GET', '/routes/new', async (ctx) => {
92
- const doc = new Document(app, 'Test multipart form', ctx);
93
- await doc.loadComponent('Conditionals');
94
- return doc;
95
- });
96
- app.request.on('GET', '/passObj', async (ctx) => {
97
- const doc = new Document(app, 'Test pass obj', ctx);
98
- await doc.loadComponent('PassObject');
99
- ctx.respondWith(doc);
100
- });
101
- }
File without changes
@@ -1 +0,0 @@
1
- "use strict";
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- import { Application } from "../../system/server/Application.js";
2
- export default function (app: Application): void;
@@ -1,34 +0,0 @@
1
- import { FormValidation } from '../../system/server/FormValidation.js';
2
- import { Document } from "../../system/server/Document.js";
3
- export default function (app) {
4
- let validator = new FormValidation();
5
- validator.singleError = true;
6
- validator.addRule('name', 'Name', ['required', ['minLength', 3]]);
7
- validator.addRule('email', 'Email', ['validEmail']);
8
- validator.addRule('number', 'Number', ['number', 'required']);
9
- validator.addRule('numeric', 'Numeric', ['numeric', 'required']);
10
- validator.addRule('float', 'Float', ['float', 'required']);
11
- app.request.on('POST', '/validation', async (ctx) => {
12
- if (ctx.body) {
13
- let validationResult = await validator.validate(ctx.body);
14
- if (validationResult.valid) {
15
- ctx.response.write('Valid');
16
- }
17
- else {
18
- app.session.setValue(ctx.sessionId, 'validationErrors', validationResult.errors);
19
- app.session.setValue(ctx.sessionId, 'formValues', ctx.body);
20
- app.request.redirect(ctx.response, '/validation');
21
- }
22
- }
23
- });
24
- app.request.on('GET', '/validation', async (ctx) => {
25
- let doc = new Document(app, 'Form validation');
26
- await doc.loadView('pages/validation', app.session.extract(ctx.sessionId, [
27
- { validationErrors: 'errors' },
28
- { formValues: 'values' }
29
- ]));
30
- ctx.response.write(doc.toString());
31
- app.session.removeValue(ctx.sessionId, 'validationErrors');
32
- app.session.removeValue(ctx.sessionId, 'formValues');
33
- });
34
- }
@@ -1,2 +0,0 @@
1
- import { InitializerFunction } from '../../../../system/Types.js';
2
- export declare const init: InitializerFunction;
@@ -1,4 +0,0 @@
1
- export const init = async function () {
2
- const test = await import('/assets/ts/Export.js');
3
- console.log(test);
4
- };
@@ -1 +0,0 @@
1
- export declare const test = 1;
@@ -1 +0,0 @@
1
- export const test = 1;
@@ -1,2 +0,0 @@
1
- import { InitializerFunction } from '../../../../system/Types.js';
2
- export declare const init: InitializerFunction;
@@ -1,43 +0,0 @@
1
- export const init = async function () {
2
- const style = document.createElement('style');
3
- style.type = 'text/css';
4
- style.textContent = `
5
- .active {
6
- font-weight: 800;
7
- }
8
- `;
9
- document.head.appendChild(style);
10
- this.store.set('showMessage', false);
11
- this.bind(this.ref('setShowMessage'), 'click', () => {
12
- this.store.set('showMessage', true);
13
- });
14
- this.bind(this.ref('unsetShowMessage'), 'click', () => {
15
- this.store.set('showMessage', false);
16
- });
17
- let num = 0;
18
- const increaseNum = () => {
19
- num++;
20
- setNum();
21
- };
22
- const decreaseNum = () => {
23
- num--;
24
- setNum();
25
- };
26
- const setNum = () => {
27
- this.store.set('number', num);
28
- this.ref('num').textContent = num.toString();
29
- };
30
- this.bind(this.ref('numIncrease'), 'click', () => {
31
- increaseNum();
32
- });
33
- this.bind(this.ref('numDecrease'), 'click', () => {
34
- decreaseNum();
35
- });
36
- setNum();
37
- this.conditionalCallback('method1', () => {
38
- return this.store.get('showMessage') === true && num > 3;
39
- });
40
- this.conditionalCallback('method2', (number) => {
41
- return number === num;
42
- });
43
- };
@@ -1,8 +0,0 @@
1
- import { ComponentScaffold, RequestContext } from '../../../../../system/Types.js';
2
- type ComponentData = {
3
- test: number;
4
- };
5
- export default class FormTestNested implements ComponentScaffold {
6
- getData(data: ComponentData, ctx: RequestContext): Promise<ComponentData>;
7
- }
8
- export {};
@@ -1,7 +0,0 @@
1
- export default class FormTestNested {
2
- async getData(data, ctx) {
3
- return {
4
- test: 123
5
- };
6
- }
7
- }
@@ -1,2 +0,0 @@
1
- import { InitializerFunction } from '../../../../system/Types.js';
2
- export declare const init: InitializerFunction;
@@ -1,5 +0,0 @@
1
- export const init = async function () {
2
- this.store.onChange('test', (key, val) => {
3
- this.find('ModelTestNested')?.redraw(this.getData());
4
- });
5
- };
@@ -1,10 +0,0 @@
1
- import { ComponentScaffold, RequestContext } from '../../../../system/Types.js';
2
- type ComponentData = {};
3
- export default class PassObj implements ComponentScaffold {
4
- getData(data: ComponentData, ctx: RequestContext): Promise<{
5
- obj: {
6
- uuid: string;
7
- };
8
- }>;
9
- }
10
- export {};
@@ -1,10 +0,0 @@
1
- import { randomString } from '../../../../system/Util.js';
2
- export default class PassObj {
3
- async getData(data, ctx) {
4
- return {
5
- obj: {
6
- uuid: randomString(12)
7
- }
8
- };
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- import { ComponentScaffold, RequestContext } from '../../../../../system/Types.js';
2
- type ComponentData = {};
3
- export default class ReceiveObj implements ComponentScaffold {
4
- getData(data: ComponentData, ctx: RequestContext): Promise<ComponentData>;
5
- }
6
- export {};
@@ -1,6 +0,0 @@
1
- export default class ReceiveObj {
2
- async getData(data, ctx) {
3
- console.log('a', data);
4
- return data;
5
- }
6
- }
@@ -1,2 +0,0 @@
1
- import { InitializerFunction } from '../../../../system/Types.js';
2
- export declare const init: InitializerFunction;
@@ -1,6 +0,0 @@
1
- export const init = async function () {
2
- setTimeout(() => {
3
- this.redraw();
4
- this.redraw();
5
- }, 1000);
6
- };
@@ -1,8 +0,0 @@
1
- import { ComponentScaffold, RequestContext } from '../../../../system/Types.js';
2
- type ComponentData = {};
3
- export default class RedrawAbort implements ComponentScaffold {
4
- getData(data: ComponentData, ctx: RequestContext): Promise<{
5
- key: string;
6
- }>;
7
- }
8
- export {};
@@ -1,8 +0,0 @@
1
- import { randomString } from '../../../../system/Util.js';
2
- export default class RedrawAbort {
3
- async getData(data, ctx) {
4
- return {
5
- key: randomString(5)
6
- };
7
- }
8
- }
@@ -1,7 +0,0 @@
1
- import { ComponentScaffold } from '../../../../system/Types.js';
2
- export default class ServerSideContext implements ComponentScaffold {
3
- getData(): Promise<{
4
- number: number;
5
- }>;
6
- num(): number;
7
- }