@webqit/webflo 1.0.38 → 1.0.39
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/README.md +2 -2037
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
Webflo is a universal *web*, *mobile*, and *API backend* framework based on vanilla HTML, CSS, and JavaScript! It's a powerful little thing written to facilitate building more authentic, web-native applications!
|
|
10
10
|
|
|
11
|
+
<!--
|
|
11
12
|
Here, we've put all of that up for a 20mins straight read!
|
|
12
13
|
|
|
13
|
-
<!--
|
|
14
14
|
## Gear Up...
|
|
15
15
|
|
|
16
16
|
Webflo is a framework on its own track - of working and thinking in vanilla HTML, CSS and JavaScript! Instead of trying to follow certain patterns that have been touted as "norms", it takes a plunge to draw on native web platform features - plus some more futurisric, fascinating new stuff from across a few web paltforn proposals! This means that to happily meet Webflo, you also have to be excited about the idea of going one step ahead!
|
|
@@ -37,2042 +37,7 @@ Natively supporting notable new possibilities...
|
|
|
37
37
|
|
|
38
38
|
(A bit of a long read!)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
+ [Installation](#installation)
|
|
42
|
-
+ [Concepts](#concepts)
|
|
43
|
-
+ [Handler Functions and Layout](#handler-functions-and-layout)
|
|
44
|
-
+ [Step Functions and Workflows](#step-functions-and-workflows)
|
|
45
|
-
+ [Pages, Layout and Templating](#pages-layout-and-templating)
|
|
46
|
-
+ [Client and Server-Side Rendering](#client-and-server-side-rendering)
|
|
47
|
-
+ [Requests and Responses](#requests-and-responses)
|
|
48
|
-
+ [Webflo Applications](#webflo-applications)
|
|
49
|
-
+ [Client-Side Applications](#client-side-applications)
|
|
50
|
-
+ [Progressive Web Apps](#progressive-web-apps)
|
|
51
|
-
+ [API Backends](#api-backends)
|
|
52
|
-
+ [Static Sites](#static-sites)
|
|
53
|
-
+ [Webflo Config](#webflo-config)
|
|
54
|
-
+ [Webflo Tooling](#webflo-tooling)
|
|
55
|
-
+ [OOHTML](#oohtml)
|
|
56
|
-
+ [OOHTML SSR](#oohtml-ssr)
|
|
57
|
-
+ [OOHTML CLI](#oohtml-cli)
|
|
58
|
-
+ [The Observer API](#the-observer-api)
|
|
59
|
-
+ [Getting Started](#getting-started)
|
|
60
|
-
+ [Getting Involved](#getting-involved)
|
|
61
|
-
|
|
62
|
-
## Overview
|
|
63
|
-
|
|
64
|
-
<details>
|
|
65
|
-
<summary><b>Build <i>anything</i></b> - from as basic as a static <code>index.html</code> page to as rich as a <i>Multi Page Application (MPA)</i>, or <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, having offline and <i>PWA</i> capabilities, etc. - this time, <i>without loosing the vanilla advantage</i>!
|
|
66
|
-
</summary>
|
|
67
|
-
|
|
68
|
-
Here's a glimpse of your Webflo app.
|
|
69
|
-
|
|
70
|
-
For when your application is a static site, or has static files to serve:
|
|
71
|
-
+ The `public` directory for static files.
|
|
72
|
-
|
|
73
|
-
```shell
|
|
74
|
-
my-app
|
|
75
|
-
├── public/index.html ----------------- http://localhost:3000/index.html | http://localhost:3000
|
|
76
|
-
└── public/logo.png ------------------- http://localhost:3000/logo.png
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
For when your application requires dynamic request handling on the server:
|
|
80
|
-
+ The `server` directory for server-side routing.
|
|
81
|
-
|
|
82
|
-
```shell
|
|
83
|
-
my-app
|
|
84
|
-
└── server/index.js
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
In which case a typical `index.js` route handler has the following anatomy:
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
/**
|
|
91
|
-
server
|
|
92
|
-
├── index.js
|
|
93
|
-
*/
|
|
94
|
-
export default function(event, context, next) {
|
|
95
|
-
if (next.pathname) {
|
|
96
|
-
return next(); // <--------------------------------- http://localhost:3000/logo.png (or other non-root URLs)
|
|
97
|
-
}
|
|
98
|
-
return { title: 'Hello from Server' }; // <------------- http://localhost:3000/ (root URL)
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
In which case data is returned either as a JSON (API) response, or as a rendered page response where there is an `index.html` file in the `public` directory that pairs with the route.
|
|
103
|
-
|
|
104
|
-
```shell
|
|
105
|
-
my-app
|
|
106
|
-
├── server/index.js
|
|
107
|
-
└── public/index.html
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
In which case a typical `index.html` page has the following anatomy:
|
|
111
|
-
|
|
112
|
-
```html
|
|
113
|
-
<!--
|
|
114
|
-
public
|
|
115
|
-
├── index.html
|
|
116
|
-
-->
|
|
117
|
-
<!DOCTYPE html>
|
|
118
|
-
<html>
|
|
119
|
-
<head>
|
|
120
|
-
<link rel="stylesheet" href="/style.css" /> <!-- ---------------------- Application CSS -->
|
|
121
|
-
<script type="module" src="/bundle.js"></script> <!-- ----------------- Application JS bundle -->
|
|
122
|
-
<template name="routes" src="/bundle.html"></template> <!-- ------------- Reusable HTML Templates and partials (Details ahead) -->
|
|
123
|
-
</head>
|
|
124
|
-
<body>...</body>
|
|
125
|
-
</html>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
For when your application requires dynamic request handling on the client (the browser):
|
|
129
|
-
+ The `client` directory for client-side routing,
|
|
130
|
-
+ And, optionally, the `worker` directory for an all-new Service Worker based routing! (As detailed ahead.)
|
|
131
|
-
|
|
132
|
-
```shell
|
|
133
|
-
my-app
|
|
134
|
-
├── client/index.js
|
|
135
|
-
└── worker/index.js
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Where in both cases, a typical `index.js` route handler has the same familiar anatomy:
|
|
139
|
-
|
|
140
|
-
```js
|
|
141
|
-
/**
|
|
142
|
-
[client|worker]
|
|
143
|
-
├── index.js
|
|
144
|
-
*/
|
|
145
|
-
export default function(event, context, next) {
|
|
146
|
-
if (next.pathname) {
|
|
147
|
-
return next(); // <--------------------------------- http://localhost:3000/logo.png (or other non-root URLs)
|
|
148
|
-
}
|
|
149
|
-
return { title: 'Hello from [Browser|Worker]' }; // <--- http://localhost:3000/ (root URL)
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
This and much more - ahead!
|
|
154
|
-
</details>
|
|
155
|
-
|
|
156
|
-
<details>
|
|
157
|
-
<summary><b>Build <i>future-proof anything</i></b> by banking more on web standards and less on abstractions! Webflo <i>just follows</i> where a native feature, standard, or conventional HTML, CSS or JS <i>already works</i>!</summary>
|
|
158
|
-
|
|
159
|
-
Here's a glimpse of the standards-based stack you get of Webflo!
|
|
160
|
-
|
|
161
|
-
For when your application involves routing:
|
|
162
|
-
+ [The Fetch Standard](https://fetch.spec.whatwg.org/), comprising of the [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request), [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response), and [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) interfaces - used for all things *requests and responses* - across client, server, and Service Worker environments. ([Details ahead](#requests-and-responses))
|
|
163
|
-
|
|
164
|
-
> This paves the way to using other native APIs as-is, when handling requests and responses. For example, if you sent an instance of the native [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData), [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob), [File](https://developer.mozilla.org/en-US/docs/Web/API/File), or [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) object from the browser side of your application, you'd be getting the equivalent instance on the server side!
|
|
165
|
-
|
|
166
|
-
+ [WHATWG URL](https://url.spec.whatwg.org/) and [WHATWG URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) - used for all things *URL* and *URL pattern matching*, respectively - across client, server, and Service Worker environments. ([Details ahead](#))
|
|
167
|
-
|
|
168
|
-
For when your application involves pages and a UI:
|
|
169
|
-
+ [The HTML Standard](https://html.spec.whatwg.org/) - held for all things *markup* - across client, server, and Service Worker environments! You'll absolutely ❤ love it that your pages and page components can live as plain `.html` files! The browser already does!
|
|
170
|
-
|
|
171
|
-
> This HTML-first approach is new! And you can get away with a "zero-JavaScript" proposition, or something more of a *Progressive Enhancement* proposition that makes do with "just-enough JavaScript"!
|
|
172
|
-
|
|
173
|
-
+ [WHATWG DOM](https://dom.spec.whatwg.org/) - available universally - not only on the client-side, but also on the server-side via [OOHTML-SSR](#oohtml-ssr) - all of which lets us have *dynamic pages*.
|
|
174
|
-
|
|
175
|
-
> And you get to have [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) as powerful building blocks.
|
|
176
|
-
|
|
177
|
-
Same web standards everwhere you look! You come off with a web-native app!
|
|
178
|
-
</details>
|
|
179
|
-
|
|
180
|
-
## Installation
|
|
181
|
-
|
|
182
|
-
Every Webflo project starts on an empty directory that you can create on your machine. The command below makes a new directory `my-app` from the terminal and navigates into it.
|
|
183
|
-
|
|
184
|
-
```shell
|
|
185
|
-
mkdir my-app
|
|
186
|
-
cd my-app
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
With [npm available on your terminal](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), run the following command to install Webflo to your project:
|
|
190
|
-
|
|
191
|
-
> System Requirements: Node.js 18.0 (having stable Fetch API support) or later
|
|
192
|
-
|
|
193
|
-
```shell
|
|
194
|
-
npm i @webqit/webflo
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
The installation automatically creates a `package.json` file at project root, containing `@webqit/webflo` as a project dependency.
|
|
198
|
-
|
|
199
|
-
```json
|
|
200
|
-
{
|
|
201
|
-
"dependencies": {
|
|
202
|
-
"@webqit/webflo": "..."
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Other important definitions like project `name`, package `type`, and *aliases* for common Webflo commands will now also belong here.
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"name": "my-app",
|
|
212
|
-
"type": "module",
|
|
213
|
-
"scripts": {
|
|
214
|
-
"start": "webflo start::server --mode=dev",
|
|
215
|
-
"generate": "webflo generate::client --compression=gz --auto-embed"
|
|
216
|
-
},
|
|
217
|
-
"dependencies": {
|
|
218
|
-
"@webqit/webflo": "..."
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
And that gets it all ready! The commands `npm start` and `npm run generate` will be coming in often during development.
|
|
224
|
-
|
|
225
|
-
### "Hello World!"
|
|
226
|
-
|
|
227
|
-
To be sure that Webflo is listening, run `npx webflo help` on the terminal. An overview of available commands should be shown.
|
|
228
|
-
|
|
229
|
-
If you can't wait to say *Hello World!* 😅, you can have an HTML page say that right away!
|
|
230
|
-
+ Create an `index.html` file in a new subdirectory `public`.
|
|
231
|
-
|
|
232
|
-
```shell
|
|
233
|
-
public
|
|
234
|
-
└── index.html
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
```html
|
|
238
|
-
<!DOCTYPE html>
|
|
239
|
-
<html>
|
|
240
|
-
<head>
|
|
241
|
-
<title>My App</title>
|
|
242
|
-
</head>
|
|
243
|
-
<body>
|
|
244
|
-
<h1>Hello World!</h1>
|
|
245
|
-
<p>This is <b>My App</b></p>
|
|
246
|
-
</body>
|
|
247
|
-
</html>
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
+ Start the Webflo server and visit `http://localhost:3000` on your browser to see your page. 😃
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
npm start
|
|
254
|
-
```
|
|
255
|
-
+ Welcome to Webflo!
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
> **Note**<br>This is documentation for Webflo@0.11.x which is compatible with OOHTML@1.x. Webflo@next which is compatible with OOHTML@2.x is coming soon!
|
|
259
|
-
|
|
260
|
-
## Concepts
|
|
261
|
-
|
|
262
|
-
+ [Handler Functions and Layout](#handler-functions-and-layout)
|
|
263
|
-
+ [Step Functions and Workflows](#step-functions-and-workflows)
|
|
264
|
-
+ [Pages, Layout and Templating](#pages-layout-and-templating)
|
|
265
|
-
+ [Client and Server-Side Rendering](#client-and-server-side-rendering)
|
|
266
|
-
+ [Requests and Responses](#requests-and-responses)
|
|
267
|
-
|
|
268
|
-
### Handler Functions and Layout
|
|
269
|
-
|
|
270
|
-
Functions come in in Webflo when you need to dynamically handle requests.
|
|
271
|
-
|
|
272
|
-
Whether building a *server-based*, *browser-based*, or *universal* application, Webflo gives you one consistent way to handle requests and navigation: using *handler functions*!
|
|
273
|
-
|
|
274
|
-
You just define an `index.js` file with a function that gets called to handle a request!
|
|
275
|
-
|
|
276
|
-
```js
|
|
277
|
-
/**
|
|
278
|
-
[server|client|worker]
|
|
279
|
-
├── index.js
|
|
280
|
-
*/
|
|
281
|
-
export default function(event, context, next, fetch) {
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
<details>
|
|
286
|
-
<summary>Functions may have a name...</summary>
|
|
287
|
-
|
|
288
|
-
> The following function handles only `GET` requests:
|
|
289
|
-
|
|
290
|
-
```js
|
|
291
|
-
export function GET(event, context, next, fetch) {
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
> Function names take after [*HTTP methods*](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods): `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`, `HEAD`, etc.
|
|
296
|
-
|
|
297
|
-
> Function names are lower case for Webflo version <= `0.11.23`, in which case `delete` is `del`.
|
|
298
|
-
</details>
|
|
299
|
-
|
|
300
|
-
<details>
|
|
301
|
-
<summary>Functions may also may be <code>async</code>...</summary>
|
|
302
|
-
|
|
303
|
-
> The following function can simply `await` asynchronous stuff:
|
|
304
|
-
|
|
305
|
-
```js
|
|
306
|
-
export async function GET(event, context, next, fetch) {
|
|
307
|
-
let a = await b();
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
</details>
|
|
311
|
-
|
|
312
|
-
Each function receives an `event` object representing details about the request - e.g. `event.request`, `event.url`, `event.session`. ([Details ahead](#workflow-api).)
|
|
313
|
-
|
|
314
|
-
While the `context` and `next` parameters are discussed below, `fetch` is a [fetch](https://fetch.spec.whatwg.org/)-equivalent function passed in for *convenience* - for initiating remote requests.
|
|
315
|
-
|
|
316
|
-
**Functions that will respond to requests on the server-side** go into a directory named `server`.
|
|
317
|
-
|
|
318
|
-
```js
|
|
319
|
-
/**
|
|
320
|
-
server
|
|
321
|
-
├── index.js
|
|
322
|
-
*/
|
|
323
|
-
export default function(event, context, next) {
|
|
324
|
-
if (next.pathname) return next();
|
|
325
|
-
return {
|
|
326
|
-
title: 'Home | FluffyPets',
|
|
327
|
-
source: 'server',
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
<details>
|
|
333
|
-
<summary>How it works...</summary>
|
|
334
|
-
|
|
335
|
-
> The above function will respond on starting the server - `npm start` on your terminal - and visiting http://localhost:3000.
|
|
336
|
-
</details>
|
|
337
|
-
|
|
338
|
-
**Funtions that will respond to requests on the client-side (from right within the browser)** go into a directory named `client`.
|
|
339
|
-
|
|
340
|
-
```js
|
|
341
|
-
/**
|
|
342
|
-
client
|
|
343
|
-
├── index.js
|
|
344
|
-
*/
|
|
345
|
-
export default function(event, context, next) {
|
|
346
|
-
if (next.pathname) return next();
|
|
347
|
-
return {
|
|
348
|
-
title: 'Home | FluffyPets',
|
|
349
|
-
source: 'in-browser',
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
<details>
|
|
355
|
-
<summary>How it works...</summary>
|
|
356
|
-
|
|
357
|
-
> The above function is built as part of your application's client-side script from the `npm run generate` command. It is typically bundled to the file `./public/bundle.js`. And the `--auto-embed` flag in that command gets it automatically embedded on your `./public/index.html` page as `<script type="module" src="/bundle.js"></script>`. Then it responds from right in the browser on visiting http://localhost:3000.
|
|
358
|
-
</details>
|
|
359
|
-
|
|
360
|
-
For *browser-based* applications that want to employ Service-Workers (typically, Progressive Web Apps), Webflo allows for equivalent request handlers as part of the Service Worker. These **worker-based** functions go into a directory named `worker`.
|
|
361
|
-
|
|
362
|
-
```js
|
|
363
|
-
/**
|
|
364
|
-
worker
|
|
365
|
-
├── index.js
|
|
366
|
-
*/
|
|
367
|
-
export default function(event, context, next) {
|
|
368
|
-
if (next.pathname) return next();
|
|
369
|
-
return {
|
|
370
|
-
title: 'Home | FluffyPets',
|
|
371
|
-
source: 'service-worker',
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
<details>
|
|
377
|
-
<summary>How it works...</summary>
|
|
378
|
-
|
|
379
|
-
> The above function is built as part of your application's Service Worker script from the `npm run generate` command. It is typically bundled to the file `./public/worker.js`, and the main application bundle automatically registers this as the application's Service Worker. Now, our function responds from within the Service Worker on visiting http://localhost:3000. (More details [ahead](#service-workers).)
|
|
380
|
-
</details>
|
|
381
|
-
|
|
382
|
-
So, depending on where requests are best handled for your type of application, handler functions may be placed as below:
|
|
383
|
-
|
|
384
|
-
```shell
|
|
385
|
-
client
|
|
386
|
-
├── index.js
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
```shell
|
|
390
|
-
worker
|
|
391
|
-
├── index.js
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
```shell
|
|
395
|
-
server
|
|
396
|
-
├── index.js
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
Static files, e.g. images, stylesheets, etc, have their place in a files directory named `public`.
|
|
400
|
-
|
|
401
|
-
```shell
|
|
402
|
-
public
|
|
403
|
-
└── logo.png
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### Step Functions and Workflows
|
|
407
|
-
|
|
408
|
-
Whether routing in the `/client`, `/worker`, or `/server` directory above, nested URLs follow the concept of Step Functions! These are parent-child layout of handlers that model your application's URL structure.
|
|
409
|
-
|
|
410
|
-
```shell
|
|
411
|
-
server
|
|
412
|
-
├── index.js --------------------------------- http://localhost:3000
|
|
413
|
-
└── products/index.js ------------------------ http://localhost:3000/products
|
|
414
|
-
└── stickers/index.js ------------------ http://localhost:3000/products/stickers
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
Each step calls a `next()` function to forward the current request to the next step of the given URL.
|
|
418
|
-
|
|
419
|
-
```js
|
|
420
|
-
/**
|
|
421
|
-
server
|
|
422
|
-
├── index.js
|
|
423
|
-
*/
|
|
424
|
-
export default async function(event, context, next) {
|
|
425
|
-
if (next.stepname) return next();
|
|
426
|
-
return { title: 'Home | FluffyPets' };
|
|
427
|
-
}
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
```js
|
|
431
|
-
/**
|
|
432
|
-
server
|
|
433
|
-
├── products/index.js
|
|
434
|
-
*/
|
|
435
|
-
export default function(event, context, next) {
|
|
436
|
-
if (next.stepname) return next();
|
|
437
|
-
return { title: 'Products' };
|
|
438
|
-
}
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
We get a step-based workflow that helps to decomplicate routing and lets us build out each route horizontally!
|
|
442
|
-
|
|
443
|
-
<details>
|
|
444
|
-
<summary>Each step can entirely control the next...</summary>
|
|
445
|
-
|
|
446
|
-
Here, a parent step can pass a `context` object to a child step, and can *recompose* its return value.
|
|
447
|
-
|
|
448
|
-
```js
|
|
449
|
-
/**
|
|
450
|
-
server
|
|
451
|
-
├── index.js
|
|
452
|
-
*/
|
|
453
|
-
export default async function(event, context, next) {
|
|
454
|
-
if (next.stepname) {
|
|
455
|
-
let childContext = { user: { id: 2 }, };
|
|
456
|
-
let childResponse = await next(childContext);
|
|
457
|
-
return { ...childResponse, title: childResponse.title + ' | FluffyPets' };
|
|
458
|
-
}
|
|
459
|
-
return { title: 'Home | FluffyPets' };
|
|
460
|
-
}
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
<details>
|
|
464
|
-
<summary>But a function can just talk to any other function...</summary>
|
|
465
|
-
|
|
466
|
-
It's versatile, so the `next()` function can be used to re-route the current request to a different handler - using a relative or absolute URL.
|
|
467
|
-
|
|
468
|
-
```js
|
|
469
|
-
/**
|
|
470
|
-
server
|
|
471
|
-
├── index.js
|
|
472
|
-
*/
|
|
473
|
-
export default async function(event, context, next) {
|
|
474
|
-
if (next.stepname === 'products') {
|
|
475
|
-
return next(context, '/api/products?params=allowed'); // With an absolute URL
|
|
476
|
-
}
|
|
477
|
-
return { title: 'Home | FluffyPets' };
|
|
478
|
-
}
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
```js
|
|
482
|
-
/**
|
|
483
|
-
server
|
|
484
|
-
├── products/index.js
|
|
485
|
-
*/
|
|
486
|
-
export default async function(event, context, next) {
|
|
487
|
-
if (next.stepname) return next();
|
|
488
|
-
return next(context, '../api/products?params=allowed'); // With a relative URL
|
|
489
|
-
}
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
And you can make that a full-fledged *in-app* request - passing in `fetch`-equivalent parameters.
|
|
493
|
-
|
|
494
|
-
```js
|
|
495
|
-
/**
|
|
496
|
-
server
|
|
497
|
-
├── index.js
|
|
498
|
-
*/
|
|
499
|
-
export default async function(event, context, next) {
|
|
500
|
-
if (next.stepname === 'products') {
|
|
501
|
-
return next(context, '/api/products?params=allowed', {
|
|
502
|
-
method: 'get', { headers: { Authorization: 'djjdd' } }
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
return { title: 'Home | FluffyPets' };
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
These requests are received at destination route - `/api/products` above - as regular HTTP requests!
|
|
510
|
-
</details>
|
|
511
|
-
</details>
|
|
512
|
-
|
|
513
|
-
For even more flexibility, workflows may be designed with *wildcard* steps using a hyphen `-` as step name. At runtime, a wildcard step matches any URL segment at its level in the hierarchy! A `this.stepname` property is always available to tell which URL segment has been matched.
|
|
514
|
-
|
|
515
|
-
```js
|
|
516
|
-
/**
|
|
517
|
-
server
|
|
518
|
-
├── -/index.js
|
|
519
|
-
*/
|
|
520
|
-
export default function(event, context, next) {
|
|
521
|
-
if (this.stepname === 'products') {
|
|
522
|
-
return { title: 'Products' };
|
|
523
|
-
}
|
|
524
|
-
return { title: 'Untitled' };
|
|
525
|
-
}
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
<details>
|
|
529
|
-
<summary>More details...</summary>
|
|
530
|
-
|
|
531
|
-
> Every handler function has the following contextual properties:
|
|
532
|
-
> + `this.stepname` - The name of the current step.
|
|
533
|
-
> + `this.pathname` - The URL pathname of the current step.
|
|
534
|
-
> + `next.stepname` - The name of the next step.
|
|
535
|
-
> + `next.pathname` - The remaining URL pathname after the current step.
|
|
536
|
-
> Server-side handlers have the following in addition:
|
|
537
|
-
> + `this.dirname` - The filesystem pathname of the current step.
|
|
538
|
-
</details>
|
|
539
|
-
|
|
540
|
-
Additionally, workflows may be designed with as many or as few step functions as necessary; the flow control parameters `next.stepname` and `next.pathname` are always available at any point to help with the remaining part of the given URL.
|
|
541
|
-
|
|
542
|
-
This means that it is even possible to handle all URLs from the root handler alone.
|
|
543
|
-
|
|
544
|
-
```js
|
|
545
|
-
/**
|
|
546
|
-
server
|
|
547
|
-
├── index.js
|
|
548
|
-
*/
|
|
549
|
-
export default function(event, context, next) {
|
|
550
|
-
// For http://localhost:3000/products
|
|
551
|
-
if (next.pathname === 'products') {
|
|
552
|
-
return { title: 'Products' };
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// For http://localhost:3000/products/stickers
|
|
556
|
-
if (next.pathname === 'products/stickers') {
|
|
557
|
-
return { title: 'Stickers' };
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// Should we later support other URLs like static assets http://localhost:3000/logo.png
|
|
561
|
-
if (next.pathname) {
|
|
562
|
-
return next();
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// For the root URL http://localhost:3000
|
|
566
|
-
return { title: 'Home' };
|
|
567
|
-
}
|
|
568
|
-
```
|
|
569
|
-
|
|
570
|
-
The `next()` function still plays an important role above because Webflo takes a *default action* when `next()` is called at the *edge* of the workflow - this point where there are no more step functions as there are URL segments.
|
|
571
|
-
|
|
572
|
-
**For workflows in the `/server` directory**, the *default action* of `next()`ing at the edge is to go match and return a static file in the `public` directory.
|
|
573
|
-
|
|
574
|
-
So, above, should our handler receive static file requests like `http://localhost:3000/logo.png`, the statement `return next()` would get Webflo to match and return the logo at `public/logo.png`, if any; a `404` response otherwise.
|
|
575
|
-
|
|
576
|
-
```shell
|
|
577
|
-
my-app
|
|
578
|
-
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/products, http://localhost:3000/products/stickers, etc
|
|
579
|
-
└── public/logo.png ------------------------- http://localhost:3000/logo.png
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
> **Note**
|
|
583
|
-
> <br>Obviously, the root handler effectively becomes the single point of entry to the application - being that it sees even requests for static files!
|
|
584
|
-
|
|
585
|
-
**For workflows in the `/worker` directory**, the *default action* of `next()`ing at the edge is to send the request through the network to the server. (But Webflo will check to see whether to (and how to) resolve the request from the application cache.)
|
|
586
|
-
|
|
587
|
-
So, above, if we defined handler functions in the `/worker` directory, we could selectively handle specific requests while `next()`ing others to the server.
|
|
588
|
-
|
|
589
|
-
```js
|
|
590
|
-
/**
|
|
591
|
-
worker
|
|
592
|
-
├── index.js
|
|
593
|
-
*/
|
|
594
|
-
export default async function(event, context, next) {
|
|
595
|
-
// For http://localhost:3000/about
|
|
596
|
-
if (next.pathname === 'about') {
|
|
597
|
-
return {
|
|
598
|
-
name: 'FluffyPets',
|
|
599
|
-
version: '1.0',
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// For http://localhost:3000/logo.png
|
|
604
|
-
if (next.pathname === 'logo.png') {
|
|
605
|
-
let response = await next();
|
|
606
|
-
console.log( 'Logo file size:', response.headers.get('Content-Length') );
|
|
607
|
-
return response;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// For every other URL
|
|
611
|
-
return next();
|
|
612
|
-
}
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
Now we get the following handler-to-URL mapping for our application:
|
|
616
|
-
|
|
617
|
-
```shell
|
|
618
|
-
my-app
|
|
619
|
-
├── worker/index.js ------------------------- http://localhost:3000/about, http://localhost:3000/logo.png
|
|
620
|
-
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/products, http://localhost:3000/products/stickers, etc
|
|
621
|
-
└── public/logo.png ------------------------- http://localhost:3000/logo.png
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
<details>
|
|
625
|
-
<summary>More details...</summary>
|
|
626
|
-
|
|
627
|
-
> Handlers in the `/worker` directory see only Same-Origin requests, being that Cross-Origin URLs like `https://auth.example.com/oauth` do not belong in the application's layout! But as detailed later, these external URLs may be may configured for strategic caching by the Service Worker.
|
|
628
|
-
</details>
|
|
629
|
-
|
|
630
|
-
**For workflows in the `/client` directory**, the *default action* of `next()`ing at the edge is to send the request through the network to the server. But where there is a Service Worker layer, then that becomes the next destination.
|
|
631
|
-
|
|
632
|
-
So, above, if we defined handler functions in the `/client` directory, we could selectively handle specific navigation requests in-browser while `next()`ing others down to the server, or first, the Service Worker layer.
|
|
633
|
-
|
|
634
|
-
```js
|
|
635
|
-
/**
|
|
636
|
-
client
|
|
637
|
-
├── index.js
|
|
638
|
-
*/
|
|
639
|
-
export default async function(event, context, next) {
|
|
640
|
-
// For http://localhost:3000/login
|
|
641
|
-
if (next.pathname === 'login') {
|
|
642
|
-
return {
|
|
643
|
-
name: 'John Doe',
|
|
644
|
-
role: 'owner',
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// For every other URL
|
|
649
|
-
return next();
|
|
650
|
-
}
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
Our overall handler-to-URL mapping for the hypothetical application in context now becomes:
|
|
654
|
-
|
|
655
|
-
```shell
|
|
656
|
-
my-app
|
|
657
|
-
├── client/index.js ------------------------- http://localhost:3000/login
|
|
658
|
-
├── worker/index.js ------------------------- http://localhost:3000/about, http://localhost:3000/logo.png
|
|
659
|
-
├── server/index.js ------------------------- http://localhost:3000, http://localhost:3000/products, http://localhost:3000/products/stickers, etc
|
|
660
|
-
└── public/logo.png ------------------------- http://localhost:3000/logo.png
|
|
661
|
-
```
|
|
662
|
-
|
|
663
|
-
If there's anything we have now, it is the ability to break work down<a href="https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm"><small><sup>[i]</sup></small></a>, optionally across step functions, optionally between layers!
|
|
664
|
-
|
|
665
|
-
### Pages, Layout and Templating
|
|
666
|
-
|
|
667
|
-
HTML files in the `public` directory, just like every other *public* file, are served statically when accessed directly - e.g. `http://localhost:3000/index.html`. But `index.html` files, specifically, are treated as *pages* by Webflo. They are, therefore, also accessible with path URLs like `http://localhost:3000`.
|
|
668
|
-
|
|
669
|
-
```shell
|
|
670
|
-
my-app
|
|
671
|
-
└── public/index.html ----------------------- http://localhost:3000/index.html, http://localhost:3000
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
But, where an `index.html` file pairs with a route...
|
|
675
|
-
|
|
676
|
-
```shell
|
|
677
|
-
my-app
|
|
678
|
-
├── server/index.js
|
|
679
|
-
└── public/index.html
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
...the route handler determines what happens.
|
|
683
|
-
|
|
684
|
-
```js
|
|
685
|
-
/**
|
|
686
|
-
server
|
|
687
|
-
├── index.js
|
|
688
|
-
*/
|
|
689
|
-
export default async function(event, context, next) {
|
|
690
|
-
// For http://localhost:3000/index.html, etc
|
|
691
|
-
if (next.pathname) {
|
|
692
|
-
return next();
|
|
693
|
-
}
|
|
694
|
-
// For http://localhost:3000 specifically
|
|
695
|
-
return { ... };
|
|
696
|
-
}
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
Now, we are able to access the data component of a route differently from its HTML component!
|
|
700
|
-
|
|
701
|
-
```shell
|
|
702
|
-
my-app
|
|
703
|
-
└── server/index.js ------------------------- http://localhost:3000 -------------------- application/json
|
|
704
|
-
└── public/index.html ----------------------- http://localhost:3000/index.html --------- text/html
|
|
705
|
-
```
|
|
706
|
-
|
|
707
|
-
But, we can also access the route in a way that gets the data rendered into the automatically-paired `index.html` file for a dynamic page response. We'd simply set the [`Accept`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) header of the request to a value of `text/html`, and Webflo will automatically perform [Server-Side Rendering](#client-and-server-side-rendering) to give a page response.
|
|
708
|
-
|
|
709
|
-
> **Note**
|
|
710
|
-
> <br>The `Accept` header hint is already how browsers make requests on every page load. Here, it just works!
|
|
711
|
-
|
|
712
|
-
This automatic pairing of an `index.html` file with a route works the same for nested routes! But top-level `index.html` files are implicitly inherited down the hierarchy. That means that subroutes do not need to have their own `index.html` document, unless necessary.
|
|
713
|
-
|
|
714
|
-
#### Layout and Templating Overview
|
|
715
|
-
|
|
716
|
-
<details>
|
|
717
|
-
<summary>Some disambiguation...</summary>
|
|
718
|
-
|
|
719
|
-
> In a Single Page Application, all pages are based off a single `index.html` document. In a Multi Page Application, pages are individual `index.html` documents - ideally. But, Server-Side Rendering makes it possible to serve the same, but dynamically-rendered, `index.html` document across page loads - essentially an SPA architecture hiding on the server. But, here, lets take Multi Page Applications for an individual-page architecture.
|
|
720
|
-
</details>
|
|
721
|
-
|
|
722
|
-
In a Multi Page Application (with an individual-page architecture), each page is its own `index.html` document, and it is often necessary to have certain page sections - e.g. site header, footer, and sidebar, etc. - stay consistent across pages. These sections can be defined once and *imported* on every page.
|
|
723
|
-
|
|
724
|
-
```html
|
|
725
|
-
my-app
|
|
726
|
-
└── public
|
|
727
|
-
├── about/index.html ------------------------- <!DOCTYPE html>
|
|
728
|
-
├── products/index.html ---------------------- <!DOCTYPE html>
|
|
729
|
-
├── index.html ------------------------------- <!DOCTYPE html>
|
|
730
|
-
├── header.html ------------------------------ <header></header> <!-- To appear at top of each index.html page -->
|
|
731
|
-
└── footer.html ------------------------------ <footer></footer> <!-- To appear at bottom of each index.html page -->
|
|
732
|
-
```
|
|
733
|
-
|
|
734
|
-
In a Single Page Application, each page is the same `index.html` document, and it is often necessary to have the main page sections change on each route. These sections can be defined per-route and *imported* to the document on navigating to their respective route.
|
|
735
|
-
|
|
736
|
-
```html
|
|
737
|
-
my-app
|
|
738
|
-
└── public
|
|
739
|
-
├── about/main.html -------------------------- <main></main> <!-- To appear at main area of index.html -->
|
|
740
|
-
├── products/main.html ----------------------- <main></main> <!-- To appear at main area of index.html -->
|
|
741
|
-
├── main.html -------------------------------- <main></main> <!-- To appear at main area of index.html -->
|
|
742
|
-
└── index.html ------------------------------- <!DOCTYPE html>
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
This, in both cases, is templating - the ability to define HTML *partials* once, and have them reused multiple times. Webflo just concerns itself with templating, and the choice of a Multi Page Application or Single Page Application becomes yours! And heck, you can even have the best of both worlds in the same application - with an architecture we'll call [Multi SPA](#in-a-multi-spa-layout)! It's all a *layout* thing!
|
|
746
|
-
|
|
747
|
-
Now, with pages in Webflo being [DOM-based](#overview) (both client-side and [server-side](#oohtml-ssr)), documents can be manipulated directly with DOM APIs, e.g. to replace or insert nodes, attributes, etc. But even better, templating in Webflo is based on the [HTML Modules](https://github.com/webqit/oohtml#html-modules) and [HTML Imports](https://github.com/webqit/oohtml#html-imports) features in [OOHTML](#oohtml) - unless disabled in config. These features provide a powerful declarative templating system on top of the standard [HTML `<template>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) element - all in a *module*, *export* and *import* paradigm.
|
|
748
|
-
|
|
749
|
-
Here, you are able to define reusable contents in a `<template>` element...
|
|
750
|
-
|
|
751
|
-
```html
|
|
752
|
-
<head>
|
|
753
|
-
<template name="routes">
|
|
754
|
-
<header exportgroup="header.html">Header Area</header>
|
|
755
|
-
<main exportgroup="main.html">Main Area</main>
|
|
756
|
-
</template>
|
|
757
|
-
</head>
|
|
758
|
-
```
|
|
759
|
-
|
|
760
|
-
...and have them imported anywhere on the root document using an `<import>` element:
|
|
761
|
-
|
|
762
|
-
```html
|
|
763
|
-
<body>
|
|
764
|
-
<import template="routes" name="header.html"></import>
|
|
765
|
-
<import template="routes" name="main.html"></import>
|
|
766
|
-
</body>
|
|
767
|
-
```
|
|
768
|
-
|
|
769
|
-
The *module* element - `<template>` - is also able to load its contents from a remote `.html` file that serves as a bundle:
|
|
770
|
-
|
|
771
|
-
```html
|
|
772
|
-
<!--
|
|
773
|
-
public
|
|
774
|
-
├── bundle.html
|
|
775
|
-
-->
|
|
776
|
-
<header exportgroup="header.html">Header Area</header>
|
|
777
|
-
<main exportgroup="main.html">Main Area</main>
|
|
778
|
-
```
|
|
779
|
-
|
|
780
|
-
```html
|
|
781
|
-
<!--
|
|
782
|
-
public
|
|
783
|
-
├── index.html
|
|
784
|
-
-->
|
|
785
|
-
<head>
|
|
786
|
-
<template name="routes" src="/bundle.html"></template>
|
|
787
|
-
</head>
|
|
788
|
-
```
|
|
789
|
-
|
|
790
|
-
What [we'll see shortly](#bundling) is how multiple standalone `.html` files - e.g. those `header.html`, `footer.html`, `main.html` files above - come together into one `bundle.html` file for an application.
|
|
791
|
-
|
|
792
|
-
#### In a Multi Page Layout
|
|
793
|
-
|
|
794
|
-
In a Multi Page layout (as seen [earlier](#layout-and-templating-overview)), generic contents - e.g. header and footer sections, etc. - are typically bundled into one `bundle.html` file that can be embedded on each page of the application.
|
|
795
|
-
|
|
796
|
-
```html
|
|
797
|
-
<!--
|
|
798
|
-
public
|
|
799
|
-
├── index.html
|
|
800
|
-
-->
|
|
801
|
-
<!DOCTYPE html>
|
|
802
|
-
<html>
|
|
803
|
-
<head>
|
|
804
|
-
<script type="module" src="/bundle.js"></script>
|
|
805
|
-
<template name="routes" src="/bundle.html"></template>
|
|
806
|
-
</head>
|
|
807
|
-
<body>
|
|
808
|
-
<import template="routes" name="header.html"></import>
|
|
809
|
-
<main>Welcome to our Home Page</main>
|
|
810
|
-
<import template="routes" name="footer.html"></import>
|
|
811
|
-
</body>
|
|
812
|
-
</html>
|
|
813
|
-
```
|
|
814
|
-
|
|
815
|
-
```html
|
|
816
|
-
<!--
|
|
817
|
-
public/about
|
|
818
|
-
├── index.html
|
|
819
|
-
-->
|
|
820
|
-
<!DOCTYPE html>
|
|
821
|
-
<html>
|
|
822
|
-
<head>
|
|
823
|
-
<script type="module" src="/bundle.js"></script>
|
|
824
|
-
<template name="routes" src="/bundle.html"></template>
|
|
825
|
-
</head>
|
|
826
|
-
<body>
|
|
827
|
-
<import template="routes" name="header.html"></import>
|
|
828
|
-
<main>Welcome to our About Page</main>
|
|
829
|
-
<import template="routes" name="footer.html"></import>
|
|
830
|
-
</body>
|
|
831
|
-
</html>
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
```html
|
|
835
|
-
<!--
|
|
836
|
-
public/products
|
|
837
|
-
├── index.html
|
|
838
|
-
-->
|
|
839
|
-
<!DOCTYPE html>
|
|
840
|
-
<html>
|
|
841
|
-
<head>
|
|
842
|
-
<script type="module" src="/bundle.js"></script>
|
|
843
|
-
<template name="routes" src="/bundle.html"></template>
|
|
844
|
-
</head>
|
|
845
|
-
<body>
|
|
846
|
-
<import template="routes" name="header.html"></import>
|
|
847
|
-
<main>Welcome to our Products Page</main>
|
|
848
|
-
<import template="routes" name="footer.html"></import>
|
|
849
|
-
</body>
|
|
850
|
-
</html>
|
|
851
|
-
```
|
|
852
|
-
|
|
853
|
-
<details>
|
|
854
|
-
<summary>How it works...</summary>
|
|
855
|
-
|
|
856
|
-
> In this architecture, navigation is traditional - a new page loads each time. The `bundle.js` script comes with the appropriate OOHTML support level required for the imports to function.
|
|
857
|
-
</details>
|
|
858
|
-
|
|
859
|
-
#### In a Single Page Layout
|
|
860
|
-
|
|
861
|
-
In a Single Page layout (as seen [earlier](#layout-and-templating-overview)), page-specific contents - e.g. main sections - are typically bundled together into one `bundle.html` file that can be embedded on the document root. Notice how nested routes end up as nested `<template>` elements that form the equivalent of the application's URL structure.
|
|
862
|
-
|
|
863
|
-
```html
|
|
864
|
-
<!--
|
|
865
|
-
public
|
|
866
|
-
├── bundle.html
|
|
867
|
-
-->
|
|
868
|
-
<template name="about">
|
|
869
|
-
<main exportgroup="main.html">Welcome to our About Page</main>
|
|
870
|
-
</template>
|
|
871
|
-
<template name="products">
|
|
872
|
-
<main exportgroup="main.html">Welcome to our Products Page</main>
|
|
873
|
-
</template>
|
|
874
|
-
<main exportgroup="main.html">Welcome to our Home Page</main>
|
|
875
|
-
```
|
|
876
|
-
|
|
877
|
-
Now, the `<main>` elements are each imported on navigating to their respective routes. This time, Webflo takes care of setting the URL path as a global `template` attribute on the `<body>` element such that `<import>` elements that inherit this global attribute are resolved from its current value.
|
|
878
|
-
|
|
879
|
-
```html
|
|
880
|
-
<!--
|
|
881
|
-
public
|
|
882
|
-
├── index.html
|
|
883
|
-
-->
|
|
884
|
-
<!DOCTYPE html>
|
|
885
|
-
<html>
|
|
886
|
-
<head>
|
|
887
|
-
<script type="module" src="/bundle.js"></script>
|
|
888
|
-
<template name="routes" src="/bundle.html"></template>
|
|
889
|
-
</head>
|
|
890
|
-
<body template="routes/"> <!-- This "template" attribute automatically changes to routes/about or routes/products as we navigate to http://localhost:3000/about and http://localhost:3000/products respectively -->
|
|
891
|
-
<header></header>
|
|
892
|
-
<import name="main.html"></import> <!-- This import element omits its "template" attribute so as to inherit the global one -->
|
|
893
|
-
<footer></footer>
|
|
894
|
-
</body>
|
|
895
|
-
</html>
|
|
896
|
-
```
|
|
897
|
-
|
|
898
|
-
<details>
|
|
899
|
-
<summary>How it works...</summary>
|
|
900
|
-
|
|
901
|
-
> In this architecture, navigation is instant and sleek - Webflo prevents a full page reload, obtains and sets data at `document.state.data` for the new URL, then sets the `template` attribute on the `<body>` element to the new URL path. The `bundle.js` script comes with the appropriate OOHTML support level required for the imports to function.
|
|
902
|
-
</details>
|
|
903
|
-
|
|
904
|
-
#### In a Multi SPA Layout
|
|
905
|
-
|
|
906
|
-
It's all a *layout* thing, so a hybrid of the two architectures above is possible in one application, to take advantage of the unique benefits of each! Here, you are able to have routes that are standalone `index.html` documents (MPA), which in turn, are able to act as a single document root for their subroutes (SPA).
|
|
907
|
-
|
|
908
|
-
```html
|
|
909
|
-
my-app
|
|
910
|
-
└── public
|
|
911
|
-
├── about/index.html ------------------------- <!DOCTYPE html> <!-- Document root 1 -->
|
|
912
|
-
├── products
|
|
913
|
-
│ ├── free/main.html --------------------------- <main></main> <!-- To appear at main area of document root 2 -->
|
|
914
|
-
│ ├── paid/main.html --------------------------- <main></main> <!-- To appear at main area of document root 2 -->
|
|
915
|
-
│ ├── main.html -------------------------------- <main></main> <!-- To appear at main area of document root 2 -->
|
|
916
|
-
│ └── index.html ------------------------------- <!DOCTYPE html> <!-- Document root 2, (doubles as an SPA) -->
|
|
917
|
-
├── index.html ------------------------------- <!DOCTYPE html> <!-- Document root 0 -->
|
|
918
|
-
├── header.html ------------------------------ <header></header> <!-- To appear at top of each document root -->
|
|
919
|
-
└── footer.html ------------------------------ <footer></footer> <!-- To appear at bottom of each document root -->
|
|
920
|
-
```
|
|
921
|
-
|
|
922
|
-
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.
|
|
923
|
-
|
|
924
|
-
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.
|
|
925
|
-
|
|
926
|
-
```html
|
|
927
|
-
<!--
|
|
928
|
-
public
|
|
929
|
-
├── products/index.html
|
|
930
|
-
-->
|
|
931
|
-
<!DOCTYPE html>
|
|
932
|
-
<html>
|
|
933
|
-
<head>
|
|
934
|
-
<script type="module" src="/webflo.bundle.js"></script>
|
|
935
|
-
<script type="module" src="/products/bundle.js"></script>
|
|
936
|
-
<template name="pages" src="/bundle.html"></template>
|
|
937
|
-
</head>
|
|
938
|
-
<body>...</body>
|
|
939
|
-
</html>
|
|
940
|
-
```
|
|
941
|
-
|
|
942
|
-
```html
|
|
943
|
-
<!--
|
|
944
|
-
public
|
|
945
|
-
├── about/index.html
|
|
946
|
-
-->
|
|
947
|
-
<!DOCTYPE html>
|
|
948
|
-
<html>
|
|
949
|
-
<head>
|
|
950
|
-
<script type="module" src="/webflo.bundle.js"></script>
|
|
951
|
-
<script type="module" src="/about/bundle.js"></script>
|
|
952
|
-
<template name="pages" src="/bundle.html"></template>
|
|
953
|
-
</head>
|
|
954
|
-
<body>...</body>
|
|
955
|
-
</html>
|
|
956
|
-
```
|
|
957
|
-
|
|
958
|
-
```html
|
|
959
|
-
<!--
|
|
960
|
-
public
|
|
961
|
-
├── index.html
|
|
962
|
-
-->
|
|
963
|
-
<!DOCTYPE html>
|
|
964
|
-
<html>
|
|
965
|
-
<head>
|
|
966
|
-
<script type="module" src="/webflo.bundle.js"></script>
|
|
967
|
-
<script type="module" src="/bundle.js"></script>
|
|
968
|
-
<template name="pages" src="/bundle.html"></template>
|
|
969
|
-
</head>
|
|
970
|
-
<body>...</body>
|
|
971
|
-
</html>
|
|
972
|
-
```
|
|
973
|
-
|
|
974
|
-
<details>
|
|
975
|
-
<summary>How it works...</summary>
|
|
976
|
-
|
|
977
|
-
> The Webflo `generate` command automatically figures out a given architecture and generates the appropriate scripts for the application! It also factors into the generated scripts the location of each document root so that [all navigations to these roots are handled as a regular page load](#spa-navigation).
|
|
978
|
-
</details>
|
|
979
|
-
|
|
980
|
-
#### Bundling
|
|
981
|
-
|
|
982
|
-
Template `.html` files are bundled from the filesystem into a single file using the [OOHTML CLI](#oohtml-cli) utility. On installing this utility, you may want to add the following to your npm scripts in `package.json`.
|
|
983
|
-
|
|
984
|
-
```json
|
|
985
|
-
"scripts": {
|
|
986
|
-
"generate:templates": "oohtml bundle --recursive --auto-embed=routes"
|
|
987
|
-
}
|
|
988
|
-
```
|
|
989
|
-
|
|
990
|
-
The `--recursive` flag gets the bundler to recursively bundle *subroots* in a [Multi SPA](#in-a-multi-spa-layout) layout - where certain subdirectories have their own `index.html` document. (These subroots would be ignored otherwise.)
|
|
991
|
-
|
|
992
|
-
The `--auto-embed` flag gets the bundler to automatically embed the generated `bundle.html` file on the matched `index.html` document. A value of `routes` for the flag ends up as the name of the *embed* template: `<template name="routes" src="/bundle.html"></template>`.
|
|
993
|
-
|
|
994
|
-
> **Note**
|
|
995
|
-
> <br>If your HTML files are actually based off the `public` directory, you'll need to tell the above command to run in the `public` directory, either by [configuring the bundler](https://github.com/webqit/oohtml-cli#other-options), or by rewriting the command with a prefix: `cd public && oohtml bundle --recursive --auto-embed=routes`.
|
|
996
|
-
|
|
997
|
-
### Client and Server-Side Rendering
|
|
998
|
-
|
|
999
|
-
With pages in Webflo being [DOM-based](#overview) (both client-side and [server-side](#oohtml-ssr)), we are able to access and manipulate documents and elements using familiar DOM APIs - e.g. to replace or insert contents, attributes, etc. Rendering in Webflo is based on this concept!
|
|
1000
|
-
|
|
1001
|
-
Here, Webflo simply makes sure that the data obtained from each route is available as part of the `document` object as [`document.state.data`](#the-documentstatedata-object), making it accessible to our rendering logic.
|
|
1002
|
-
|
|
1003
|
-
We are able embed a script on our page and render this data on the relevant parts of the document.
|
|
1004
|
-
|
|
1005
|
-
```html
|
|
1006
|
-
<!--
|
|
1007
|
-
public
|
|
1008
|
-
├── index.html
|
|
1009
|
-
-->
|
|
1010
|
-
<!DOCTYPE html>
|
|
1011
|
-
<html>
|
|
1012
|
-
<head>
|
|
1013
|
-
<title></title>
|
|
1014
|
-
<script>
|
|
1015
|
-
setTimeout(() => {
|
|
1016
|
-
console.log( document.state.data ); // { title: 'Home | FluffyPets' }
|
|
1017
|
-
let { title } = document.state.data;
|
|
1018
|
-
document.title = title;
|
|
1019
|
-
}, 0);
|
|
1020
|
-
</script>
|
|
1021
|
-
</head>
|
|
1022
|
-
<body></body>
|
|
1023
|
-
</html>
|
|
1024
|
-
```
|
|
1025
|
-
|
|
1026
|
-
Where your rendering logic is an external script, your `<script>` element would need to have an `ssr` Boolean attribute to get the rendering engine to fetch and run your script on the server.
|
|
1027
|
-
|
|
1028
|
-
```html
|
|
1029
|
-
<!--
|
|
1030
|
-
public
|
|
1031
|
-
├── index.html
|
|
1032
|
-
-->
|
|
1033
|
-
<!DOCTYPE html>
|
|
1034
|
-
<html>
|
|
1035
|
-
<head>
|
|
1036
|
-
<title></title>
|
|
1037
|
-
<script src="app.js" ssr></script>
|
|
1038
|
-
</head>
|
|
1039
|
-
<body></body>
|
|
1040
|
-
</html>
|
|
1041
|
-
```
|
|
1042
|
-
|
|
1043
|
-
From here, even the most-rudimentary form of rendering (using vanilla HTML and native DOM methods) becomes possible, and this is a good thing: you get away with less tooling until you absolutely need to add up on tooling!
|
|
1044
|
-
|
|
1045
|
-
However, since the `document` objects in Webflo natively support [OOHTML](#oohtml) - unless disabled in config, we are able to write reactive UI logic! Here, OOHTML makes it possible to embed reactive `<script>` elements (called [Subscript](https://github.com/webqit/oohtml#subscript)) right within HTML elements - where each expression automatically self-updates whenever references to data, or its properties, get an update!
|
|
1046
|
-
|
|
1047
|
-
```html
|
|
1048
|
-
<!--
|
|
1049
|
-
public
|
|
1050
|
-
├── index.html
|
|
1051
|
-
-->
|
|
1052
|
-
<!DOCTYPE html>
|
|
1053
|
-
<html>
|
|
1054
|
-
<head>
|
|
1055
|
-
<title></title>
|
|
1056
|
-
</head>
|
|
1057
|
-
<body>
|
|
1058
|
-
<h1></h1>
|
|
1059
|
-
<script type="subscript">
|
|
1060
|
-
let { title } = document.state.data;
|
|
1061
|
-
document.title = title;
|
|
1062
|
-
let h1Element = this.querySelector('h1');
|
|
1063
|
-
h1Element.innerHTML = title;
|
|
1064
|
-
</script>
|
|
1065
|
-
</body>
|
|
1066
|
-
</html>
|
|
1067
|
-
```
|
|
1068
|
-
|
|
1069
|
-
<details>
|
|
1070
|
-
<summary>Re-introducing UI logic in the actual language for logic - JavaScript...</summary>
|
|
1071
|
-
|
|
1072
|
-
> So, this is simple to think about: HTML already just let's us embed `<script>` elements for UI logic, and so be it! What OOHTML does further is simply to extend the plain old `<script>` element with the `subscript` type which gets any JavaScript code to be *reactive*! Compared with other syntax alternatives, this uniquely enables us to do all things logic in the actual language for logic - JavaScript.
|
|
1073
|
-
</details>
|
|
1074
|
-
|
|
1075
|
-
Note that because these scripts are naturally reactive, we do not require any `setTimeout()` construct like we required earlier in the case of the classic `<script>` element. These expressions self-update as the values they depend on become available, removed, or updated - i.e. as `document.state` gets updated.
|
|
1076
|
-
|
|
1077
|
-
From here, we are also able to write more succinct code! Using the [Namespaced HTML](https://github.com/webqit/oohtml#namespaced-html) feature in OOHTML, we could do without those `querySelector()` calls up there. Also, we could go on to use any DOM manipulation library of our choice; e.g jQuery, or even better, the jQuery-like [Play UI](https://github.com/webqit/play-ui) library.
|
|
1078
|
-
|
|
1079
|
-
```html
|
|
1080
|
-
<!--
|
|
1081
|
-
public
|
|
1082
|
-
├── index.html
|
|
1083
|
-
-->
|
|
1084
|
-
<!DOCTYPE html>
|
|
1085
|
-
<html>
|
|
1086
|
-
<head>
|
|
1087
|
-
<title></title>
|
|
1088
|
-
<script src="/jquery.js"></script>
|
|
1089
|
-
</head>
|
|
1090
|
-
<body namespace>
|
|
1091
|
-
<h1 id="headline1"></h1>
|
|
1092
|
-
<script type="subscript">
|
|
1093
|
-
let { title } = document.state.data;
|
|
1094
|
-
document.title = title;
|
|
1095
|
-
let { headline1, headline2 } = this.namespace;
|
|
1096
|
-
$(headline1).html(title);
|
|
1097
|
-
if (headline2) {
|
|
1098
|
-
$(headline2).html(title);
|
|
1099
|
-
}
|
|
1100
|
-
</script>
|
|
1101
|
-
</body>
|
|
1102
|
-
</html>
|
|
1103
|
-
```
|
|
1104
|
-
|
|
1105
|
-
Above, we've also referenced some currently non-existent element `headline2` - ahead of when it becomes added in the DOM! This should give a glimpse of the powerful reactivity we get with having OOHTML around on our document!
|
|
1106
|
-
|
|
1107
|
-
```js
|
|
1108
|
-
setTimeout(() => {
|
|
1109
|
-
let headline2 = document.createElement('h2');
|
|
1110
|
-
headline2.id = 'headline2';
|
|
1111
|
-
document.body.append(headline2);
|
|
1112
|
-
}, 1000);
|
|
1113
|
-
```
|
|
1114
|
-
|
|
1115
|
-
Taking things further, it is possible to write class-based components that abstract away all logic! You can find a friend in [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)! Plus, your Custom Elements can function reactively using [SubscriptElement](https://github.com/webqit/oohtml#subscript) as base class!
|
|
1116
|
-
|
|
1117
|
-
#### Custom Render Functions
|
|
1118
|
-
|
|
1119
|
-
Custom `render` functions can be defined on a route (`export function render() {}`) to entirely handle, or extend, rendering.
|
|
1120
|
-
|
|
1121
|
-
```js
|
|
1122
|
-
/**
|
|
1123
|
-
server
|
|
1124
|
-
├── index.js
|
|
1125
|
-
*/
|
|
1126
|
-
export default async function(event, context, next) {
|
|
1127
|
-
return { title: 'Home | FluffyPets' };
|
|
1128
|
-
}
|
|
1129
|
-
export async function render(event, data, next) {
|
|
1130
|
-
return `
|
|
1131
|
-
<!DOCTYPE html>
|
|
1132
|
-
<html>
|
|
1133
|
-
<head><title>FluffyPets</title></head>
|
|
1134
|
-
<body>
|
|
1135
|
-
<h1>${ data.title }</h1>
|
|
1136
|
-
</body>
|
|
1137
|
-
</html>
|
|
1138
|
-
`;
|
|
1139
|
-
}
|
|
1140
|
-
```
|
|
1141
|
-
|
|
1142
|
-
<details>
|
|
1143
|
-
<summary>And, custom <code>render</code> functions can be step functions too, nested as necessary to form a <i>render</i> workflow.</summary>
|
|
1144
|
-
|
|
1145
|
-
```js
|
|
1146
|
-
/**
|
|
1147
|
-
server
|
|
1148
|
-
├── index.js
|
|
1149
|
-
*/
|
|
1150
|
-
export async function render(event, data, next) {
|
|
1151
|
-
// For render callbacks at child step
|
|
1152
|
-
if (next.stepname) {
|
|
1153
|
-
return next();
|
|
1154
|
-
}
|
|
1155
|
-
return `
|
|
1156
|
-
<!DOCTYPE html>
|
|
1157
|
-
<html>
|
|
1158
|
-
<head><title>FluffyPets</title></head>
|
|
1159
|
-
<body>
|
|
1160
|
-
<h1>${ data.title }</h1>
|
|
1161
|
-
</body>
|
|
1162
|
-
</html>
|
|
1163
|
-
`;
|
|
1164
|
-
}
|
|
1165
|
-
```
|
|
1166
|
-
|
|
1167
|
-
> **Note**
|
|
1168
|
-
> <br>Typically, though, child steps do not always need to have an equivalent`render` callback being that they automatically inherit rendering from their parent or ancestor.
|
|
1169
|
-
</details>
|
|
1170
|
-
|
|
1171
|
-
But, custom render functions do not always need to do as much as entirely handle rendering. It is possible to get them to trigger Webflo's native rendering and simply modify the documents being rendered. Here, you would simply call the `next()` function to advance the *render workflow* into Webflo's default rendering. A `window` instance is returned containing the document being rendered.
|
|
1172
|
-
|
|
1173
|
-
```js
|
|
1174
|
-
/**
|
|
1175
|
-
server
|
|
1176
|
-
├── index.js
|
|
1177
|
-
*/
|
|
1178
|
-
export default async function(event, context, next) {
|
|
1179
|
-
return { title: 'Home | FluffyPets' };
|
|
1180
|
-
}
|
|
1181
|
-
export async function render(event, data, next) {
|
|
1182
|
-
let window = await next( data );
|
|
1183
|
-
let { document } = window;
|
|
1184
|
-
console.log( document.state.data ); // { title: 'Home | FluffyPets' }
|
|
1185
|
-
return window;
|
|
1186
|
-
}
|
|
1187
|
-
```
|
|
1188
|
-
|
|
1189
|
-
Custom render functions must return a value, and `window` objects are accepted. (Actually, any object that has a `toString()` method can be returned.)
|
|
1190
|
-
|
|
1191
|
-
#### The Idea of State
|
|
1192
|
-
|
|
1193
|
-
There often needs to be a central point in an application where things are stored and managed. You could think of it as having a global object initialized `window.store = {}` on which different parts of an application can store and retrieve values. This is the basic idea of state. But it also doesn't go without the idea of *observability* - something that lets the different parts of the application observe and respond to changes made on this object!
|
|
1194
|
-
|
|
1195
|
-
*State* and *Observability* in Webflo applications come down to the same basic form:
|
|
1196
|
-
|
|
1197
|
-
first, an object...
|
|
1198
|
-
|
|
1199
|
-
```js
|
|
1200
|
-
document.state = {};
|
|
1201
|
-
// and for elements: element.state = {};
|
|
1202
|
-
```
|
|
1203
|
-
|
|
1204
|
-
...and then, a way to observe property changes on it...
|
|
1205
|
-
|
|
1206
|
-
```js
|
|
1207
|
-
Observer.observe(document.state, changes => {
|
|
1208
|
-
changes.forEach(change => {
|
|
1209
|
-
console.log(change.name, change.value);
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
```
|
|
1213
|
-
|
|
1214
|
-
```js
|
|
1215
|
-
Observer.observe(document.state, propertyName, change => {
|
|
1216
|
-
console.log(change.name, change.value);
|
|
1217
|
-
});
|
|
1218
|
-
```
|
|
1219
|
-
|
|
1220
|
-
...and with incredible syntax benefits - where all references to the object and its properties from within embedded Subscript code are reactive.
|
|
1221
|
-
|
|
1222
|
-
```html
|
|
1223
|
-
<script type="subscript">
|
|
1224
|
-
// Always log the value of this property in realtime
|
|
1225
|
-
console.log(document.state.propertyName);
|
|
1226
|
-
</script>
|
|
1227
|
-
```
|
|
1228
|
-
|
|
1229
|
-
Look, this covers it all: state management and reactive UIs, with none of a state machine!
|
|
1230
|
-
|
|
1231
|
-
Interestingly, this idea of "state" is all of OOHTML's: the [State API](https://github.com/webqit/oohtml#state-api) that's natively available in OOHTML-based documents - both client-side and server-side! Webflo simply just leverages it!
|
|
1232
|
-
|
|
1233
|
-
This API exposes an application-wide `document.state` object and a per-element `element.state` object. And these are *live* read/write objects that can be observed for property changes using the [Observer API](#the-observer-api). It comes off as the simplest approach to state and reactivity!
|
|
1234
|
-
|
|
1235
|
-
> **Note**
|
|
1236
|
-
> <br>The State API is available as long as the [OOHTML support level](#oohtml) in config is left as `full`, or set to `scripting`.
|
|
1237
|
-
|
|
1238
|
-
#### The `document.state.data` Object
|
|
1239
|
-
|
|
1240
|
-
This property reperesents the application data at any point in time - obtained from route handers on each navigation. Webflo simply updates this property and lets the page's [rendering logic](#client-and-server-side-rendering), or other parts of the application, take over.
|
|
1241
|
-
|
|
1242
|
-
```js
|
|
1243
|
-
console.log(document.state.data) // { title: 'Home | FluffyPets' }
|
|
1244
|
-
```
|
|
1245
|
-
|
|
1246
|
-
<details>
|
|
1247
|
-
<summary>More examples...</summary>
|
|
1248
|
-
|
|
1249
|
-
```js
|
|
1250
|
-
Observer.observe(document.state, 'data', e => {
|
|
1251
|
-
console.log('Current page data is: ', e.value);
|
|
1252
|
-
});
|
|
1253
|
-
```
|
|
1254
|
-
|
|
1255
|
-
```html
|
|
1256
|
-
<script type="subscript">
|
|
1257
|
-
let { data: { title } } = document.state;
|
|
1258
|
-
document.title = title;
|
|
1259
|
-
</script>
|
|
1260
|
-
```
|
|
1261
|
-
</details>
|
|
1262
|
-
|
|
1263
|
-
#### The `document.state.url` Object
|
|
1264
|
-
|
|
1265
|
-
This is a *live* object that reperesents the properties of the application URL at any point in time. The object exposes the same URL properties as of a standard [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) object, but, here, as *live* properties that can be observed as navigation happens, and modified to initiate navigation - all using the [Observer API](#the-observer-api).
|
|
1266
|
-
|
|
1267
|
-
```js
|
|
1268
|
-
let { url } = document.state;
|
|
1269
|
-
console.log(url) // { hash, host, hostname, href, origin, password, pathname, port, protocol, search, searchParams, username }
|
|
1270
|
-
```
|
|
1271
|
-
|
|
1272
|
-
<details>
|
|
1273
|
-
<summary>More examples...</summary>
|
|
1274
|
-
|
|
1275
|
-
```js
|
|
1276
|
-
Observer.observe(url, 'hash', e => {
|
|
1277
|
-
console.log(url.hash === e.value); // true
|
|
1278
|
-
});
|
|
1279
|
-
```
|
|
1280
|
-
|
|
1281
|
-
```js
|
|
1282
|
-
// Navigates to "/login#form" as if a link was clicked
|
|
1283
|
-
document.addEventListener('synthetic-navigation', e => {
|
|
1284
|
-
Observer.set(url, 'href', '/login#form');
|
|
1285
|
-
});
|
|
1286
|
-
|
|
1287
|
-
// Or...
|
|
1288
|
-
document.addEventListener('synthetic-navigation', e => {
|
|
1289
|
-
Observer.set(url, { pathname: '/login', hash: '#form' });
|
|
1290
|
-
});
|
|
1291
|
-
|
|
1292
|
-
console.log(url.hash); // #form
|
|
1293
|
-
```
|
|
1294
|
-
|
|
1295
|
-
There is also the *convenience* `query` property that offers the URL parameters as a *live* object.
|
|
1296
|
-
|
|
1297
|
-
```js
|
|
1298
|
-
// For URL: http://localhost:3000/login?as=student
|
|
1299
|
-
console.log(url.query.as) // student
|
|
1300
|
-
|
|
1301
|
-
// Re-rewrite the URL and initiate navigation by simply modifying a query parameter
|
|
1302
|
-
document.addEventListener('synthetic-navigation', e => {
|
|
1303
|
-
Observer.set(url.query, 'as', 'business');
|
|
1304
|
-
});
|
|
1305
|
-
```
|
|
1306
|
-
|
|
1307
|
-
```html
|
|
1308
|
-
<script type="subscript">
|
|
1309
|
-
let { query: { as: role } } = url;
|
|
1310
|
-
document.title = 'Login as ' + role;
|
|
1311
|
-
</script>
|
|
1312
|
-
```
|
|
1313
|
-
</details>
|
|
1314
|
-
|
|
1315
|
-
### Requests and Responses
|
|
1316
|
-
|
|
1317
|
-
On each request, the event object passed to route handlers exposes the incoming request as `event.request`. This is an instance of `event.Request` - an extension of the [WHATWG Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) class. The event object also exposes `event.Response` - an extension of the [WHATWG Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) class, for returning instance-based responses. You enjoy routing that is based on standard interfaces!
|
|
1318
|
-
|
|
1319
|
-
Routes in Webflo can be designed for different types of request/response scenarios. Here are some important ones:
|
|
1320
|
-
|
|
1321
|
-
#### Scenario 1: Static File Requests and Responses
|
|
1322
|
-
|
|
1323
|
-
Static file requests like `http://localhost:3000/logo.png` are automatically responded to by Webflo when `next()`ed forward by route handlers, or where there are no route handlers.
|
|
1324
|
-
+ On the server, Webflo serves files from the `public` directory. File contents along with the appropriate headers like [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type), [`Content-Length`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length), etc. are returned as an instance of `event.Response`. Where a request has an [`Accept-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) header set (e.g. `gzip`, `br`) and there exists a matching *compressed version* of the said file on the file system (e.g. `./public/logo.png.gz`, `./public/logo.png.br`), the compressed version is served and the appropriate [`Content-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) response header is set.
|
|
1325
|
-
|
|
1326
|
-
#### Scenario 2: API Requests and Responses
|
|
1327
|
-
|
|
1328
|
-
JSON (API) requests - requests that expect to get a JSON response (i.e. [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type): `application/json`) - are automatically satisfied by Webflo with a valid JSON response. Here, Webflo simply jsonfies workflow return values - which are usually plain objects, or other jsonfyable types - `string`, `number`, `boolean`, `array`.
|
|
1329
|
-
+ These requests need not have an [`Accept`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) header; but if they should, it must be the value of `application/json`.
|
|
1330
|
-
+ Routes intended to be accessed this way are expected to return a jsonfyable value (or an instance of `event.Response` containing same) from the workflow.
|
|
1331
|
-
+ Workflow responses that are an instance of `event.Response` with a `Content-Type` header already set are sent as-is.
|
|
1332
|
-
|
|
1333
|
-
#### Scenario 3: Page Requests and Responses
|
|
1334
|
-
|
|
1335
|
-
HTML page requests - requests that expect to get an HTML response (i.e. [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type): `text/html`) - are automatically satisfied by Webflo with a valid HTML response. Workflow return values that are objects are automatically used for [Server-Side Rendering](#client-and-server-side-rendering).
|
|
1336
|
-
+ These requests need to have an [`Accept`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) header of `text/html`, or something that resolves to `text/html` - e.g. `text/*`, `*/html`, `*/*`.
|
|
1337
|
-
+ Routes intended to be accessed this way are expected to return a plain object (or an instance of `event.Response` containing same) from the workflow in order to be renderable.
|
|
1338
|
-
+ Workflow responses that are an instance of `event.Response` with a `Content-Type` header already set are sent as-is, and not rendered.
|
|
1339
|
-
|
|
1340
|
-
#### Scenario 4: Single Page Navigation Requests and Responses
|
|
1341
|
-
|
|
1342
|
-
In a Single Page Application layout, every navigation event (page-to-page navigation, history back and forward navigation, and form submissions) is expected to initiate a request/response flow without a full page reload, since the destination URLs are often based off the already loaded document. The Webflo client JS intercepts these navigation events and generates the equivalent request object with an `Accept` header of `application/json`, so that data can be obtained as a JSON object ([scenerio 2 above](#scenario-2-api-requests-and-responses)) for [Client-Side Rendering](#client-and-server-side-rendering).
|
|
1343
|
-
|
|
1344
|
-
The generated request also [hints the server](#custom-redirect-responses) on how to return cross-SPA redirects (redirects that will point to another origin, or to another SPA root (in a [Multi SPA](#in-a-multi-spa-layout) layout)) so that it can be handled manually by the client. The following headers are set: `X-Redirect-Policy: manual-when-cross-spa`, `X-Redirect-Code: 200`.
|
|
1345
|
-
+ Same-SPA redirects are sent as-is, and the Webflo client JS receives and renders the final data and updates the address bar with the final URL.
|
|
1346
|
-
+ Cross-SPA/cross-origin redirects are communicated back, as hinted, and the destination URL is opened as a fresh page load.
|
|
1347
|
-
|
|
1348
|
-
#### Scenario 5: Range Requests and Responses
|
|
1349
|
-
|
|
1350
|
-
In all cases, where a request specifies a [`Range`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range) header, Webflo automatically slices the response body to satisfy the range, and the appropriate [`Content-Range`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) response header is set.
|
|
1351
|
-
+ Workflow responses that are an instance of `event.Response` with a `Content-Range` header already set are sent as-is.
|
|
1352
|
-
|
|
1353
|
-
#### Other Requests and Responses
|
|
1354
|
-
|
|
1355
|
-
Workflows may return any other data type, e.g. an instance of the native [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData), [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob), [File](https://developer.mozilla.org/en-US/docs/Web/API/File), or [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream), etc., or an instance of `event.Response` containing same - usually on routes that do not double as a page route. Webflo tries to send these along with the appropriate response headers.
|
|
1356
|
-
|
|
1357
|
-
> **Note**
|
|
1358
|
-
> <br>The fact that all requests, even static file requests, are seen by route handlers, where defined, means that they get a chance to dynamically generate the responses that the client sees!
|
|
1359
|
-
|
|
1360
|
-
#### Custom Redirect Responses
|
|
1361
|
-
|
|
1362
|
-
It is possible to hint the server on how to serve redirect responses. The idea is to substitute the standard `302`, `301` response code for these redirects with a non-rediret status code so that it can be recieved as a normal response and handled manually. The following pair of headers make this possible: `X-Redirect-Code`, `X-Redirect-Policy`.
|
|
1363
|
-
+ The `X-Redirect-Code` can be any valid HTTP status code (often preferably, in the 2xx). This is the response code that you want Webflo to substitute the actual redirect code with.
|
|
1364
|
-
+ The `X-Redirect-Policy` header can be any of:
|
|
1365
|
-
+ `manual` - which means "treat all redirects as manual"
|
|
1366
|
-
+ `manual-if-cross-origin` - which means "treat cross-origin redirects as manual"
|
|
1367
|
-
+ `manual-if-cross-spa` - which means "treat cross-SPA redirects (including cross-origin redirects) as manual"
|
|
1368
|
-
|
|
1369
|
-
In each case, the substituted, original redirect code is returned back in the response in a special `X-Redirect-Code` response header, alongside the standard `Location` header.
|
|
1370
|
-
|
|
1371
|
-
#### Failure Responses
|
|
1372
|
-
|
|
1373
|
-
Where workflows return `undefined`, a `Not Found` status is implied.
|
|
1374
|
-
+ On the server side, a `404` HTTP response is returned.
|
|
1375
|
-
+ On the client-side, the initiating document in the browser has its `document.state.data` emptied. The error is also exposed on the [`document.state.network.error`](#the-documentstatenetwork-object) property.
|
|
1376
|
-
|
|
1377
|
-
Where workflows throw an exception, an *error* status is implied.
|
|
1378
|
-
+ On the server side, the error is logged and a `500` HTTP response is returned.
|
|
1379
|
-
+ On the client-side, the initiating document in the browser has its `document.state.data` emptied. The error is also exposed on the [`document.state.network.error`](#the-documentstatenetwork-object) property.
|
|
1380
|
-
|
|
1381
|
-
#### Cookie Responses
|
|
1382
|
-
|
|
1383
|
-
Handlers can set [response cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) via the standard `Response` constructor, or using the standard `Headers.set()` method.
|
|
1384
|
-
|
|
1385
|
-
<details>
|
|
1386
|
-
<summary>Examples...</summary>
|
|
1387
|
-
|
|
1388
|
-
```js
|
|
1389
|
-
let response = event.Response(data, { headers: { 'Set-Cookie': cookieString }});
|
|
1390
|
-
|
|
1391
|
-
response.headers.set('Set-Cookie', cookieString);
|
|
1392
|
-
```
|
|
1393
|
-
|
|
1394
|
-
Webflo also offers a *convenience* method.
|
|
1395
|
-
|
|
1396
|
-
```js
|
|
1397
|
-
let response = event.Response(data, { headers: { cookies: cookieString }});
|
|
1398
|
-
|
|
1399
|
-
response.headers.cookies = { 'Cookie-1': cookieString, 'Cookie-2': cookie2String };
|
|
1400
|
-
```
|
|
1401
|
-
|
|
1402
|
-
```js
|
|
1403
|
-
let cookieObject = { value: 'cookie-val', expires, maxAge, domain, path, secure, HttpOnly, sameSite };
|
|
1404
|
-
let cookie2Object = { value: 'cookie2-val' };
|
|
1405
|
-
response.headers.cookies = { 'Cookie-1': cookieObject };
|
|
1406
|
-
response.headers.cookies = { 'Cookie-2': cookie2Object };
|
|
1407
|
-
|
|
1408
|
-
console.log(response.headers.cookies); // { 'Cookie-1': cookieObject, 'Cookie-2': cookie2Object };
|
|
1409
|
-
```
|
|
1410
|
-
|
|
1411
|
-
Set cookies are [accessed](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie) on the next request via request headers.
|
|
1412
|
-
|
|
1413
|
-
```js
|
|
1414
|
-
console.log(event.request.headers.get('Cookie')); // Cookie-1=cookie-val&Cookie-2=cookie2-val;
|
|
1415
|
-
```
|
|
1416
|
-
|
|
1417
|
-
Webflo also offers a *convenience* method.
|
|
1418
|
-
|
|
1419
|
-
```js
|
|
1420
|
-
console.log(event.request.headers.cookies); // { 'Cookie-1': 'cookie-val', 'Cookie-2': 'cookie2-val' };
|
|
1421
|
-
```
|
|
1422
|
-
</details>
|
|
1423
|
-
|
|
1424
|
-
### Webflo Applications
|
|
1425
|
-
|
|
1426
|
-
Webflo comes ready for any type of application!
|
|
1427
|
-
|
|
1428
|
-
+ [Client-Side Applications](#client-side-applications)
|
|
1429
|
-
+ [Progressive Web Apps](#progressive-web-apps)
|
|
1430
|
-
+ [API Backends](#api-backends)
|
|
1431
|
-
+ [Static Sites](#static-sites)
|
|
1432
|
-
|
|
1433
|
-
*And you can go hybrid!*
|
|
1434
|
-
|
|
1435
|
-
#### Client-Side Applications
|
|
1436
|
-
|
|
1437
|
-
Web pages that embed the Webflo client JS deliver a great user experience. It's simple: the `npm run generate` command does both the building and embedding of the script (or scripts), for the document root (or document roots - in a [Multi Page](#in-a-multi-page-layout) / [Multi SPA](#in-a-multi-spa-layout) layout)!
|
|
1438
|
-
|
|
1439
|
-
On being loaded, the state of the application is initialized, or is restored through hydration - where [Server-Side Rendering](#client-and-server-side-rendering) was involved to optimize for first paint, and an app-like experience kicks in! For [Single-Page Applications](#in-a-single-page-layout), [Client-Side Rendering](#client-and-server-side-rendering) is performed on each navigation.
|
|
1440
|
-
|
|
1441
|
-
##### SPA Navigation
|
|
1442
|
-
|
|
1443
|
-
Unless disabled in config, it is factored-in at build time for the application client JS to be able to automatially figure out when to intercept a navigation event and prevent a full page reload, and when not to.
|
|
1444
|
-
|
|
1445
|
-
<details>
|
|
1446
|
-
<summary>How it works...</summary>
|
|
1447
|
-
|
|
1448
|
-
SPA Navigation follows the following rules:
|
|
1449
|
-
|
|
1450
|
-
+ When it ascertains that the destination URL is based on the current running `index.html` document in the browser (an SPA architecture), a full page reload is prevented for *soft* navigation. But where the destination URL points out of the current document root (a [Multi SPA](#in-a-multi-spa-layout) architecture), navigation is allowed as a normal page load, and a new page root is loaded.
|
|
1451
|
-
+ If navigation is initiated with any of the following keys pressed: Meta Key, Alt Key, Shift Key, Ctrl Key, navigation is allowed to work the default way - regardless of the first rule above.
|
|
1452
|
-
+ If navigation is initiated from a link element that has the `target` attribute, or the `download` attribute, navigation is allowed to work the default way - regardless of the first rule above.
|
|
1453
|
-
+ If navigation is initiated from a form element that has the `target` attribute, navigation is allowed to work the default way - regardless of the first rule above.
|
|
1454
|
-
</details>
|
|
1455
|
-
|
|
1456
|
-
<details>
|
|
1457
|
-
<summary>Config (Default)</summary>
|
|
1458
|
-
|
|
1459
|
-
```json
|
|
1460
|
-
{ "spa_navigation": true }
|
|
1461
|
-
```
|
|
1462
|
-
|
|
1463
|
-
> **File: `.webqit/webflo/client.json`**
|
|
1464
|
-
|
|
1465
|
-
> **Command: `webflo config client spa_navigation=TRUE`**
|
|
1466
|
-
</details>
|
|
1467
|
-
|
|
1468
|
-
##### SPA State
|
|
1469
|
-
|
|
1470
|
-
On the client side of a Webflo application, [the idea of state](#the-idea-of-state) also includes the following aspects of the client-side lifecycle that can be used to provide visual cues on the UI.
|
|
1471
|
-
|
|
1472
|
-
###### The `document.state.network` Object
|
|
1473
|
-
|
|
1474
|
-
This is a *live* object that exposes the network activity and network state of the application.
|
|
1475
|
-
|
|
1476
|
-
```js
|
|
1477
|
-
console.log(document.state.network) // { requesting, remote, error, redirecting, connectivity, }
|
|
1478
|
-
```
|
|
1479
|
-
|
|
1480
|
-
<details>
|
|
1481
|
-
<summary>Property: <code>.network.requesting: null|Object</code></summary>
|
|
1482
|
-
|
|
1483
|
-
This property tells when a request is ongoing, in which case it exposes the `params` object used to initiate the request.
|
|
1484
|
-
|
|
1485
|
-
On the UI, this could be used to hide a menu drawer that may have been open.
|
|
1486
|
-
|
|
1487
|
-
```html
|
|
1488
|
-
<menu-drawer>
|
|
1489
|
-
<script type="subscript">
|
|
1490
|
-
let { network: { requesting } } = document.state;
|
|
1491
|
-
if (requesting) {
|
|
1492
|
-
$(this).attr('open', false);
|
|
1493
|
-
}
|
|
1494
|
-
</script>
|
|
1495
|
-
</menu-drawer>
|
|
1496
|
-
```
|
|
1497
|
-
</details>
|
|
1498
|
-
|
|
1499
|
-
<details>
|
|
1500
|
-
<summary>Property: <code>.network.remote: null|String</code></summary>
|
|
1501
|
-
|
|
1502
|
-
This property tells when a remote request is ongoing - usually the same navigation requests as at `network.requesting`, but when not handled by any client-side route handlers, or when `next()`ed to this point by route handlers. The `remote` property also goes live when a route handler calls the special `fetch()` function that they recieve on their fourth parameter.
|
|
1503
|
-
|
|
1504
|
-
On the UI, this could be used to show/hide a spinner, or progress bar, to provide a visual cue.
|
|
1505
|
-
|
|
1506
|
-
```html
|
|
1507
|
-
<progress-bar>
|
|
1508
|
-
<script type="subscript">
|
|
1509
|
-
let { network: { remote } } = document.state;
|
|
1510
|
-
$(this).attr('hidden', !remote);
|
|
1511
|
-
</script>
|
|
1512
|
-
</progress-bar>
|
|
1513
|
-
```
|
|
1514
|
-
</details>
|
|
1515
|
-
|
|
1516
|
-
<details>
|
|
1517
|
-
<summary>Property: <code>.network.error: null|Error</code></summary>
|
|
1518
|
-
|
|
1519
|
-
This property tells when a request is *errored* in which case it contains an `Error` instance of the error. For requests that can be retried, the `Error` instance also has a custom `retry()` method.
|
|
1520
|
-
|
|
1521
|
-
On the UI, this could be used to show/hide cute error elements.
|
|
1522
|
-
|
|
1523
|
-
```html
|
|
1524
|
-
<nice-error>
|
|
1525
|
-
<script type="subscript">
|
|
1526
|
-
let { network: { error } } = document.state;
|
|
1527
|
-
$(this).attr('hidden', !error);
|
|
1528
|
-
</script>
|
|
1529
|
-
</nice-error>
|
|
1530
|
-
```
|
|
1531
|
-
</details>
|
|
1532
|
-
|
|
1533
|
-
<details>
|
|
1534
|
-
<summary>Property: <code>.network.redirecting: null|String</code></summary>
|
|
1535
|
-
|
|
1536
|
-
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.
|
|
1537
|
-
|
|
1538
|
-
On the UI, this could be used to mark the current page as stale and prevent further interactions.
|
|
1539
|
-
|
|
1540
|
-
```html
|
|
1541
|
-
<body>
|
|
1542
|
-
<script type="subscript">
|
|
1543
|
-
let { network: { redirecting } } = document.state;
|
|
1544
|
-
$(this).css(redirecting ? { pointerEvents: 'none', filter: 'blur(2)' } : { pointerEvents: 'auto', filter: 'blur(0)' });
|
|
1545
|
-
</script>
|
|
1546
|
-
</body>
|
|
1547
|
-
```
|
|
1548
|
-
</details>
|
|
1549
|
-
|
|
1550
|
-
<details>
|
|
1551
|
-
<summary>Property: <code>.network.connectivity: String</code></summary>
|
|
1552
|
-
|
|
1553
|
-
This property tells of [the browser's ability to connect to the network](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine): `online`, `offline`.
|
|
1554
|
-
|
|
1555
|
-
On the UI, this could be used to show/hide a connectivity status.
|
|
1556
|
-
|
|
1557
|
-
```html
|
|
1558
|
-
<body>
|
|
1559
|
-
<script type="subscript">
|
|
1560
|
-
let { network: { connectivity } } = document.state;
|
|
1561
|
-
$(this).attr( 'connectivity', connectivity });
|
|
1562
|
-
</script>
|
|
1563
|
-
</body>
|
|
1564
|
-
```
|
|
1565
|
-
</details>
|
|
1566
|
-
|
|
1567
|
-
Here are some additional examples with the [Observer API](#the-observer-api).
|
|
1568
|
-
|
|
1569
|
-
<details>
|
|
1570
|
-
<summary>Visualize the network state...</summary>
|
|
1571
|
-
|
|
1572
|
-
```js
|
|
1573
|
-
// Visualize the network state
|
|
1574
|
-
let networkVisualizer = changes => {
|
|
1575
|
-
changes.forEach(e => {
|
|
1576
|
-
console.log(e.name, ':', e.value);
|
|
1577
|
-
});
|
|
1578
|
-
};
|
|
1579
|
-
Observer.observe(document.state.network, networkVisualizer);
|
|
1580
|
-
// Or: Observer.observe(document, [ ['state', 'network'] ], networkVisualizer, { subtree: true });
|
|
1581
|
-
```
|
|
1582
|
-
</details>
|
|
1583
|
-
|
|
1584
|
-
<details>
|
|
1585
|
-
<summary>Visualize "connectivity"...</summary>
|
|
1586
|
-
|
|
1587
|
-
```js
|
|
1588
|
-
// Visualize the 'connectivity' property
|
|
1589
|
-
let connectivityVisualizer = e => {
|
|
1590
|
-
console.log('You are ', e.value);
|
|
1591
|
-
};
|
|
1592
|
-
Observer.observe(document.state.network, 'connectivity', connectivityVisualizer);
|
|
1593
|
-
// Or: Observer.observe(document.state, [ ['network', 'connectivity'] ], connectivityeVisualizer);
|
|
1594
|
-
```
|
|
1595
|
-
</details>
|
|
1596
|
-
|
|
1597
|
-
<details>
|
|
1598
|
-
<summary>Catch request errors; attempt a retry...</summary>
|
|
1599
|
-
|
|
1600
|
-
```js
|
|
1601
|
-
// Catch request errors; attempt a retry
|
|
1602
|
-
Observer.observe(document.state.network, 'error', e => {
|
|
1603
|
-
if (!e.value) return;
|
|
1604
|
-
console.error(e.value.message);
|
|
1605
|
-
if (e.value.retry) {
|
|
1606
|
-
console.error('Retrying...');
|
|
1607
|
-
e.value.retry();
|
|
1608
|
-
}
|
|
1609
|
-
});
|
|
1610
|
-
```
|
|
1611
|
-
</details>
|
|
1612
|
-
|
|
1613
|
-
##### Form Actions
|
|
1614
|
-
|
|
1615
|
-
When navigation occurs [via form submissions](#scenario-4-single-page-navigation-requests-and-responses), the form element and the submit button are made to go on the *active* state while the request is being processed. For both of these elements, the Webflo client simply sets the `element.state.active` to `true` on submission, then `false`, on completion.
|
|
1616
|
-
|
|
1617
|
-
```html
|
|
1618
|
-
<form method="post">
|
|
1619
|
-
<input name="username" placeholder="Your username..." />
|
|
1620
|
-
<script>
|
|
1621
|
-
$(this).css(this.state.active ? { pointerEvents: 'none', opacity: 'o.5' } : { pointerEvents: 'auto', opacity: '1' });
|
|
1622
|
-
</script>
|
|
1623
|
-
</form>
|
|
1624
|
-
```
|
|
1625
|
-
|
|
1626
|
-
Also, you'd remember that HTML forms can only accept two HTTP methods on their `method` attribute: `GET`, `POST`! And the same constraint exists on the equivalent `formmethod` attribue in submit buttons. You are able to overcome this in Webflo by using alternative `data-` attributes: `data-method`, `data-formmethod`, respectively.
|
|
1627
|
-
|
|
1628
|
-
```html
|
|
1629
|
-
<form data-method="patch">
|
|
1630
|
-
<input name="price" placeholder="Enter new price..." />
|
|
1631
|
-
</form>
|
|
1632
|
-
```
|
|
1633
|
-
|
|
1634
|
-
#### Progressive Web Apps
|
|
1635
|
-
|
|
1636
|
-
Webflo client-side applications are intended to provide an app-like-first experience. So unless disabled in config, a [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) is built as part of your application on running the `npm run generate` command. And as covered above, you may define [route handlers in the `/worker` directory](#handler-functions-and-layout) of your application, and these will be built into the service worker to handle Same-Origin requests of the application. Where there are no *worker* handlers, or where these forward incoming requests, requests are fetched, either from the cache, or from the network, depending on the fetching strategy built into the Service Worker.
|
|
1637
|
-
|
|
1638
|
-
<details>
|
|
1639
|
-
<summary>Config (Default)</summary>
|
|
1640
|
-
|
|
1641
|
-
```json
|
|
1642
|
-
{ "service_worker_support": true }
|
|
1643
|
-
```
|
|
1644
|
-
|
|
1645
|
-
> **File: `.webqit/webflo/client.json`**
|
|
1646
|
-
|
|
1647
|
-
> **Command: `webflo config client service_worker_support=TRUE`**
|
|
1648
|
-
</details>
|
|
1649
|
-
|
|
1650
|
-
##### Fetching Strategy
|
|
1651
|
-
|
|
1652
|
-
<details>
|
|
1653
|
-
<summary>Network First</summary>
|
|
1654
|
-
|
|
1655
|
-
This strategy tells the Service Worker to always attempt fetching from the network first for given resources, before fetching from the cache. On every successful network fetch, a copy of the response is saved to the cache for next time. (This is good for resources that need to be fresh to the user on a "best effort" basis.) Unless changed, this is Webflo's default fetching strategy. When not the default strategy, a list of specific URLs that should be fetched this way can be configured.
|
|
1656
|
-
|
|
1657
|
-
<details>
|
|
1658
|
-
<summary>Config (Default)</summary>
|
|
1659
|
-
|
|
1660
|
-
```json
|
|
1661
|
-
{ "default_fetching_strategy": "network-first" }
|
|
1662
|
-
```
|
|
1663
|
-
|
|
1664
|
-
*To list specific URLs...*
|
|
1665
|
-
|
|
1666
|
-
```json
|
|
1667
|
-
{ "network_first_urls": [ "/logo.png" ] }
|
|
1668
|
-
```
|
|
1669
|
-
|
|
1670
|
-
> **File: `.webqit/webflo/worker.json`**
|
|
1671
|
-
|
|
1672
|
-
> **Command: `webflo config worker default_fetching_strategy=network-first`**
|
|
1673
|
-
</details>
|
|
1674
|
-
</details>
|
|
1675
|
-
|
|
1676
|
-
<details>
|
|
1677
|
-
<summary>Cache First</summary>
|
|
1678
|
-
|
|
1679
|
-
This strategy tells the Service Worker to always attempt fetching from the cache first for given resources, before fetching from the network. After serving a cached response, or where not found in cache, a network fetch happens and a copy of the response is saved to the cache for next time. (This is good for resources that do not critially need to be fresh to the user.) When not the default strategy, a list of specific URLs that should be fetched this way can be configured.
|
|
1680
|
-
|
|
1681
|
-
<details>
|
|
1682
|
-
<summary>Config</summary>
|
|
1683
|
-
|
|
1684
|
-
```json
|
|
1685
|
-
{ "default_fetching_strategy": "cache-first" }
|
|
1686
|
-
```
|
|
1687
|
-
|
|
1688
|
-
*To list specific URLs...*
|
|
1689
|
-
|
|
1690
|
-
```json
|
|
1691
|
-
{ "cache_first_urls": [ "/logo.png" ] }
|
|
1692
|
-
```
|
|
1693
|
-
|
|
1694
|
-
> **File: `.webqit/webflo/worker.json`**
|
|
1695
|
-
|
|
1696
|
-
> **Command: `webflo config worker default_fetching_strategy=cache-first`**
|
|
1697
|
-
</details>
|
|
1698
|
-
</details>
|
|
1699
|
-
|
|
1700
|
-
<details>
|
|
1701
|
-
<summary>Network Only</summary>
|
|
1702
|
-
|
|
1703
|
-
This strategy tells the Service Worker to always fetch given resources from the network only. They are simply not available when offline. (This is good for resources that critially need to be fresh to the user.) When not the default strategy, a list of specific URLs that should be fetched this way can be configured.
|
|
1704
|
-
|
|
1705
|
-
<details>
|
|
1706
|
-
<summary>Config</summary>
|
|
1707
|
-
|
|
1708
|
-
```json
|
|
1709
|
-
{ "default_fetching_strategy": "network-only" }
|
|
1710
|
-
```
|
|
1711
|
-
|
|
1712
|
-
*To list specific URLs...*
|
|
1713
|
-
|
|
1714
|
-
```json
|
|
1715
|
-
{ "network_only_urls": [ "/logo.png" ] }
|
|
1716
|
-
```
|
|
1717
|
-
|
|
1718
|
-
> **File: `.webqit/webflo/worker.json`**
|
|
1719
|
-
|
|
1720
|
-
> **Command: `webflo config worker default_fetching_strategy=network-only`**
|
|
1721
|
-
</details>
|
|
1722
|
-
</details>
|
|
1723
|
-
|
|
1724
|
-
<details>
|
|
1725
|
-
<summary>Cache Only</summary>
|
|
1726
|
-
|
|
1727
|
-
This strategy tells the Service Worker to always fetch given resources from the cache only. (This is good for resources that do not change often.) When not the default strategy, a list of specific URLs that should be fetched this way can be configured. The listed resources are pre-cached ahead of when they'll be needed - and are served from the cache each time. (Pre-caching happens on the one-time `install` event of the Service Worker.)
|
|
1728
|
-
|
|
1729
|
-
<details>
|
|
1730
|
-
<summary>Config</summary>
|
|
1731
|
-
|
|
1732
|
-
```json
|
|
1733
|
-
{ "default_fetching_strategy": "cache-only" }
|
|
1734
|
-
```
|
|
1735
|
-
|
|
1736
|
-
*To list specific URLs...*
|
|
1737
|
-
|
|
1738
|
-
```json
|
|
1739
|
-
{ "cache_only_urls": [ "/logo.png" ] }
|
|
1740
|
-
```
|
|
1741
|
-
|
|
1742
|
-
> **File: `.webqit/webflo/worker.json`**
|
|
1743
|
-
|
|
1744
|
-
> **Command: `webflo config worker default_fetching_strategy=cache-only`**
|
|
1745
|
-
</details>
|
|
1746
|
-
</details>
|
|
1747
|
-
|
|
1748
|
-
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.)
|
|
1749
|
-
|
|
1750
|
-
<details>
|
|
1751
|
-
<summary>Example...</summary>
|
|
1752
|
-
|
|
1753
|
-
```json
|
|
1754
|
-
{ "cache_only_urls": [ "/icons/*.svg" ] }
|
|
1755
|
-
```
|
|
1756
|
-
</details>
|
|
1757
|
-
|
|
1758
|
-
##### Cross-Thread Communications
|
|
1759
|
-
|
|
1760
|
-
A couple APIs exists in browsers for establishing a two-way communication channel between a page and its Service Worker, for firing UI Notifications from either ends, and for implementing Push Notifications. Webflo offers to simply this with a unifying set of conventions:
|
|
1761
|
-
|
|
1762
|
-
###### The `workport` API
|
|
1763
|
-
|
|
1764
|
-
This is an object with simple methods for working with *cross-thread* messages, UI Notifications, and Push Notifications.
|
|
1765
|
-
|
|
1766
|
-
On both the client and worker side of your application, the `workport` object is accessible from route handlers as `this.runtime.workport`.
|
|
1767
|
-
|
|
1768
|
-
```js
|
|
1769
|
-
/**
|
|
1770
|
-
[client|worker]
|
|
1771
|
-
├── index.js
|
|
1772
|
-
*/
|
|
1773
|
-
export default async function(event, context, next) {
|
|
1774
|
-
let { workport } = this.runtime;
|
|
1775
|
-
workport.messaging.post({ ... });
|
|
1776
|
-
return { ... };
|
|
1777
|
-
}
|
|
1778
|
-
```
|
|
1779
|
-
|
|
1780
|
-
For cross-thread messaging, both sides of the API exposes the following methods:
|
|
1781
|
-
|
|
1782
|
-
<details>
|
|
1783
|
-
<summary>Method: <code>.messaging.post()</code></summary>
|
|
1784
|
-
|
|
1785
|
-
The `.messaging.post()` method is used for sending any arbitrary data to the other side. E.g. `workport.messaging.post({ type: 'TEST' })`.
|
|
1786
|
-
</details>
|
|
1787
|
-
|
|
1788
|
-
<details>
|
|
1789
|
-
<summary>Method: <code>.messaging.listen()</code></summary>
|
|
1790
|
-
|
|
1791
|
-
The `.messaging.listen()` method is used for registering a listener to the `message` event from the other side. E.g. `workport.messaging.listen(event => console.log(event.data.type))`. (See [`window: onmessage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/message_event), [`worker: onmessage`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/message_event).)
|
|
1792
|
-
</details>
|
|
1793
|
-
|
|
1794
|
-
<details>
|
|
1795
|
-
<summary>Method: <code>.messaging.request()</code></summary>
|
|
1796
|
-
|
|
1797
|
-
The `.messaging.request()` method is used for sending a message to the other side and obtaing a response, using the [MessageChannel](https://developer.mozilla.org/docs/Web/API/MessageChannel/MessageChannel) API.
|
|
1798
|
-
|
|
1799
|
-
```js
|
|
1800
|
-
// On the worker side
|
|
1801
|
-
workport.messaging.listen(event => {
|
|
1802
|
-
console.log(event.data);
|
|
1803
|
-
if (event.ports[0]) {
|
|
1804
|
-
event.ports[0].postMessage({ type: 'WORKS' });
|
|
1805
|
-
}
|
|
1806
|
-
});
|
|
1807
|
-
```
|
|
1808
|
-
|
|
1809
|
-
```js
|
|
1810
|
-
// On the client side
|
|
1811
|
-
let response = await workport.messaging.request({ type: 'TEST' });
|
|
1812
|
-
console.log(response); // { type: 'WORKS' }
|
|
1813
|
-
```
|
|
1814
|
-
</details>
|
|
1815
|
-
|
|
1816
|
-
<details>
|
|
1817
|
-
<summary>Method: <code>.messaging.channel()</code></summary>
|
|
1818
|
-
|
|
1819
|
-
The `.messaging.channel()` method is used for sending *broadcast* messages to the other side - including all other browsing contents that live on the same origin, using the [Broadcast Channel](https://developer.mozilla.org/docs/Web/API/Broadcast_Channel_API) API.
|
|
1820
|
-
|
|
1821
|
-
```js
|
|
1822
|
-
// On the worker side
|
|
1823
|
-
let channelId = 'channel-1';
|
|
1824
|
-
workport.messaging.channel(channelId).listen(event => {
|
|
1825
|
-
console.log(event.data);
|
|
1826
|
-
});
|
|
1827
|
-
```
|
|
1828
|
-
|
|
1829
|
-
```js
|
|
1830
|
-
// On the client side
|
|
1831
|
-
let channelId = 'channel-1';
|
|
1832
|
-
workport.messaging.channel(channelId).broadcast({ type: 'TEST' });
|
|
1833
|
-
```
|
|
1834
|
-
</details>
|
|
1835
|
-
|
|
1836
|
-
For [UI Nofitications](https://developer.mozilla.org/en-US/docs/Web/API/notification), both sides of the API exposes the following methods:
|
|
1837
|
-
|
|
1838
|
-
<details>
|
|
1839
|
-
<summary>Method: <code>.nofitications.fire()</code></summary>
|
|
1840
|
-
|
|
1841
|
-
The `.nofitications.fire()` method is used for firing up a UI notification. This uses the [`Nofitications constructor`](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification), and thus, accepts the same arguments as the constructor. But it returns a `Promise` that resolves when the notification is *clicked* or *closed*, but rejects when the notification encounters an error, or when the application isn't granted the [notification permission](https://developer.mozilla.org/en-US/docs/Web/API/Notification/requestPermission).
|
|
1842
|
-
|
|
1843
|
-
```js
|
|
1844
|
-
let title = 'Test Nofitication';
|
|
1845
|
-
let options = { body: '...', icon: '...', actions: [ ... ] };
|
|
1846
|
-
workport.nofitications.fire(title, options).then(event => {
|
|
1847
|
-
console.log(event.action);
|
|
1848
|
-
});
|
|
1849
|
-
```
|
|
1850
|
-
</details>
|
|
1851
|
-
|
|
1852
|
-
<details>
|
|
1853
|
-
<summary>Method: <code>.nofitications.handle()</code></summary>
|
|
1854
|
-
|
|
1855
|
-
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.)
|
|
1856
|
-
|
|
1857
|
-
```js
|
|
1858
|
-
workport.nofitications.handle(event => {
|
|
1859
|
-
console.log(event.action);
|
|
1860
|
-
});
|
|
1861
|
-
```
|
|
1862
|
-
</details>
|
|
1863
|
-
|
|
1864
|
-
For [Push Nofitications](https://developer.mozilla.org/en-US/docs/Web/API/Push_API), the client-side of the API exposes the following methods:
|
|
1865
|
-
|
|
1866
|
-
<details>
|
|
1867
|
-
<summary>Method: <code>.push.subscribe()</code></summary>
|
|
1868
|
-
|
|
1869
|
-
The `.push.subscribe()` method is the equivalent of the [`PushManager.subscribe()`](https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe) method. (But this can also take the *applicationServerKey* as a first argument, and other options as a second argument, in which case it automatically runs the key through an `urlBase64ToUint8Array()` function.)
|
|
1870
|
-
</details>
|
|
1871
|
-
|
|
1872
|
-
<details>
|
|
1873
|
-
<summary>Method: <code>.push.unsubscribe()</code></summary>
|
|
1874
|
-
|
|
1875
|
-
The `.push.unsubscribe()` method is the equivalent of the [`PushSubscription.unsubscribe()`](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription/unsubscribe) method.
|
|
1876
|
-
</details>
|
|
1877
|
-
|
|
1878
|
-
<details>
|
|
1879
|
-
<summary>Method: <code>.push.getSubscription()</code></summary>
|
|
1880
|
-
|
|
1881
|
-
The `.push.getSubscription()` method is the equivalent of the [`PushManager.getSubscription()`](https://developer.mozilla.org/en-US/docs/Web/API/PushManager/getSubscription) method.
|
|
1882
|
-
</details>
|
|
1883
|
-
|
|
1884
|
-
The worker-side of the API exposes the following methods:
|
|
1885
|
-
|
|
1886
|
-
<details>
|
|
1887
|
-
<summary>Method: <code>.push.listen()</code></summary>
|
|
1888
|
-
|
|
1889
|
-
The `.push.listen()` method is for listening to the [`push`](https://developer.mozilla.org/en-US/docs/Web/API/PushEvent) from within Service Workers. E.g. `workport.push.listen(event => console.log(event.data.type))`.
|
|
1890
|
-
</details>
|
|
1891
|
-
|
|
1892
|
-
###### Route *events*
|
|
1893
|
-
|
|
1894
|
-
These are simple route events that fire when messaging and notification events happen.
|
|
1895
|
-
|
|
1896
|
-
On both the client and worker side of your application, you can define an event listener alongside your *root* route handler. The event listener is called to handle all messaging and notification events that happen.
|
|
1897
|
-
|
|
1898
|
-
```js
|
|
1899
|
-
/**
|
|
1900
|
-
[client|worker]
|
|
1901
|
-
├── index.js
|
|
1902
|
-
*/
|
|
1903
|
-
export default async function(event, context, next) {
|
|
1904
|
-
return { ... };
|
|
1905
|
-
}
|
|
1906
|
-
export async function alert(event, context, next) {
|
|
1907
|
-
return { ... };
|
|
1908
|
-
}
|
|
1909
|
-
```
|
|
1910
|
-
|
|
1911
|
-
The event type is given in the `event.type` property. This could be:
|
|
1912
|
-
|
|
1913
|
-
+ **`message`** - both client and worker side. For *replyable* messages, the event handler's return value is automatically sent back as response.
|
|
1914
|
-
+ **`notificationclick`** - worker side.
|
|
1915
|
-
+ **`push`** - worker side.
|
|
1916
|
-
|
|
1917
|
-
<details>
|
|
1918
|
-
<summary>Advanced...</summary>
|
|
1919
|
-
|
|
1920
|
-
The `next()` function could be used to delegate the handling of an event to step handlers where defined. This time, the path name must be given as a second argument to the call.
|
|
1921
|
-
|
|
1922
|
-
```js
|
|
1923
|
-
/**
|
|
1924
|
-
worker
|
|
1925
|
-
├── index.js
|
|
1926
|
-
*/
|
|
1927
|
-
export async function alert(event, context, next) {
|
|
1928
|
-
if (event.type === 'push') {
|
|
1929
|
-
await next(context, '/services/push');
|
|
1930
|
-
return;
|
|
1931
|
-
}
|
|
1932
|
-
console.log(event.type);
|
|
1933
|
-
}
|
|
1934
|
-
```
|
|
1935
|
-
</details>
|
|
1936
|
-
|
|
1937
|
-
#### API Backends
|
|
1938
|
-
|
|
1939
|
-
In Webflo, an API backend is what you, in essence, come off with with your server-side routes.
|
|
1940
|
-
|
|
1941
|
-
```js
|
|
1942
|
-
/**
|
|
1943
|
-
server
|
|
1944
|
-
├── index.js
|
|
1945
|
-
*/
|
|
1946
|
-
export default function(event, context, next) {
|
|
1947
|
-
if (next.pathname) return next();
|
|
1948
|
-
return { ... };
|
|
1949
|
-
}
|
|
1950
|
-
```
|
|
1951
|
-
|
|
1952
|
-
You are always able to lay out your route handlers in the structure for a formal REST API.
|
|
1953
|
-
|
|
1954
|
-
```shell
|
|
1955
|
-
server
|
|
1956
|
-
├── index.js
|
|
1957
|
-
├── api/v1/index.js
|
|
1958
|
-
└── api/v1/products/index.js
|
|
1959
|
-
```
|
|
1960
|
-
|
|
1961
|
-
And if you will partition your backend for both page routes and a formal REST API...
|
|
1962
|
-
|
|
1963
|
-
```shell
|
|
1964
|
-
server
|
|
1965
|
-
├── index.js ──┐
|
|
1966
|
-
├── cart/index.js ├─ Page Routes
|
|
1967
|
-
├── products/index.js ──┘
|
|
1968
|
-
├── api/v1/index.js ──┐
|
|
1969
|
-
├── api/v1/orders/index.js ├─ REST API
|
|
1970
|
-
└── api/v1/products/index.js ──┘
|
|
1971
|
-
```
|
|
1972
|
-
|
|
1973
|
-
...you could get your page routes to run off your REST API by re-routing your `next()` calls to consume the appropriate API route.
|
|
1974
|
-
|
|
1975
|
-
```js
|
|
1976
|
-
/**
|
|
1977
|
-
server
|
|
1978
|
-
├── cart/index.js
|
|
1979
|
-
*/
|
|
1980
|
-
export default async function(event, context, next) {
|
|
1981
|
-
if (next.pathname) {
|
|
1982
|
-
return next();
|
|
1983
|
-
}
|
|
1984
|
-
// Items to display in cart are in the "/api/v1/orders" route
|
|
1985
|
-
let cartItems = await next(context, `/api/v1/orders?user_id=1`);
|
|
1986
|
-
return { title: 'Your Cart', ...cartItems };
|
|
1987
|
-
}
|
|
1988
|
-
```
|
|
1989
|
-
|
|
1990
|
-
This way, there is one source of truth for your application - both when visiting from a page and from a REST API.
|
|
1991
|
-
|
|
1992
|
-
#### Static Sites
|
|
1993
|
-
|
|
1994
|
-
You can build an entire static site from off the `/public` directory alone! It's all about placing files and HTML pages there to be served statically!
|
|
1995
|
-
|
|
1996
|
-
Here, static pages means pages that are not server-rendered during the request/response cycle, but served directly from files. You are free to hand-author each of them - either as standalone `index.html` files, or as a combination of `index.html` *roots* plus *templates* that can all get resolved client-side. The [Pages, Layout and Templating](https://github.com/webqit/webflo/blob/master/README.md#pages-layout-and-templating) section covers layout patterns.
|
|
1997
|
-
|
|
1998
|
-
On the other hand, if you have a dynamic site, you can make a static site off it! The idea is to turn on your server and crawl your dynamic site via HTTP requests, outputting static HTML representations of each page. This is called *Pre-Rendering* or *Static-Site Generation* (SSG)!
|
|
1999
|
-
|
|
2000
|
-
A simple tool, like [`staticgen`](https://github.com/tj/staticgen), or the basic [`wget`](https://www.gnu.org/software/wget/) command (similar to `curl`), can get this done in an instant. On figuring out the command that works best for you, you may want to add an alias of the command to your npm scripts in `package.json`.
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
```json
|
|
2004
|
-
"scripts": {
|
|
2005
|
-
"generate:site": "wget -P public -nv -nH -r -E localhost:3000"
|
|
2006
|
-
}
|
|
2007
|
-
```
|
|
2008
|
-
|
|
2009
|
-
<details>
|
|
2010
|
-
<summary>How it works...</summary>
|
|
2011
|
-
|
|
2012
|
-
> Above, we used the `-P` flag to specify the output directory as `public`, the `-nv` flag to opt into “non-verbose” mode which outputs less information, the `-r` flag to get it to crawl and download recursively, and the `-E` flag to get it to add the `.html` extension to generated files.
|
|
2013
|
-
</details>
|
|
2014
|
-
|
|
2015
|
-
*Happy static!*
|
|
2016
|
-
|
|
2017
|
-
## Webflo Config
|
|
2018
|
-
|
|
2019
|
-
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.
|
|
2020
|
-
|
|
2021
|
-
## Webflo Tooling
|
|
2022
|
-
|
|
2023
|
-
Webflo applications are often built on/with the following technologies.
|
|
2024
|
-
|
|
2025
|
-
+ [OOHTML](#oohtml)
|
|
2026
|
-
+ [OOHTML SSR](#oohtml-ssr)
|
|
2027
|
-
+ [OOHTML CLI](#oohtml-cli)
|
|
2028
|
-
+ [The Observer API](#the-observer-api)
|
|
2029
|
-
|
|
2030
|
-
### OOHTML
|
|
2031
|
-
|
|
2032
|
-
[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!
|
|
2033
|
-
|
|
2034
|
-
Webflo natively supports OOHTML in full! But it is also possible to switch this to none, or to partial support - when specific features aren't needed anywhere in your application. Server-side and client-side support for OOHTML exist independently. This is good when, for example, your application places more importance on SSR, and less on CSR, in which case a reduced support for OOHTML can reduce the overall client JS size.
|
|
2035
|
-
|
|
2036
|
-
<details>
|
|
2037
|
-
<summary>Config (Default)</summary>
|
|
2038
|
-
|
|
2039
|
-
```json
|
|
2040
|
-
{ "oohtml_support": "full" }
|
|
2041
|
-
```
|
|
2042
|
-
|
|
2043
|
-
*Values: `full`, `namespacing`, `scripting`, `templating`, `none` - See [details at OOHTML SSR](https://github.com/webqit/oohtml-ssr#options)*
|
|
2044
|
-
|
|
2045
|
-
> **File: `.webqit/webflo/client.json`**
|
|
2046
|
-
|
|
2047
|
-
> **Command: `webflo config client oohtml_support=full`**
|
|
2048
|
-
|
|
2049
|
-
> File: `.webqit/webflo/server.json` | Command: `webflo config server oohtml_support=full`
|
|
2050
|
-
</details>
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
### OOHTML SSR
|
|
2054
|
-
|
|
2055
|
-
[OOHTML SSR](https://github.com/webqit/oohtml-ssr) is a server-side DOM implementation with native support for OOHTML. This is internally used by Webflo as the Server-Side Rendering engine, and it it what gives Webflo its native support for OOHTML.
|
|
2056
|
-
|
|
2057
|
-
### OOHTML CLI
|
|
2058
|
-
|
|
2059
|
-
[OOHTML CLI](https://github.com/webqit/oohtml-cli) is a small Command Line utility that automates certain aspects of hand-authored OOHTML-based documents.
|
|
2060
|
-
|
|
2061
|
-
### The Observer API
|
|
2062
|
-
|
|
2063
|
-
[The Observer API](https://github.com/webqit/observer) is a simple set of functions for intercepting and observing JavaScript objects and arrays. (Reflection, Interception, and Events.)
|
|
2064
|
-
|
|
2065
|
-
This is part of OOHTML's reactivity system, and it is made available on OOHTML-based documents as `window.WebQit.Observer`.
|
|
2066
|
-
|
|
2067
|
-
## Getting Started
|
|
2068
|
-
|
|
2069
|
-
Your baby steps with Webflo could be a ["Hello World" `index.html` file](#installation), optionally, next with a route handler that returns an equivalent `{ title: 'Hello World'}` object!
|
|
2070
|
-
|
|
2071
|
-
You could soon be taking all your ideas to Webflo! 😃
|
|
2072
|
-
|
|
2073
|
-
## Getting Involved
|
|
2074
|
-
|
|
2075
|
-
All forms of contributions and PR are welcome! To report bugs or request features, please submit an [issue](https://github.com/webqit/webflo/issues). For general discussions, ideation or community help, please join our github [Discussions](https://github.com/webqit/webflo/discussions).
|
|
40
|
+
This is Webflo's newest iteration! This is a major overhaul from [the previous](https://github.com/webqit/webflo/tree/prev) idea! Documentation is coming!
|
|
2076
41
|
|
|
2077
42
|
## License
|
|
2078
43
|
|