@webqit/webflo 0.11.18 → 0.11.21
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.
- package/LICENSE +21 -0
- package/README.md +69 -30
- package/package.json +2 -2
- package/src/runtime-pi/Router.js +2 -1
- package/src/runtime-pi/client/Runtime.js +2 -2
- package/src/runtime-pi/client/index.js +6 -1
- package/src/runtime-pi/client/worker/Worker.js +21 -13
- package/src/runtime-pi/client/worker/Workport.js +1 -1
- package/src/runtime-pi/client/worker/index.js +6 -1
- package/src/runtime-pi/server/index.js +2 -20
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-present, Yuxi (Evan) You
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -7,41 +7,75 @@
|
|
|
7
7
|
|
|
8
8
|
<!-- /BADGES -->
|
|
9
9
|
|
|
10
|
-
Webflo is a universal *web*, *mobile*, and *API backend* framework built to solve for the underrated `.html` + `.css` + `.js` stack! This has been written
|
|
10
|
+
Webflo is a universal *web*, *mobile*, and *API backend* framework built to solve for the underrated `.html` + `.css` + `.js` stack! This has been written to facilitate working and thinking in vanilla HTML, CSS and JavaScript - for building more authentic, web-native applications!
|
|
11
11
|
|
|
12
|
-
Ok, we've put all of that up for a straight read!
|
|
12
|
+
Ok, we've put all of that up for a 10min straight read!
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
## The Catch...
|
|
15
|
+
|
|
16
|
+
The overall motivation for Webflo is to facilitate *web-native* development; to be the cool framework that draws on native web platform features - including new fascinating features we're proposing as standards! So, it gets a little bit "futuristic"! You thus have to be excited about taking a plunge to happily meet Webflo!
|
|
17
|
+
|
|
18
|
+
## The Wins...
|
|
19
|
+
|
|
20
|
+
Much of what eludes the web today...
|
|
21
|
+
|
|
22
|
+
+ An overarching HTML-first thinking!
|
|
23
|
+
+ The build-less, vanilla advantage!
|
|
24
|
+
+ (Futuristic) Native reactivity!
|
|
25
|
+
+ (Futuristic) Minimalist-JS philosophy!
|
|
26
|
+
+ Universal-everything!
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
(Details just ahead!)
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
All of Webflo in a 10-min read!
|
|
18
33
|
|
|
19
34
|
+ [Overview](#overview)
|
|
20
35
|
+ [Installation](#installation)
|
|
21
36
|
+ [Concepts](#concepts)
|
|
37
|
+
+ [Handler Functions and Layout](#handler-functions-and-layout)
|
|
38
|
+
+ [Step Functions and Workflows](#step-functions-and-workflows)
|
|
39
|
+
+ [Pages, Layout and Templating](#pages-layout-and-templating)
|
|
40
|
+
+ [Client and Server-Side Rendering](#client-and-server-side-rendering)
|
|
41
|
+
+ [Requests and Responses](#requests-and-responses)
|
|
22
42
|
+ [Webflo Applications](#webflo-applications)
|
|
43
|
+
+ [Client-Side Applications](#client-side-applications)
|
|
44
|
+
+ [Progressive Web Apps](#progressive-web-apps)
|
|
45
|
+
+ [API Backends](#api-backends)
|
|
46
|
+
+ [Static Sites](#static-sites)
|
|
23
47
|
+ [Webflo Config](#webflo-config)
|
|
24
|
-
+ [
|
|
48
|
+
+ [Webflo Tooling](#webflo-tooling)
|
|
49
|
+
+ [OOHTML](#oohtml)
|
|
50
|
+
+ [OOHTML SSR](#oohtml-ssr)
|
|
51
|
+
+ [OOHTML CLI](#oohtml-cli)
|
|
52
|
+
+ [The Observer API](#the-observer-api)
|
|
25
53
|
+ [Getting Started](#getting-started)
|
|
26
54
|
+ [Getting Involved](#getting-involved)
|
|
27
55
|
|
|
28
56
|
## Overview
|
|
29
57
|
|
|
30
58
|
<details>
|
|
31
|
-
<summary><b>Build <i>anything</i></b> - from as basic as a static <code>index.html</code> page to as rich as a universal app that's either a <i>Multi Page Application (MPA)</i>, <i>Single Page Application (SPA)</i>, or a hybrid of
|
|
59
|
+
<summary><b>Build <i>anything</i></b> - from as basic as a static <code>index.html</code> page to as rich as a universal app that's either a <i>Multi Page Application (MPA)</i>, <i>Single Page Application (SPA)</i>, or a hybrid of both, implementing <i>Server Side Rendering (SSR)</i>, <i>Client Side Rendering (CSR)</i>, or a hybrid of both, offline and <i>PWA</i> capabilities, etc. - this time, <i>without loosing the vanilla advantage</i>!
|
|
32
60
|
</summary>
|
|
33
61
|
|
|
34
62
|
Here's a glimpse of your Webflo app.
|
|
35
63
|
|
|
36
|
-
For when your application
|
|
64
|
+
For when your application is a static site, or has static files to serve.
|
|
37
65
|
+ The `public` directory for static files.
|
|
38
|
-
+ The `server` directory for server-side routing. (i.e. dynamic request handling on the server - in the case of Multi Page Applications, API backends, etc.)
|
|
39
66
|
|
|
40
67
|
```shell
|
|
41
68
|
my-app
|
|
42
|
-
├── server/index.js
|
|
43
69
|
└── public/logo.png
|
|
44
70
|
```
|
|
71
|
+
|
|
72
|
+
For when your application has a Server side.
|
|
73
|
+
+ The `server` directory for server-side routing. (i.e. dynamic request handling on the server - in the case of Multi Page Applications, API backends, etc.)
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
my-app
|
|
77
|
+
└── server/index.js
|
|
78
|
+
```
|
|
45
79
|
|
|
46
80
|
And a typical `index.js` route handler has the following anatomy.
|
|
47
81
|
|
|
@@ -100,7 +134,7 @@ For when your application has a Client side.
|
|
|
100
134
|
└── worker/index.js
|
|
101
135
|
```
|
|
102
136
|
|
|
103
|
-
And in both cases, a typical `index.js` route handler has the following anatomy.
|
|
137
|
+
And in both cases, a typical `index.js` route handler has the following anatomy. (Same with server-side handlers.)
|
|
104
138
|
|
|
105
139
|
```js
|
|
106
140
|
/**
|
|
@@ -165,7 +199,7 @@ With [npm available on your terminal](https://docs.npmjs.com/downloading-and-ins
|
|
|
165
199
|
> System Requirements: Node.js 14.0 or later
|
|
166
200
|
|
|
167
201
|
```shell
|
|
168
|
-
|
|
202
|
+
npm i @webqit/webflo
|
|
169
203
|
```
|
|
170
204
|
|
|
171
205
|
The installation automatically creates a `package.json` file at project root, containing `@webqit/webflo` as a project dependency.
|
|
@@ -385,7 +419,7 @@ export default function(event, context, next) {
|
|
|
385
419
|
}
|
|
386
420
|
```
|
|
387
421
|
|
|
388
|
-
|
|
422
|
+
We get a step-based workflow that helps to decomplicate routing and lets us scale horizontally as our application grows larger.
|
|
389
423
|
|
|
390
424
|
<details>
|
|
391
425
|
<summary>More details...</summary>
|
|
@@ -525,7 +559,7 @@ So, above, should our handler receive static file requests like `http://localhos
|
|
|
525
559
|
|
|
526
560
|
```shell
|
|
527
561
|
my-app
|
|
528
|
-
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/
|
|
562
|
+
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/products, http://localhost:3000/products/stickers, etc
|
|
529
563
|
└── public/logo.png ------------------------- http://localhost:3000/logo.png
|
|
530
564
|
```
|
|
531
565
|
|
|
@@ -567,7 +601,7 @@ Now we get the following handler-to-URL mapping for our application:
|
|
|
567
601
|
```shell
|
|
568
602
|
my-app
|
|
569
603
|
├── worker/index.js ------------------------- http://localhost:3000/about, http://localhost:3000/logo.png
|
|
570
|
-
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/
|
|
604
|
+
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/products, http://localhost:3000/products/stickers, etc
|
|
571
605
|
└── public/logo.png ------------------------- http://localhost:3000/logo.png
|
|
572
606
|
```
|
|
573
607
|
|
|
@@ -606,7 +640,7 @@ Our overall handler-to-URL mapping for this application now becomes:
|
|
|
606
640
|
my-app
|
|
607
641
|
├── client/index.js ------------------------- http://localhost:3000/login
|
|
608
642
|
├── worker/index.js ------------------------- http://localhost:3000/about, http://localhost:3000/logo.png
|
|
609
|
-
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/
|
|
643
|
+
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/products, http://localhost:3000/products/stickers, etc
|
|
610
644
|
└── public/logo.png ------------------------- http://localhost:3000/logo.png
|
|
611
645
|
```
|
|
612
646
|
|
|
@@ -692,7 +726,7 @@ In a Multi Page Application (with an individual-page architecture), each page is
|
|
|
692
726
|
my-app
|
|
693
727
|
└── public
|
|
694
728
|
├── about/index.html ------------------------- <!DOCTYPE html>
|
|
695
|
-
├──
|
|
729
|
+
├── products/index.html ---------------------- <!DOCTYPE html>
|
|
696
730
|
├── index.html ------------------------------- <!DOCTYPE html>
|
|
697
731
|
├── header.html ------------------------------ <header></header> <!-- To appear at top of each index.html page -->
|
|
698
732
|
└── footer.html ------------------------------ <footer></footer> <!-- To appear at bottom of each index.html page -->
|
|
@@ -704,7 +738,7 @@ In a Single Page Application, each page is the same `index.html` document, and i
|
|
|
704
738
|
my-app
|
|
705
739
|
└── public
|
|
706
740
|
├── about/main.html -------------------------- <main></main> <!-- To appear at main area of index.html -->
|
|
707
|
-
├──
|
|
741
|
+
├── products/main.html ----------------------- <main></main> <!-- To appear at main area of index.html -->
|
|
708
742
|
├── main.html -------------------------------- <main></main> <!-- To appear at main area of index.html -->
|
|
709
743
|
└── index.html ------------------------------- <!DOCTYPE html>
|
|
710
744
|
```
|
|
@@ -876,7 +910,7 @@ It's all a *layout* thing, so a hybrid of the two architectures above is possibl
|
|
|
876
910
|
my-app
|
|
877
911
|
└── public
|
|
878
912
|
├── about/index.html ------------------------- <!DOCTYPE html> <!-- Document root 1 -->
|
|
879
|
-
├──
|
|
913
|
+
├── products
|
|
880
914
|
│ ├── free/main.html --------------------------- <main></main> <!-- To appear at main area of document root 2 -->
|
|
881
915
|
│ ├── paid/main.html --------------------------- <main></main> <!-- To appear at main area of document root 2 -->
|
|
882
916
|
│ ├── main.html -------------------------------- <main></main> <!-- To appear at main area of document root 2 -->
|
|
@@ -886,7 +920,7 @@ my-app
|
|
|
886
920
|
└── footer.html ------------------------------ <footer></footer> <!-- To appear at bottom of each document root -->
|
|
887
921
|
```
|
|
888
922
|
|
|
889
|
-
The above gives us three document roots: `/index.html`, `/about/index.html`, `/
|
|
923
|
+
The above gives us three document roots: `/index.html`, `/about/index.html`, `/products/index.html`. The `/products` route doubles as a Single Page Application such that visiting the `/products` route loads the document root `/products/index.html` and lets Webflo SPA routing determine which of `/products/main.html`, `/products/free/main.html`, `/products/paid/main.html` is imported on a given URL.
|
|
890
924
|
|
|
891
925
|
Webflo ensures that only the amount of JavaScript for a document root is actually loaded! So, above, a common JavaScript build is shared across the three document roots alongside an often tiny root-specific build.
|
|
892
926
|
|
|
@@ -1490,7 +1524,7 @@ On the UI, this could be used to show/hide cute error elements.
|
|
|
1490
1524
|
|
|
1491
1525
|
This property tells when a client-side redirect is ongoing - see [Scenario 4: Single Page Navigation Requests and Responses](#scenario-4-single-page-navigation-requests-and-responses) - in which case it exposes the destination URL.
|
|
1492
1526
|
|
|
1493
|
-
On the UI, this could be used to
|
|
1527
|
+
On the UI, this could be used to mark the current page as stale and prevent further interactions.
|
|
1494
1528
|
|
|
1495
1529
|
```html
|
|
1496
1530
|
<body>
|
|
@@ -1526,13 +1560,13 @@ Here are some additional examples with the [Observer API](#the-observer-api).
|
|
|
1526
1560
|
|
|
1527
1561
|
```js
|
|
1528
1562
|
// Visualize the network state
|
|
1529
|
-
let
|
|
1563
|
+
let networkVisualizer = changes => {
|
|
1530
1564
|
changes.forEach(e => {
|
|
1531
1565
|
console.log(e.name, ':', e.value);
|
|
1532
1566
|
});
|
|
1533
1567
|
};
|
|
1534
|
-
Observer.observe(document.state.network,
|
|
1535
|
-
// Or: Observer.observe(document, [ ['state', 'network'] ],
|
|
1568
|
+
Observer.observe(document.state.network, networkVisualizer);
|
|
1569
|
+
// Or: Observer.observe(document, [ ['state', 'network'] ], networkVisualizer, { subtree: true });
|
|
1536
1570
|
```
|
|
1537
1571
|
</details>
|
|
1538
1572
|
|
|
@@ -1700,7 +1734,7 @@ This strategy tells the Service Worker to always fetch given resources from the
|
|
|
1700
1734
|
</details>
|
|
1701
1735
|
</details>
|
|
1702
1736
|
|
|
1703
|
-
In all cases above, the convention for specifying URLs for a strategy accepts an [URL
|
|
1737
|
+
In all cases above, the convention for specifying URLs for a strategy accepts an [URL pattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) - against which URLs can be matched on the fly. For example, to place all files in an `/image` directory (and subdirectories) on the *Cache First* strategy, the pattern `/image/*` can be used. To place all `.svg` files in an `/icons` directory (including subdirectories) on the *Cache Only* strategy, the pattern `/icons/*.svg` can be used. (Specifically for the *Cache Only* strategy, patterns are resolved at Service Worker build-time, and each pattern must match, at least, a file.)
|
|
1704
1738
|
|
|
1705
1739
|
<details>
|
|
1706
1740
|
<summary>Example...</summary>
|
|
@@ -1716,7 +1750,7 @@ A couple APIs exists in browsers for establishing a two-way communication channe
|
|
|
1716
1750
|
|
|
1717
1751
|
###### The `workport` API
|
|
1718
1752
|
|
|
1719
|
-
This is an object with simple methods for working with *cross-thread* messages, UI and Push Notifications.
|
|
1753
|
+
This is an object with simple methods for working with *cross-thread* messages, UI Notifications, and Push Notifications.
|
|
1720
1754
|
|
|
1721
1755
|
On both the client and worker side of your application, the `workport` object is accessible from route handlers as `this.runtime.workport`.
|
|
1722
1756
|
|
|
@@ -1805,12 +1839,12 @@ workport.nofitications.fire(title, options).then(event => {
|
|
|
1805
1839
|
</details>
|
|
1806
1840
|
|
|
1807
1841
|
<details>
|
|
1808
|
-
<summary>Method: <code>.nofitications.
|
|
1842
|
+
<summary>Method: <code>.nofitications.handle()</code></summary>
|
|
1809
1843
|
|
|
1810
|
-
The `.nofitications.
|
|
1844
|
+
The `.nofitications.handle()` method (in Service-Workers) is used for handling [`notificationclick`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/notificationclick_event) events. (Handlers are called each time a notification is clicked.)
|
|
1811
1845
|
|
|
1812
1846
|
```js
|
|
1813
|
-
workport.nofitications.
|
|
1847
|
+
workport.nofitications.handle(event => {
|
|
1814
1848
|
console.log(event.action);
|
|
1815
1849
|
});
|
|
1816
1850
|
```
|
|
@@ -1973,10 +2007,15 @@ A simple tool, like [`staticgen`](https://github.com/tj/staticgen), or the basic
|
|
|
1973
2007
|
|
|
1974
2008
|
Webflo comes *convention-first*! But it is entirely configurable for when you need it! The easiest way to do this is to run the command `webflo config` and follow the walkthrough. To simply get an overview, use the command `webflo config help`, and all commands and their description are shown.
|
|
1975
2009
|
|
|
1976
|
-
##
|
|
2010
|
+
## Webflo Tooling
|
|
1977
2011
|
|
|
1978
2012
|
Webflo applications are often built on/with the following technologies.
|
|
1979
2013
|
|
|
2014
|
+
+ [OOHTML](#oohtml)
|
|
2015
|
+
+ [OOHTML SSR](#oohtml-ssr)
|
|
2016
|
+
+ [OOHTML CLI](#oohtml-cli)
|
|
2017
|
+
+ [The Observer API](#the-observer-api)
|
|
2018
|
+
|
|
1980
2019
|
### OOHTML
|
|
1981
2020
|
|
|
1982
2021
|
[OOHTML](https://github.com/webqit/oohtml) is a proposed set of new features for HTML that makes it fun to hand-author your HTML documents! Within OOHTML are [HTML Modules](https://github.com/webqit/oohtml#html-modules) and [HTML Imports](https://github.com/webqit/oohtml#html-imports), [Reactive Scripts](https://github.com/webqit/oohtml#subscript) and more!
|
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.11.
|
|
15
|
+
"version": "0.11.21",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@octokit/webhooks": "^7.15.1",
|
|
39
|
-
"@webqit/backpack": "^0.1.
|
|
39
|
+
"@webqit/backpack": "^0.1.2",
|
|
40
40
|
"@webqit/oohtml-ssr": "^1.1.0",
|
|
41
41
|
"@webqit/util": "^0.8.9",
|
|
42
42
|
"client-sessions": "^0.8.0",
|
package/src/runtime-pi/Router.js
CHANGED
|
@@ -41,12 +41,13 @@ export default class Router {
|
|
|
41
41
|
async route(method, event, arg, _default, remoteFetch = null) {
|
|
42
42
|
|
|
43
43
|
const $this = this;
|
|
44
|
+
const $runtime = this.cx.runtime;
|
|
44
45
|
|
|
45
46
|
// ----------------
|
|
46
47
|
// The loop
|
|
47
48
|
// ----------------
|
|
48
49
|
const next = async function(thisTick) {
|
|
49
|
-
const thisContext = { };
|
|
50
|
+
const thisContext = { runtime: $runtime };
|
|
50
51
|
if (!thisTick.trail || thisTick.trail.length < thisTick.destination.length) {
|
|
51
52
|
thisTick = await $this.readTick(thisTick);
|
|
52
53
|
// -------------
|
|
@@ -112,8 +112,8 @@ export default class Runtime {
|
|
|
112
112
|
// Capture all form-submit
|
|
113
113
|
// and fire to this router.
|
|
114
114
|
window.addEventListener('submit', e => {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
const form = e.target.closest('form'), submitter = e.submitter;
|
|
116
|
+
const submitParams = [ 'action', 'enctype', 'method', 'noValidate', 'target' ].reduce((params, prop) => {
|
|
117
117
|
params[prop] = submitter && submitter.hasAttribute(`form${prop.toLowerCase()}`) ? submitter[`form${_toTitle(prop)}`] : form[prop];
|
|
118
118
|
return params;
|
|
119
119
|
}, {});
|
|
@@ -15,4 +15,9 @@ export async function start(clientCallback = null) {
|
|
|
15
15
|
return new Runtime(Context.create(cx), ( ...args ) => {
|
|
16
16
|
return clientCallback ? clientCallback( ...args.concat( defaultClientCallback ) ) : defaultClientCallback( ...args );
|
|
17
17
|
});
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @APIS
|
|
22
|
+
*/
|
|
23
|
+
export * as APIS from './Runtime.js';
|
|
@@ -3,9 +3,21 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import { _any } from '@webqit/util/arr/index.js';
|
|
6
|
-
import { HttpEvent, Request, Response, Observer } from '../Runtime.js';
|
|
7
6
|
import { urlPattern } from '../../util.js';
|
|
7
|
+
import { HttpEvent, Request, Response, Observer } from '../Runtime.js';
|
|
8
8
|
import Workport from './Workport.js';
|
|
9
|
+
export {
|
|
10
|
+
URL,
|
|
11
|
+
FormData,
|
|
12
|
+
ReadableStream,
|
|
13
|
+
RequestHeaders,
|
|
14
|
+
ResponseHeaders,
|
|
15
|
+
Request,
|
|
16
|
+
Response,
|
|
17
|
+
fetch,
|
|
18
|
+
HttpEvent,
|
|
19
|
+
Observer,
|
|
20
|
+
} from '../Runtime.js';
|
|
9
21
|
|
|
10
22
|
/**
|
|
11
23
|
* ---------------------------
|
|
@@ -71,6 +83,14 @@ export default class Worker {
|
|
|
71
83
|
}) );
|
|
72
84
|
});
|
|
73
85
|
|
|
86
|
+
// ---------------
|
|
87
|
+
Observer.set(this, 'location', {});
|
|
88
|
+
Observer.set(this, 'network', {});
|
|
89
|
+
// ---------------
|
|
90
|
+
Observer.observe(this.network, es => {
|
|
91
|
+
//console.log('//////////', ...es.map(e => `${e.name}: ${e.value}`))
|
|
92
|
+
});
|
|
93
|
+
|
|
74
94
|
// -------------
|
|
75
95
|
// ONFETCH
|
|
76
96
|
self.addEventListener('fetch', event => {
|
|
@@ -114,22 +134,10 @@ export default class Worker {
|
|
|
114
134
|
}
|
|
115
135
|
}
|
|
116
136
|
});
|
|
117
|
-
workport.notifications.listen(async evt => {
|
|
118
|
-
let client = this.clients.get('*');
|
|
119
|
-
client.alert && await client.alert(evt);
|
|
120
|
-
});
|
|
121
137
|
workport.push.listen(async evt => {
|
|
122
138
|
let client = this.clients.get('*');
|
|
123
139
|
client.alert && await client.alert(evt);
|
|
124
140
|
});
|
|
125
|
-
|
|
126
|
-
// ---------------
|
|
127
|
-
Observer.set(this, 'location', {});
|
|
128
|
-
Observer.set(this, 'network', {});
|
|
129
|
-
// ---------------
|
|
130
|
-
Observer.observe(this.network, es => {
|
|
131
|
-
//console.log('//////////', ...es.map(e => `${e.name}: ${e.value}`))
|
|
132
|
-
});
|
|
133
141
|
|
|
134
142
|
}
|
|
135
143
|
|
|
@@ -15,4 +15,9 @@ export async function start(clientCallback = null) {
|
|
|
15
15
|
return new Worker(Context.create(cx), ( ...args ) => {
|
|
16
16
|
return clientCallback ? clientCallback( ...args.concat( defaultClientCallback ) ) : defaultClientCallback( ...args );
|
|
17
17
|
});
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @APIS
|
|
22
|
+
*/
|
|
23
|
+
export * as APIS from './Worker.js';
|
|
@@ -6,20 +6,6 @@ import Context from './Context.js';
|
|
|
6
6
|
import RuntimeClient from './RuntimeClient.js';
|
|
7
7
|
import Runtime from './Runtime.js';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @desc
|
|
11
|
-
*/
|
|
12
|
-
export const desc = {
|
|
13
|
-
config: {
|
|
14
|
-
headers: 'Configure automatic http headers.',
|
|
15
|
-
prerendering: 'Configure prerendering.',
|
|
16
|
-
redirects: 'Configure automatic redirects.',
|
|
17
|
-
server: 'Configure server settings.',
|
|
18
|
-
vhosts: 'Configure virtual hosts.',
|
|
19
|
-
},
|
|
20
|
-
start: 'Starts the Webflo server.',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
9
|
/**
|
|
24
10
|
* @start
|
|
25
11
|
*/
|
|
@@ -32,10 +18,6 @@ export async function start(clientCallback = null) {
|
|
|
32
18
|
}
|
|
33
19
|
|
|
34
20
|
/**
|
|
35
|
-
* @
|
|
21
|
+
* @APIS
|
|
36
22
|
*/
|
|
37
|
-
export
|
|
38
|
-
Context,
|
|
39
|
-
RuntimeClient,
|
|
40
|
-
Runtime,
|
|
41
|
-
}
|
|
23
|
+
export * as APIS from './Runtime.js';
|