@webqit/webflo 0.11.61-0 → 1.0.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 (118) hide show
  1. package/.gitignore +7 -7
  2. package/LICENSE +20 -20
  3. package/README.md +2079 -2074
  4. package/docker/Dockerfile +42 -42
  5. package/docker/README.md +91 -91
  6. package/docker/package.json +2 -2
  7. package/package.json +80 -81
  8. package/src/{Context.js → AbstractContext.js} +71 -79
  9. package/src/config-pi/deployment/Env.js +68 -68
  10. package/src/config-pi/deployment/Layout.js +63 -63
  11. package/src/config-pi/deployment/Origins.js +139 -139
  12. package/src/config-pi/deployment/Proxy.js +74 -74
  13. package/src/config-pi/deployment/index.js +17 -17
  14. package/src/config-pi/index.js +15 -15
  15. package/src/config-pi/runtime/Client.js +116 -98
  16. package/src/config-pi/runtime/Server.js +125 -125
  17. package/src/config-pi/runtime/client/Worker.js +109 -134
  18. package/src/config-pi/runtime/client/index.js +11 -11
  19. package/src/config-pi/runtime/index.js +17 -17
  20. package/src/config-pi/runtime/server/Headers.js +74 -74
  21. package/src/config-pi/runtime/server/Redirects.js +69 -69
  22. package/src/config-pi/runtime/server/index.js +13 -13
  23. package/src/config-pi/static/Manifest.js +319 -319
  24. package/src/config-pi/static/Ssg.js +49 -49
  25. package/src/config-pi/static/index.js +13 -13
  26. package/src/deployment-pi/index.js +10 -10
  27. package/src/deployment-pi/origins/index.js +216 -216
  28. package/src/index.js +11 -19
  29. package/src/runtime-pi/HttpEvent.js +126 -106
  30. package/src/runtime-pi/HttpUser.js +126 -0
  31. package/src/runtime-pi/MessagingOverBroadcast.js +9 -0
  32. package/src/runtime-pi/MessagingOverChannel.js +85 -0
  33. package/src/runtime-pi/MessagingOverSocket.js +106 -0
  34. package/src/runtime-pi/MultiportMessagingAPI.js +81 -0
  35. package/src/runtime-pi/WebfloCookieStorage.js +27 -0
  36. package/src/runtime-pi/WebfloEventTarget.js +39 -0
  37. package/src/runtime-pi/WebfloMessageEvent.js +58 -0
  38. package/src/runtime-pi/WebfloMessagingAPI.js +69 -0
  39. package/src/runtime-pi/{Router.js → WebfloRouter.js} +99 -130
  40. package/src/runtime-pi/WebfloRuntime.js +52 -0
  41. package/src/runtime-pi/WebfloStorage.js +109 -0
  42. package/src/runtime-pi/client/ClientMessaging.js +5 -0
  43. package/src/runtime-pi/client/Context.js +3 -7
  44. package/src/runtime-pi/client/CookieStorage.js +17 -0
  45. package/src/runtime-pi/client/Router.js +38 -48
  46. package/src/runtime-pi/client/SessionStorage.js +33 -0
  47. package/src/runtime-pi/client/Url.js +156 -205
  48. package/src/runtime-pi/client/WebfloClient.js +544 -0
  49. package/src/runtime-pi/client/WebfloRootClient1.js +179 -0
  50. package/src/runtime-pi/client/WebfloRootClient2.js +109 -0
  51. package/src/runtime-pi/client/WebfloSubClient.js +165 -0
  52. package/src/runtime-pi/client/Workport.js +118 -178
  53. package/src/runtime-pi/client/generate.js +480 -471
  54. package/src/runtime-pi/client/index.js +16 -21
  55. package/src/runtime-pi/client/worker/ClientMessaging.js +5 -0
  56. package/src/runtime-pi/client/worker/Context.js +3 -7
  57. package/src/runtime-pi/client/worker/CookieStorage.js +17 -0
  58. package/src/runtime-pi/client/worker/SessionStorage.js +13 -0
  59. package/src/runtime-pi/client/worker/WebfloWorker.js +294 -0
  60. package/src/runtime-pi/client/worker/Workport.js +17 -85
  61. package/src/runtime-pi/client/worker/index.js +10 -21
  62. package/src/runtime-pi/index.js +6 -13
  63. package/src/runtime-pi/server/ClientMessaging.js +18 -0
  64. package/src/runtime-pi/server/ClientMessagingRegistry.js +57 -0
  65. package/src/runtime-pi/server/Context.js +11 -15
  66. package/src/runtime-pi/server/CookieStorage.js +17 -0
  67. package/src/runtime-pi/server/Router.js +93 -159
  68. package/src/runtime-pi/server/SessionStorage.js +53 -0
  69. package/src/runtime-pi/server/WebfloServer.js +755 -0
  70. package/src/runtime-pi/server/index.js +10 -21
  71. package/src/runtime-pi/util-http.js +322 -86
  72. package/src/runtime-pi/util-url.js +146 -146
  73. package/src/runtime-pi/xURL.js +108 -105
  74. package/src/runtime-pi/xfetch.js +22 -22
  75. package/src/services-pi/cert/http-auth-hook.js +22 -22
  76. package/src/services-pi/cert/http-cleanup-hook.js +22 -22
  77. package/src/services-pi/cert/index.js +79 -79
  78. package/src/services-pi/index.js +8 -8
  79. package/src/static-pi/index.js +10 -10
  80. package/src/webflo.js +30 -30
  81. package/test/index.test.js +26 -26
  82. package/test/site/package.json +9 -9
  83. package/test/site/public/bundle.html +5 -5
  84. package/test/site/public/bundle.html.json +3 -3
  85. package/test/site/public/bundle.js +2 -2
  86. package/test/site/public/bundle.webflo.js +15 -15
  87. package/test/site/public/index.html +29 -29
  88. package/test/site/public/index1.html +34 -34
  89. package/test/site/public/page-2/bundle.html +4 -4
  90. package/test/site/public/page-2/bundle.js +2 -2
  91. package/test/site/public/page-2/index.html +45 -45
  92. package/test/site/public/page-2/main.html +2 -2
  93. package/test/site/public/page-4/subpage/bundle.js +2 -2
  94. package/test/site/public/page-4/subpage/index.html +30 -30
  95. package/test/site/public/sparoots.json +4 -4
  96. package/test/site/public/worker.js +3 -3
  97. package/test/site/server/index.js +15 -15
  98. package/src/runtime-pi/Application.js +0 -29
  99. package/src/runtime-pi/Cookies.js +0 -82
  100. package/src/runtime-pi/Runtime.js +0 -21
  101. package/src/runtime-pi/client/Application.js +0 -100
  102. package/src/runtime-pi/client/Runtime.js +0 -332
  103. package/src/runtime-pi/client/createStorage.js +0 -57
  104. package/src/runtime-pi/client/oohtml/full.js +0 -7
  105. package/src/runtime-pi/client/oohtml/namespacing.js +0 -7
  106. package/src/runtime-pi/client/oohtml/scripting.js +0 -8
  107. package/src/runtime-pi/client/oohtml/templating.js +0 -8
  108. package/src/runtime-pi/client/worker/Application.js +0 -44
  109. package/src/runtime-pi/client/worker/Runtime.js +0 -269
  110. package/src/runtime-pi/server/Application.js +0 -116
  111. package/src/runtime-pi/server/Runtime.js +0 -557
  112. package/src/runtime-pi/xFormData.js +0 -24
  113. package/src/runtime-pi/xHeaders.js +0 -146
  114. package/src/runtime-pi/xRequest.js +0 -46
  115. package/src/runtime-pi/xRequestHeaders.js +0 -109
  116. package/src/runtime-pi/xResponse.js +0 -33
  117. package/src/runtime-pi/xResponseHeaders.js +0 -117
  118. package/src/runtime-pi/xxHttpMessage.js +0 -102
@@ -1,68 +1,68 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import { Dotfile } from '@webqit/backpack';
6
-
7
- export default class Env extends Dotfile {
8
-
9
- // Base name
10
- get name() {
11
- return 'env';
12
- }
13
-
14
- // @desc
15
- static get ['@desc']() {
16
- return 'Environmental variables config.';
17
- }
18
-
19
- // isEnv
20
- get isEnv() {
21
- return true;
22
- }
23
-
24
- // Defaults merger
25
- withDefaults(config) {
26
- return this.merge({
27
- autoload: true,
28
- }, config, 'patch');
29
- }
30
-
31
- // Questions generator
32
- getSchema(config, choices = {}) {
33
- // Questions
34
- return [
35
- {
36
- name: 'entries',
37
- type: 'recursive',
38
- controls: {
39
- name: 'variable',
40
- combomode: true,
41
- },
42
- initial: config.entries,
43
- schema: [
44
- {
45
- name: 'name',
46
- type: 'text',
47
- message: 'Name',
48
- validation: ['important'],
49
- },
50
- {
51
- name: 'value',
52
- type: 'text',
53
- message: 'Value',
54
- validation: ['important'],
55
- },
56
- ],
57
- },
58
- {
59
- name: 'autoload',
60
- type: 'toggle',
61
- message: 'Choose whether to autoload variables into "process.env"',
62
- active: 'YES',
63
- inactive: 'NO',
64
- initial: config.autoload,
65
- },
66
- ];
67
- }
68
- }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import { Dotfile } from '@webqit/backpack';
6
+
7
+ export default class Env extends Dotfile {
8
+
9
+ // Base name
10
+ get name() {
11
+ return 'env';
12
+ }
13
+
14
+ // @desc
15
+ static get ['@desc']() {
16
+ return 'Environmental variables config.';
17
+ }
18
+
19
+ // isEnv
20
+ get isEnv() {
21
+ return true;
22
+ }
23
+
24
+ // Defaults merger
25
+ withDefaults(config) {
26
+ return this.merge({
27
+ autoload: true,
28
+ }, config, 'patch');
29
+ }
30
+
31
+ // Questions generator
32
+ getSchema(config, choices = {}) {
33
+ // Questions
34
+ return [
35
+ {
36
+ name: 'entries',
37
+ type: 'recursive',
38
+ controls: {
39
+ name: 'variable',
40
+ combomode: true,
41
+ },
42
+ initial: config.entries,
43
+ schema: [
44
+ {
45
+ name: 'name',
46
+ type: 'text',
47
+ message: 'Name',
48
+ validation: ['important'],
49
+ },
50
+ {
51
+ name: 'value',
52
+ type: 'text',
53
+ message: 'Value',
54
+ validation: ['important'],
55
+ },
56
+ ],
57
+ },
58
+ {
59
+ name: 'autoload',
60
+ type: 'toggle',
61
+ message: 'Choose whether to autoload variables into "process.env"',
62
+ active: 'YES',
63
+ inactive: 'NO',
64
+ initial: config.autoload,
65
+ },
66
+ ];
67
+ }
68
+ }
@@ -1,63 +1,63 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import { Dotfile } from '@webqit/backpack';
6
-
7
- export default class Layout extends Dotfile {
8
-
9
- // Base name
10
- get name() {
11
- return 'layout';
12
- }
13
-
14
- // @desc
15
- static get ['@desc']() {
16
- return 'Project layout config.';
17
- }
18
-
19
- // Defaults merger
20
- withDefaults(config) {
21
- return this.merge({
22
- PUBLIC_DIR: './public',
23
- SERVER_DIR: './server',
24
- CLIENT_DIR: './client',
25
- WORKER_DIR: './worker',
26
- }, config, 'patch');
27
- }
28
-
29
- // Questions generator
30
- getSchema(config, choices = {}) {
31
- // Questions
32
- return [
33
- {
34
- name: 'PUBLIC_DIR',
35
- type: 'text',
36
- message: 'Enter the application\'s public directory',
37
- initial: config.PUBLIC_DIR,
38
- validation: ['important'],
39
- },
40
- {
41
- name: 'SERVER_DIR',
42
- type: 'text',
43
- message: 'Enter the directory for the application\'s server-side route handlers',
44
- initial: config.SERVER_DIR,
45
- validation: ['important'],
46
- },
47
- {
48
- name: 'CLIENT_DIR',
49
- type: 'text',
50
- message: 'Enter the directory for the application\'s client-side route handlers',
51
- initial: config.CLIENT_DIR,
52
- validation: ['important'],
53
- },
54
- {
55
- name: 'WORKER_DIR',
56
- type: 'text',
57
- message: 'Enter the directory for the application\'s offline route handlers',
58
- initial: config.WORKER_DIR,
59
- validation: ['important'],
60
- },
61
- ];
62
- }
63
- }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import { Dotfile } from '@webqit/backpack';
6
+
7
+ export default class Layout extends Dotfile {
8
+
9
+ // Base name
10
+ get name() {
11
+ return 'layout';
12
+ }
13
+
14
+ // @desc
15
+ static get ['@desc']() {
16
+ return 'Project layout config.';
17
+ }
18
+
19
+ // Defaults merger
20
+ withDefaults(config) {
21
+ return this.merge({
22
+ PUBLIC_DIR: './public',
23
+ SERVER_DIR: './server',
24
+ CLIENT_DIR: './client',
25
+ WORKER_DIR: './worker',
26
+ }, config, 'patch');
27
+ }
28
+
29
+ // Questions generator
30
+ getSchema(config, choices = {}) {
31
+ // Questions
32
+ return [
33
+ {
34
+ name: 'PUBLIC_DIR',
35
+ type: 'text',
36
+ message: 'Enter the application\'s public directory',
37
+ initial: config.PUBLIC_DIR,
38
+ validation: ['important'],
39
+ },
40
+ {
41
+ name: 'SERVER_DIR',
42
+ type: 'text',
43
+ message: 'Enter the directory for the application\'s server-side route handlers',
44
+ initial: config.SERVER_DIR,
45
+ validation: ['important'],
46
+ },
47
+ {
48
+ name: 'CLIENT_DIR',
49
+ type: 'text',
50
+ message: 'Enter the directory for the application\'s client-side route handlers',
51
+ initial: config.CLIENT_DIR,
52
+ validation: ['important'],
53
+ },
54
+ {
55
+ name: 'WORKER_DIR',
56
+ type: 'text',
57
+ message: 'Enter the directory for the application\'s offline route handlers',
58
+ initial: config.WORKER_DIR,
59
+ validation: ['important'],
60
+ },
61
+ ];
62
+ }
63
+ }
@@ -1,139 +1,139 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import Url from 'url';
6
- import { _before } from '@webqit/util/str/index.js';
7
- import { _isTypeObject } from '@webqit/util/js/index.js';
8
- import { Dotfile } from '@webqit/backpack';
9
-
10
- export default class Origins extends Dotfile {
11
-
12
- // Base name
13
- get name() {
14
- return 'origins';
15
- }
16
-
17
- // @desc
18
- static get ['@desc']() {
19
- return 'Remote origins config.';
20
- }
21
-
22
- // Defaults merger
23
- withDefaults(config) {
24
- let hostname = '', origin = '';
25
- if (this.cx.PKG && this.cx.PKG.repository) {
26
- var inferredRepo = Url.parse(_isTypeObject(this.cx.PKG.repository) ? this.cx.PKG.repository.url : this.cx.PKG.repository);
27
- hostname = _before(inferredRepo.hostname, '.');
28
- origin = _before(inferredRepo.pathname, '.');
29
- }
30
- // Params
31
- return this.merge({
32
- entries: [{
33
- host: hostname,
34
- access_token: '',
35
- repo: origin,
36
- branch: 'master',
37
- tag: 'root',
38
- deploy_path: '.',
39
- autodeploy: true,
40
- autodeploy_secret: '',
41
- ondeploy: 'npm install',
42
- ondeploy_autoexit: true,
43
- }],
44
- }, config, 'patch');
45
- }
46
-
47
- // Match
48
- async match(url) {
49
- return ((await this.read()).entries || []).filter(_origin => _origin.tag.toLowerCase() === url.toLowerCase() || _origin.repo.toLowerCase() === url.toLowerCase());
50
- }
51
-
52
- // Questions generator
53
- getSchema(config, choices = {}) {
54
- // Choices
55
- const CHOICES = this.merge({
56
- host: [
57
- {value: 'github',},
58
- {value: 'bitbucket',},
59
- ],
60
- }, choices, 'patch');
61
- // Questions
62
- return [
63
- {
64
- name: 'entries',
65
- type: 'recursive',
66
- controls: {
67
- name: 'repository',
68
- },
69
- initial: config.entries,
70
- schema: [
71
- {
72
- name: 'host',
73
- type: 'select',
74
- message: 'Host name',
75
- choices: CHOICES.host,
76
- validation: ['input', 'important'],
77
- },
78
- {
79
- name: 'access_token',
80
- type: 'text',
81
- message: 'Enter your Personal Acess Token at host (if exists)',
82
- validation: ['input', 'important'],
83
- },
84
- {
85
- name: 'repo',
86
- type: 'text',
87
- message: 'Enter a repository name (in the format: user-or-org/origin)',
88
- validation: ['input', 'important'],
89
- },
90
- {
91
- name: 'branch',
92
- type: 'text',
93
- message: 'Specifiy the git branch within the given repository',
94
- validation: ['input', 'important'],
95
- },
96
- {
97
- name: 'tag',
98
- type: 'text',
99
- message: 'Enter a local name for this origin',
100
- validation: ['input', 'important'],
101
- },
102
- {
103
- name: 'deploy_path',
104
- type: 'text',
105
- message: 'Enter the relative local path that this origin deploys to',
106
- validation: ['important'],
107
- },
108
- {
109
- name: 'autodeploy',
110
- type: 'toggle',
111
- message: 'Auto-deploy this origin on every push to branch?',
112
- active: 'YES',
113
- inactive: 'NO',
114
- },
115
- {
116
- name: 'autodeploy_secret',
117
- type: (prev, ans) => ans.autodeploy ? 'text' : null,
118
- message: 'Enter the "secret" for validating the auto-deploy webhook event',
119
- validation: ['input', 'important'],
120
- },
121
- {
122
- name: 'ondeploy',
123
- type: 'text',
124
- message: 'Enter an optional "command" to run on deploy',
125
- validation: ['input', 'important'],
126
- },
127
- {
128
- name: 'ondeploy_autoexit',
129
- type: (prev, ans) => ans.autodeploy ? 'toggle' : null,
130
- message: 'Auto exit process on deploy?',
131
- active: 'YES',
132
- inactive: 'NO',
133
- },
134
- ],
135
- },
136
-
137
- ];
138
- }
139
- }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import Url from 'url';
6
+ import { _before } from '@webqit/util/str/index.js';
7
+ import { _isTypeObject } from '@webqit/util/js/index.js';
8
+ import { Dotfile } from '@webqit/backpack';
9
+
10
+ export default class Origins extends Dotfile {
11
+
12
+ // Base name
13
+ get name() {
14
+ return 'origins';
15
+ }
16
+
17
+ // @desc
18
+ static get ['@desc']() {
19
+ return 'Remote origins config.';
20
+ }
21
+
22
+ // Defaults merger
23
+ withDefaults(config) {
24
+ let hostname = '', origin = '';
25
+ if (this.cx.PKG && this.cx.PKG.repository) {
26
+ var inferredRepo = Url.parse(_isTypeObject(this.cx.PKG.repository) ? this.cx.PKG.repository.url : this.cx.PKG.repository);
27
+ hostname = _before(inferredRepo.hostname, '.');
28
+ origin = _before(inferredRepo.pathname, '.');
29
+ }
30
+ // Params
31
+ return this.merge({
32
+ entries: [{
33
+ host: hostname,
34
+ access_token: '',
35
+ repo: origin,
36
+ branch: 'master',
37
+ tag: 'root',
38
+ deploy_path: '.',
39
+ autodeploy: true,
40
+ autodeploy_secret: '',
41
+ ondeploy: 'npm install',
42
+ ondeploy_autoexit: true,
43
+ }],
44
+ }, config, 'patch');
45
+ }
46
+
47
+ // Match
48
+ async match(url) {
49
+ return ((await this.read()).entries || []).filter(_origin => _origin.tag.toLowerCase() === url.toLowerCase() || _origin.repo.toLowerCase() === url.toLowerCase());
50
+ }
51
+
52
+ // Questions generator
53
+ getSchema(config, choices = {}) {
54
+ // Choices
55
+ const CHOICES = this.merge({
56
+ host: [
57
+ {value: 'github',},
58
+ {value: 'bitbucket',},
59
+ ],
60
+ }, choices, 'patch');
61
+ // Questions
62
+ return [
63
+ {
64
+ name: 'entries',
65
+ type: 'recursive',
66
+ controls: {
67
+ name: 'repository',
68
+ },
69
+ initial: config.entries,
70
+ schema: [
71
+ {
72
+ name: 'host',
73
+ type: 'select',
74
+ message: 'Host name',
75
+ choices: CHOICES.host,
76
+ validation: ['input', 'important'],
77
+ },
78
+ {
79
+ name: 'access_token',
80
+ type: 'text',
81
+ message: 'Enter your Personal Acess Token at host (if exists)',
82
+ validation: ['input', 'important'],
83
+ },
84
+ {
85
+ name: 'repo',
86
+ type: 'text',
87
+ message: 'Enter a repository name (in the format: user-or-org/origin)',
88
+ validation: ['input', 'important'],
89
+ },
90
+ {
91
+ name: 'branch',
92
+ type: 'text',
93
+ message: 'Specifiy the git branch within the given repository',
94
+ validation: ['input', 'important'],
95
+ },
96
+ {
97
+ name: 'tag',
98
+ type: 'text',
99
+ message: 'Enter a local name for this origin',
100
+ validation: ['input', 'important'],
101
+ },
102
+ {
103
+ name: 'deploy_path',
104
+ type: 'text',
105
+ message: 'Enter the relative local path that this origin deploys to',
106
+ validation: ['important'],
107
+ },
108
+ {
109
+ name: 'autodeploy',
110
+ type: 'toggle',
111
+ message: 'Auto-deploy this origin on every push to branch?',
112
+ active: 'YES',
113
+ inactive: 'NO',
114
+ },
115
+ {
116
+ name: 'autodeploy_secret',
117
+ type: (prev, ans) => ans.autodeploy ? 'text' : null,
118
+ message: 'Enter the "secret" for validating the auto-deploy webhook event',
119
+ validation: ['input', 'important'],
120
+ },
121
+ {
122
+ name: 'ondeploy',
123
+ type: 'text',
124
+ message: 'Enter an optional "command" to run on deploy',
125
+ validation: ['input', 'important'],
126
+ },
127
+ {
128
+ name: 'ondeploy_autoexit',
129
+ type: (prev, ans) => ans.autodeploy ? 'toggle' : null,
130
+ message: 'Auto exit process on deploy?',
131
+ active: 'YES',
132
+ inactive: 'NO',
133
+ },
134
+ ],
135
+ },
136
+
137
+ ];
138
+ }
139
+ }