@webqit/webflo 0.10.3 → 0.11.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 (60) hide show
  1. package/README.md +1509 -3
  2. package/bundle.html.json +1665 -0
  3. package/package.json +3 -3
  4. package/src/Context.js +8 -4
  5. package/src/config-pi/deployment/Env.js +2 -2
  6. package/src/config-pi/deployment/Layout.js +2 -2
  7. package/src/config-pi/deployment/Origins.js +2 -2
  8. package/src/config-pi/deployment/Virtualization.js +2 -2
  9. package/src/config-pi/runtime/Client.js +39 -11
  10. package/src/config-pi/runtime/Server.js +26 -10
  11. package/src/config-pi/runtime/client/Worker.js +32 -14
  12. package/src/config-pi/runtime/server/Headers.js +2 -2
  13. package/src/config-pi/runtime/server/Redirects.js +2 -2
  14. package/src/config-pi/static/Manifest.js +2 -2
  15. package/src/config-pi/static/Ssg.js +2 -2
  16. package/src/runtime-pi/Router.js +1 -1
  17. package/src/runtime-pi/client/Runtime.js +116 -62
  18. package/src/runtime-pi/client/RuntimeClient.js +28 -43
  19. package/src/runtime-pi/client/Workport.js +163 -0
  20. package/src/runtime-pi/client/generate.js +285 -77
  21. package/src/runtime-pi/client/{generate.oohtml.js → oohtml/full.js} +0 -0
  22. package/src/runtime-pi/client/oohtml/namespacing.js +7 -0
  23. package/src/runtime-pi/client/oohtml/scripting.js +8 -0
  24. package/src/runtime-pi/client/oohtml/templating.js +8 -0
  25. package/src/runtime-pi/client/worker/Worker.js +58 -24
  26. package/src/runtime-pi/client/worker/Workport.js +80 -0
  27. package/src/runtime-pi/server/Router.js +2 -2
  28. package/src/runtime-pi/server/Runtime.js +30 -11
  29. package/src/runtime-pi/server/RuntimeClient.js +24 -14
  30. package/src/runtime-pi/util.js +2 -2
  31. package/src/webflo.js +7 -9
  32. package/test/site/package.json +9 -0
  33. package/test/site/public/bundle.html +6 -0
  34. package/test/site/public/bundle.html.json +4 -0
  35. package/test/site/public/bundle.js +2 -0
  36. package/test/site/public/bundle.js.gz +0 -0
  37. package/test/site/public/bundle.webflo.js +15 -0
  38. package/test/site/public/bundle.webflo.js.gz +0 -0
  39. package/test/site/public/index.html +30 -0
  40. package/test/site/public/index1.html +35 -0
  41. package/test/site/public/page-2/bundle.html +5 -0
  42. package/test/site/public/page-2/bundle.html.json +1 -0
  43. package/test/site/public/page-2/bundle.js +2 -0
  44. package/test/site/public/page-2/bundle.js.gz +0 -0
  45. package/test/site/public/page-2/index.html +46 -0
  46. package/test/site/public/page-2/logo-130x130.png +0 -0
  47. package/test/site/public/page-2/main.html +3 -0
  48. package/test/site/public/page-3/logo-130x130.png +0 -0
  49. package/test/site/public/page-4/subpage/bundle.html +0 -0
  50. package/test/site/public/page-4/subpage/bundle.html.json +1 -0
  51. package/test/site/public/page-4/subpage/bundle.js +2 -0
  52. package/test/site/public/page-4/subpage/bundle.js.gz +0 -0
  53. package/test/site/public/page-4/subpage/index.html +31 -0
  54. package/test/site/public/sparoots.json +5 -0
  55. package/test/site/public/worker.js +3 -0
  56. package/test/site/public/worker.js.gz +0 -0
  57. package/test/site/server/index.js +16 -0
  58. package/src/Cli.js +0 -131
  59. package/src/Configurator.js +0 -97
  60. package/src/runtime-pi/client/WorkerComm.js +0 -102
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "0.10.3",
15
+ "version": "0.11.0",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@octokit/webhooks": "^7.15.1",
39
- "@webqit/backpack": "^0.0.37",
40
- "@webqit/oohtml-ssr": "^1.0.3",
39
+ "@webqit/backpack": "^0.1.0",
40
+ "@webqit/oohtml-ssr": "^1.1.0",
41
41
  "@webqit/util": "^0.8.9",
42
42
  "client-sessions": "^0.8.0",
43
43
  "esbuild": "^0.14.38",
package/src/Context.js CHANGED
@@ -17,10 +17,14 @@ export default class Context {
17
17
  this[prop] = this.dict[prop];
18
18
  }
19
19
  if (arguments.length > 1) {
20
- this.dict.CWD = CD;
20
+ Object.defineProperty(this.dict, 'CWD', { get: () => CD });
21
21
  }
22
22
  }
23
23
 
24
+ get name() {
25
+ return 'webflo';
26
+ }
27
+
24
28
  // create
25
29
  static create(...args) {
26
30
  return new this(...args);
@@ -31,9 +35,9 @@ export default class Context {
31
35
  return this.dict.CWD || '';
32
36
  }
33
37
 
34
- // webflo
35
- get webflo() {
36
- return this.dict.webflo || {};
38
+ // meta
39
+ get meta() {
40
+ return this.dict.meta || {};
37
41
  }
38
42
 
39
43
  // app
@@ -3,9 +3,9 @@
3
3
  * imports
4
4
  */
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
- import Configurator from '../../Configurator.js';
6
+ import { Dotfile } from '@webqit/backpack';
7
7
 
8
- export default class Env extends Configurator {
8
+ export default class Env extends Dotfile {
9
9
 
10
10
  // Base name
11
11
  get name() {
@@ -3,9 +3,9 @@
3
3
  * imports
4
4
  */
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
- import Configurator from '../../Configurator.js';
6
+ import { Dotfile } from '@webqit/backpack';
7
7
 
8
- export default class Layout extends Configurator {
8
+ export default class Layout extends Dotfile {
9
9
 
10
10
  // Base name
11
11
  get name() {
@@ -6,9 +6,9 @@ import Url from 'url';
6
6
  import { _merge } from '@webqit/util/obj/index.js';
7
7
  import { _before } from '@webqit/util/str/index.js';
8
8
  import { _isObject, _isTypeObject } from '@webqit/util/js/index.js';
9
- import Configurator from '../../Configurator.js';
9
+ import { Dotfile } from '@webqit/backpack';
10
10
 
11
- export default class Origins extends Configurator {
11
+ export default class Origins extends Dotfile {
12
12
 
13
13
  // Base name
14
14
  get name() {
@@ -4,9 +4,9 @@
4
4
  */
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
6
  import { _isObject } from '@webqit/util/js/index.js';
7
- import Configurator from '../../Configurator.js';
7
+ import { Dotfile } from '@webqit/backpack';
8
8
 
9
- export default class Virtualization extends Configurator {
9
+ export default class Virtualization extends Dotfile {
10
10
 
11
11
  // Base name
12
12
  get name() {
@@ -5,9 +5,9 @@
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
6
  import { _isNumeric } from '@webqit/util/js/index.js';
7
7
  import { _before, _after } from '@webqit/util/str/index.js';
8
- import Configurator from '../../Configurator.js';
8
+ import { Dotfile } from '@webqit/backpack';
9
9
 
10
- export default class Client extends Configurator {
10
+ export default class Client extends Dotfile {
11
11
 
12
12
  // Base name
13
13
  get name() {
@@ -23,8 +23,10 @@ export default class Client extends Configurator {
23
23
  withDefaults(config) {
24
24
  return _merge(true, {
25
25
  bundle_filename: 'bundle.js',
26
- support_oohtml: true,
27
- support_service_worker: true,
26
+ public_base_url: '/',
27
+ spa_routing: true,
28
+ oohtml_support: 'full',
29
+ service_worker_support: true,
28
30
  worker_scope: '/',
29
31
  worker_filename: 'worker.js',
30
32
  }, config);
@@ -32,6 +34,16 @@ export default class Client extends Configurator {
32
34
 
33
35
  // Questions generator
34
36
  questions(config, choices = {}) {
37
+ // Choices
38
+ const CHOICES = _merge({
39
+ oohtml_support: [
40
+ {value: 'full', title: 'Full'},
41
+ {value: 'namespacing', title: 'namespacing'},
42
+ {value: 'scripting', title: 'scripting'},
43
+ {value: 'templating', title: 'templating'},
44
+ {value: 'none', title: 'none'},
45
+ ],
46
+ }, choices);
35
47
  // Questions
36
48
  return [
37
49
  {
@@ -41,30 +53,46 @@ export default class Client extends Configurator {
41
53
  initial: config.bundle_filename,
42
54
  },
43
55
  {
44
- name: 'support_oohtml',
56
+ name: 'public_base_url',
57
+ type: 'text',
58
+ message: '[public_base_url]: Enter the base-URL for public resource URLs',
59
+ initial: DATA.public_base_url,
60
+ validation: ['important'],
61
+ },
62
+ {
63
+ name: 'spa_routing',
45
64
  type: 'toggle',
46
- message: 'Support rendering with OOHTML? (Adds OOHTML to your app\'s bundle.)',
65
+ message: '[spa_routing]: Enable Single Page Routing Mode',
47
66
  active: 'YES',
48
67
  inactive: 'NO',
49
- initial: config.support_oohtml,
68
+ initial: config.spa_routing,
69
+ validation: ['important'],
70
+ },
71
+ {
72
+ name: 'oohtml_support',
73
+ type: 'select',
74
+ message: '[oohtml_support]: (Adds OOHTML to your app\'s bundle.) Specify OOHTML support level',
75
+ choices: CHOICES.oohtml_support,
76
+ initial: this.indexOfInitial(CHOICES.oohtml_support, config.oohtml_support),
77
+ validation: ['important'],
50
78
  },
51
79
  {
52
- name: 'support_service_worker',
80
+ name: 'service_worker_support',
53
81
  type: 'toggle',
54
82
  message: 'Support Service Worker?',
55
83
  active: 'YES',
56
84
  inactive: 'NO',
57
- initial: config.support_service_worker,
85
+ initial: config.service_worker_support,
58
86
  },
59
87
  {
60
88
  name: 'worker_scope',
61
- type: (prev, answers) => answers.support_service_worker ? 'text' : null,
89
+ type: (prev, answers) => answers.service_worker_support ? 'text' : null,
62
90
  message: 'Specify the Service Worker scope',
63
91
  initial: config.worker_scope,
64
92
  },
65
93
  {
66
94
  name: 'worker_filename',
67
- type: (prev, answers) => answers.support_service_worker ? 'text' : null,
95
+ type: (prev, answers) => answers.service_worker_support ? 'text' : null,
68
96
  message: 'Specify the Service Worker filename',
69
97
  initial: config.worker_filename,
70
98
  },
@@ -3,9 +3,9 @@
3
3
  * imports
4
4
  */
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
- import Configurator from '../../Configurator.js';
6
+ import { Dotfile } from '@webqit/backpack';
7
7
 
8
- export default class Server extends Configurator {
8
+ export default class Server extends Dotfile {
9
9
 
10
10
  // Base name
11
11
  get name() {
@@ -29,6 +29,7 @@ export default class Server extends Configurator {
29
29
  force: false,
30
30
  },
31
31
  force_www: '',
32
+ oohtml_support: 'full',
32
33
  shared: false,
33
34
  }, config);
34
35
  }
@@ -42,13 +43,20 @@ export default class Server extends Configurator {
42
43
  {value: 'add',},
43
44
  {value: 'remove',},
44
45
  ],
46
+ oohtml_support: [
47
+ {value: 'full', title: 'full'},
48
+ {value: 'namespacing', title: 'namespacing'},
49
+ {value: 'scripting', title: 'scripting'},
50
+ {value: 'templating', title: 'templating'},
51
+ {value: 'none', title: 'none'},
52
+ ],
45
53
  }, choices);
46
54
  // Questions
47
55
  return [
48
56
  {
49
57
  name: 'port',
50
58
  type: 'number',
51
- message: 'Enter port number',
59
+ message: '[port]: Enter port number',
52
60
  initial: config.port,
53
61
  validation: ['important'],
54
62
  },
@@ -62,31 +70,31 @@ export default class Server extends Configurator {
62
70
  {
63
71
  name: 'port',
64
72
  type: 'number',
65
- message: 'Enter HTTPS port number',
73
+ message: '[port]: Enter HTTPS port number',
66
74
  validation: ['important'],
67
75
  },
68
76
  {
69
77
  name: 'keyfile',
70
78
  type: 'text',
71
- message: 'Enter SSL KEY file',
79
+ message: '[keyfile]: Enter SSL KEY file',
72
80
  validation: ['important'],
73
81
  },
74
82
  {
75
83
  name: 'certfile',
76
84
  type: 'text',
77
- message: 'Enter SSL CERT file',
85
+ message: '[certfile]: Enter SSL CERT file',
78
86
  validation: ['important'],
79
87
  },
80
88
  {
81
89
  name: 'certdoms',
82
90
  type: 'list',
83
- message: 'Enter the CERT domains (comma-separated)',
91
+ message: '[certdoms]: Enter the CERT domains (comma-separated)',
84
92
  validation: ['important'],
85
93
  },
86
94
  {
87
95
  name: 'force',
88
96
  type: 'toggle',
89
- message: 'Force HTTPS?',
97
+ message: '[force]: Force HTTPS?',
90
98
  active: 'YES',
91
99
  inactive: 'NO',
92
100
  },
@@ -95,14 +103,22 @@ export default class Server extends Configurator {
95
103
  {
96
104
  name: 'force_www',
97
105
  type: 'select',
98
- message: 'Force add/remove "www" on hostname?',
106
+ message: '[force_www]: Force add/remove "www" on hostname?',
99
107
  choices: CHOICES.force_www,
100
108
  initial: this.indexOfInitial(CHOICES.force_www, config.force_www),
101
109
  },
110
+ {
111
+ name: 'oohtml_support',
112
+ type: 'select',
113
+ message: '[oohtml_support]: Specify OOHTML support level',
114
+ choices: CHOICES.oohtml_support,
115
+ initial: this.indexOfInitial(CHOICES.oohtml_support, config.oohtml_support),
116
+ validation: ['important'],
117
+ },
102
118
  {
103
119
  name: 'shared',
104
120
  type: 'toggle',
105
- message: 'Shared server?',
121
+ message: '[shared]: Shared server?',
106
122
  active: 'YES',
107
123
  inactive: 'NO',
108
124
  initial: config.shared,
@@ -5,9 +5,9 @@
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
6
  import { _isNumeric } from '@webqit/util/js/index.js';
7
7
  import { _before, _after } from '@webqit/util/str/index.js';
8
- import Configurator from '../../../Configurator.js';
8
+ import { Dotfile } from '@webqit/backpack';
9
9
 
10
- export default class Worker extends Configurator {
10
+ export default class Worker extends Dotfile {
11
11
 
12
12
  // Base name
13
13
  get name() {
@@ -23,10 +23,11 @@ export default class Worker extends Configurator {
23
23
  withDefaults(config) {
24
24
  return _merge(true, {
25
25
  cache_name: 'cache_v0',
26
- cache_only_urls: [],
26
+ default_fetching_strategy: 'network-first',
27
+ network_first_urls: [],
27
28
  cache_first_urls: [],
28
29
  network_only_urls: [],
29
- network_first_urls: [],
30
+ cache_only_urls: [ '/page-3/{*.json}' ],
30
31
  skip_waiting: false,
31
32
  // -----------------
32
33
  support_push: false,
@@ -42,6 +43,15 @@ export default class Worker extends Configurator {
42
43
  if (config.cache_name && config.cache_name.indexOf('_v') > -1 && _isNumeric(_after(config.cache_name, '_v'))) {
43
44
  config.cache_name = _before(config.cache_name, '_v') + '_v' + (parseInt(_after(config.cache_name, '_v')) + 1);
44
45
  }
46
+ // Choices
47
+ const CHOICES = _merge({
48
+ default_fetching_strategy: [
49
+ {value: 'network-first', title: 'Network-first (Webflo default)'},
50
+ {value: 'cache-first', title: 'Cache-first'},
51
+ {value: 'network-only', title: 'Network-only'},
52
+ {value: 'cache-only', title: 'Cache-only'},
53
+ ],
54
+ }, choices);
45
55
  // Questions
46
56
  return [
47
57
  {
@@ -51,28 +61,36 @@ export default class Worker extends Configurator {
51
61
  initial: config.cache_name,
52
62
  },
53
63
  {
54
- name: 'cache_only_urls',
55
- type: 'list',
56
- message: 'Specify URLs for a "cache-only" fetching strategy (comma-separated, globe supported)',
57
- initial: (config.cache_only_urls || []).join(', '),
64
+ name: 'default_fetching_strategy',
65
+ type: 'select',
66
+ message: '[default_fetching_strategy]: Choose the default fetching strategy',
67
+ choices: CHOICES.default_fetching_strategy,
68
+ initial: this.indexOfInitial(CHOICES.default_fetching_strategy, config.default_fetching_strategy),
69
+ validation: ['important'],
70
+ },
71
+ {
72
+ name: 'network_first_urls',
73
+ type: (prev, answers) => answers.default_fetching_strategy === 'network-first' ? null : 'list',
74
+ message: 'Specify URLs for a "network-first-then-cache" fetching strategy (comma-separated, globe supported)',
75
+ initial: (config.network_first_urls || []).join(', '),
58
76
  },
59
77
  {
60
78
  name: 'cache_first_urls',
61
- type: 'list',
79
+ type: (prev, answers) => answers.default_fetching_strategy === 'cache-first' ? null : 'list',
62
80
  message: 'Specify URLs for a "cache-first-then-network" fetching strategy (comma-separated, globe supported)',
63
81
  initial: (config.cache_first_urls || []).join(', '),
64
82
  },
65
83
  {
66
84
  name: 'network_only_urls',
67
- type: 'list',
85
+ type: (prev, answers) => answers.default_fetching_strategy === 'network-only' ? null : 'list',
68
86
  message: 'Specify URLs for a "network-only" fetching strategy (comma-separated, globe supported)',
69
87
  initial: (config.network_only_urls || []).join(', '),
70
88
  },
71
89
  {
72
- name: 'network_first_urls',
73
- type: 'list',
74
- message: 'Specify URLs for a "network-first-then-cache" fetching strategy (comma-separated, globe supported)',
75
- initial: (config.network_first_urls || []).join(', '),
90
+ name: 'cache_only_urls',
91
+ type: (prev, answers) => answers.default_fetching_strategy === 'cache-only' ? null : 'list',
92
+ message: 'Specify URLs for a "cache-only" fetching strategy (comma-separated, globe supported)',
93
+ initial: (config.cache_only_urls || []).join(', '),
76
94
  },
77
95
  {
78
96
  name: 'skip_waiting',
@@ -5,9 +5,9 @@
5
5
  import Url from 'url';
6
6
  import { _merge } from '@webqit/util/obj/index.js';
7
7
  import { _isObject } from '@webqit/util/js/index.js';
8
- import Configurator from '../../../Configurator.js';
8
+ import { Dotfile } from '@webqit/backpack';
9
9
 
10
- export default class Headers extends Configurator {
10
+ export default class Headers extends Dotfile {
11
11
 
12
12
  // Base name
13
13
  get name() {
@@ -6,9 +6,9 @@ import Url from 'url';
6
6
  import { _merge } from '@webqit/util/obj/index.js';
7
7
  import { _after } from '@webqit/util/str/index.js';
8
8
  import { _isObject, _isNumeric } from '@webqit/util/js/index.js';
9
- import Configurator from '../../../Configurator.js';
9
+ import { Dotfile } from '@webqit/backpack';
10
10
 
11
- export default class Redirects extends Configurator {
11
+ export default class Redirects extends Dotfile {
12
12
 
13
13
  // Base name
14
14
  get name() {
@@ -8,9 +8,9 @@ import { _merge } from '@webqit/util/obj/index.js';
8
8
  import { _isNumeric } from '@webqit/util/js/index.js';
9
9
  import { _before, _after } from '@webqit/util/str/index.js';
10
10
  import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
11
- import Configurator from '../../Configurator.js';
11
+ import { Dotfile } from '@webqit/backpack';
12
12
 
13
- export default class Manifest extends Configurator {
13
+ export default class Manifest extends Dotfile {
14
14
 
15
15
  // Base name
16
16
  get name() {
@@ -4,9 +4,9 @@
4
4
  */
5
5
  import { _merge } from '@webqit/util/obj/index.js';
6
6
  import { _isObject } from '@webqit/util/js/index.js';
7
- import Configurator from '../../Configurator.js';
7
+ import { Dotfile } from '@webqit/backpack';
8
8
 
9
- export default class Ssg extends Configurator {
9
+ export default class Ssg extends Dotfile {
10
10
 
11
11
  // Base name
12
12
  get name() {
@@ -46,7 +46,7 @@ export default class Router {
46
46
  // The loop
47
47
  // ----------------
48
48
  const next = async function(thisTick) {
49
- const thisContext = {};
49
+ const thisContext = { };
50
50
  if (!thisTick.trail || thisTick.trail.length < thisTick.destination.length) {
51
51
  thisTick = await $this.readTick(thisTick);
52
52
  // -------------