@webqit/webflo 0.8.76 → 0.8.77
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/package.json +1 -1
- package/src/runtime/_Request.js +2 -4
- package/src/runtime/client/Navigator.js +1 -1
- package/src/runtime/client/Storage.js +8 -7
- package/src/runtime/client/Worker.js +6 -1
- /package/src/runtime/client/{Cache.js → archive/Cache.js} +0 -0
- /package/src/runtime/client/{Http.js → archive/Http.js} +0 -0
- /package/src/runtime/client/{StdRequest.js → archive/StdRequest.js} +0 -0
- /package/src/runtime/client/{WorkerComm.js → archive/WorkerComm.js} +0 -0
package/package.json
CHANGED
package/src/runtime/_Request.js
CHANGED
|
@@ -32,10 +32,8 @@ const _Request = globals => class extends _MessageStream(globals.Request, _Reque
|
|
|
32
32
|
// Init can contain "already-parsed request content"
|
|
33
33
|
if (('body' in init)) {
|
|
34
34
|
init = { ...init };
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
init.body = _typedDataCache.body;
|
|
38
|
-
}
|
|
35
|
+
_typedDataCache = encodeBody(init.body, globals);
|
|
36
|
+
init.body = _typedDataCache.body;
|
|
39
37
|
}
|
|
40
38
|
if (!_isEmpty(init)) {
|
|
41
39
|
super(input, init);
|
|
@@ -157,7 +157,6 @@ export default class Navigator {
|
|
|
157
157
|
...params,
|
|
158
158
|
headers: {
|
|
159
159
|
'Accept': 'application/json',
|
|
160
|
-
'Cache-Control': 'no-store',
|
|
161
160
|
'X-Redirect-Policy': 'manual-when-cross-origin',
|
|
162
161
|
'X-Redirect-Code': xRedirectCode,
|
|
163
162
|
'X-Powered-By': '@webqit/webflo',
|
|
@@ -224,6 +223,7 @@ export default class Navigator {
|
|
|
224
223
|
this._abortController = new AbortController();
|
|
225
224
|
let xRedirectCode = 300;
|
|
226
225
|
|
|
226
|
+
|
|
227
227
|
if (params.srcType === 'init' || !(_before(url.href, '#') === _before(params.referrer, '#') && (params.method || 'GET').toUpperCase() === 'GET')) {
|
|
228
228
|
handleResponse(this.client.call(this, generateRequest(url.href, params), params, remoteRequest), params);
|
|
229
229
|
}
|
|
@@ -6,30 +6,31 @@
|
|
|
6
6
|
import { _isString, _isUndefined } from '@webqit/util/js/index.js';
|
|
7
7
|
import { Observer } from './Runtime.js';
|
|
8
8
|
|
|
9
|
-
export default function(persistent = false) {
|
|
9
|
+
export default function(persistent = false, namespace = null) {
|
|
10
10
|
|
|
11
11
|
const storeType = persistent ? 'localStorage' : 'sessionStorage';
|
|
12
12
|
if (!window[storeType]) {
|
|
13
|
-
throw new Error(`The specified Web Storage API ${storeType} is invalid or not supported`)
|
|
13
|
+
throw new Error(`The specified Web Storage API ${storeType} is invalid or not supported`);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const _storage = {};
|
|
17
17
|
Observer.intercept(_storage, (event, received, next) => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const key = namespace ? `${namespace}.${event.name}` : event.name;
|
|
19
|
+
if (event.type === 'get' && _isString(key)) {
|
|
20
|
+
const value = window[storeType].getItem(key);
|
|
20
21
|
return !_isUndefined(value) ? JSON.parse(value) : value;
|
|
21
22
|
}
|
|
22
23
|
if (event.type === 'set') {
|
|
23
|
-
window[storeType].setItem(
|
|
24
|
+
window[storeType].setItem(key, !_isUndefined(event.value) ? JSON.stringify(event.value) : event.value);
|
|
24
25
|
return true;
|
|
25
26
|
}
|
|
26
27
|
if (event.type === 'deleteProperty') {
|
|
27
|
-
window[storeType].removeItem(
|
|
28
|
+
window[storeType].removeItem(key);
|
|
28
29
|
return true;
|
|
29
30
|
}
|
|
30
31
|
if (event.type === 'has') {
|
|
31
32
|
for(var i = 0; i < window[storeType].length; i ++){
|
|
32
|
-
if (window[storeType].key(i) ===
|
|
33
|
+
if (window[storeType].key(i) === key) {
|
|
33
34
|
return true;
|
|
34
35
|
}
|
|
35
36
|
};
|
|
@@ -103,10 +103,15 @@ export default function(layout, params) {
|
|
|
103
103
|
|
|
104
104
|
if (evt.request.url.startsWith(self.origin) && (evt.request.mode === 'navigate' || evt.request.headers.get('X-Powered-By') === '@webqit/webflo')) {
|
|
105
105
|
// -----------------
|
|
106
|
+
// We must patch the event object with the new request instance
|
|
107
|
+
// cos the body of the original gets consumed (thus invalidated) by the new instance
|
|
108
|
+
Object.defineProperty(evt, 'request', {
|
|
109
|
+
value: new NavigationEvent.Request(evt.request),
|
|
110
|
+
});
|
|
106
111
|
// Sync session data to cache to be available to service-worker routers
|
|
107
112
|
// Sync only takes for requests that actually do send the "$session" cookie
|
|
108
113
|
const sessionData = Observer.proxy(sessionStores[evt.clientId] || {});
|
|
109
|
-
const clientNavigationEvent = new NavigationEvent(
|
|
114
|
+
const clientNavigationEvent = new NavigationEvent(evt.request, sessionData);
|
|
110
115
|
// -----------------
|
|
111
116
|
// The app router
|
|
112
117
|
const router = new Router(_before(evt.request.url, '?'), layout, { layout });
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|