@webqit/webflo 0.20.17 → 0.20.18

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 CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "0.20.17",
15
+ "version": "0.20.18",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -322,6 +322,7 @@ export class WebfloClient extends WebfloRuntime {
322
322
  method: null
323
323
  });
324
324
  };
325
+
325
326
  // Ping existing background processes
326
327
  // !IMPORTANT: Posting to the group when empty will keep the event until next addition
327
328
  // and we don't want that
@@ -329,6 +330,9 @@ export class WebfloClient extends WebfloRuntime {
329
330
  const url = { ...Url.copy(scopeObj.url), method: scopeObj.request.method };
330
331
  this.#background.postMessage(url, { wqEventOptions: { type: 'navigate' } });
331
332
  }
333
+
334
+ console.log('_______,', scopeObj.detail.navigationType);
335
+
332
336
  // Dispatch for response
333
337
  scopeObj.response = await this.dispatchNavigationEvent({
334
338
  httpEvent: scopeObj.httpEvent,
@@ -342,20 +346,15 @@ export class WebfloClient extends WebfloRuntime {
342
346
  clientPortB: wqMessageChannel.port2,
343
347
  originalRequestInit: scopeObj.init
344
348
  });
349
+
345
350
  // Decode response
346
351
  scopeObj.finalUrl = scopeObj.response.url || scopeObj.request.url;
347
352
  if (scopeObj.response.redirected || scopeObj.detail.navigationType === 'rdr' || scopeObj.detail.isHoisted) {
348
353
  const stateData = { ...(this.currentEntry()?.getState() || {}), redirected: true, };
349
354
  await this.updateCurrentEntry({ state: stateData }, scopeObj.finalUrl);
350
355
  }
356
+
351
357
  // Transition UI
352
- Observer.set(this.transition.from, Url.copy(this.location));
353
- Observer.set(this.transition.to, 'href', scopeObj.finalUrl);
354
- Observer.set(this.transition, 'rel', this.transition.from.pathname === this.transition.to.pathname ? 'unchanged' : (
355
- `${this.transition.from.pathname}/`.startsWith(`${this.transition.to.pathname}/`) ? 'parent' : (
356
- `${this.transition.to.pathname}/`.startsWith(`${this.transition.from.pathname}/`) ? 'child' : 'unrelated'
357
- )
358
- ));
359
358
  await this.transitionUI(async () => {
360
359
  // Set post-request states
361
360
  Observer.set(this.location, 'href', scopeObj.finalUrl);
@@ -374,12 +373,12 @@ export class WebfloClient extends WebfloRuntime {
374
373
  !(['GET'].includes(scopeObj.request.method) || scopeObj.response.redirected || scopeObj.detail.navigationType === 'rdr')
375
374
  );
376
375
  await this.applyPostRenderState(scopeObj.httpEvent);
377
- });
376
+ }, scopeObj.finalUrl, scopeObj.detail);
378
377
  }
379
378
 
380
379
  async dispatchNavigationEvent({ httpEvent, crossLayerFetch, clientPortB, originalRequestInit, processObj = {} }) {
381
380
  let response = await super.dispatchNavigationEvent({ httpEvent, crossLayerFetch, clientPortB });
382
-
381
+
383
382
  // Extract interactive. mode handling
384
383
  const handleInteractiveMode = async (resolve) => {
385
384
  const liveResponse = await LiveResponse.from(response);
@@ -469,19 +468,29 @@ export class WebfloClient extends WebfloRuntime {
469
468
  return 2; // Window reload
470
469
  }
471
470
 
472
- async transitionUI(updateCallback) {
473
- if (document.startViewTransition && this.withViewTransitions) {
471
+ async transitionUI(updateCallback, finalUrl, detail) {
472
+ // Set initial states
473
+ Observer.set(this.transition.from, Url.copy(this.location));
474
+ Observer.set(this.transition.to, 'href', finalUrl);
475
+ const viewTransitionRel = this.transition.from.pathname === this.transition.to.pathname ? 'same' : (
476
+ `${this.transition.from.pathname}/`.startsWith(`${this.transition.to.pathname}/`) ? 'out' : (
477
+ `${this.transition.to.pathname}/`.startsWith(`${this.transition.from.pathname}/`) ? 'in' : 'other'
478
+ )
479
+ );
480
+ Observer.set(this.transition, 'rel', viewTransitionRel);
481
+ // Trigger transition
482
+ if (document.startViewTransition && this.withViewTransitions && !detail.hasUAVisualTransition) {
474
483
  const synthesizeWhile = window.webqit?.realdom?.synthesizeWhile || ((callback) => callback());
475
484
  return new Promise(async (resolve) => {
476
485
  await synthesizeWhile(async () => {
477
- Observer.set(this.transition, 'phase', 1);
478
- const viewTransition = document.startViewTransition(updateCallback);
486
+ Observer.set(this.transition, 'phase', 'old');
487
+ const viewTransition = document.startViewTransition({ update: updateCallback, styles: ['navigation', viewTransitionRel] });
479
488
  try { await viewTransition.updateCallbackDone; } catch (e) { console.log(e); }
480
- Observer.set(this.transition, 'phase', 2);
489
+ Observer.set(this.transition, 'phase', 'new');
481
490
  try { await viewTransition.ready; } catch (e) { console.log(e); }
482
- Observer.set(this.transition, 'phase', 3);
491
+ Observer.set(this.transition, 'phase', 'start');
483
492
  try { await viewTransition.finished; } catch (e) { console.log(e); }
484
- Observer.set(this.transition, 'phase', 0);
493
+ Observer.set(this.transition, 'phase', 'end');
485
494
  resolve();
486
495
  });
487
496
  });
@@ -24,12 +24,16 @@ export class WebfloRootClient2 extends WebfloRootClient1 {
24
24
  if (!e.canIntercept
25
25
  || e.downloadRequest !== null
26
26
  || !this.isSpaRoute(e.destination.url)
27
- || e.navigationType === 'reload') return;
27
+ || ['reload'].includes(e.navigationType)) return;
28
28
  if (e.hashChange) {
29
29
  Observer.set(this.location, 'href', e.destination.url);
30
30
  return;
31
31
  }
32
- const { navigationType, destination, signal, formData, info, userInitiated } = e;
32
+ if (e.navigationType === 'replace') {
33
+ e.intercept({});
34
+ return;
35
+ }
36
+ const { navigationType, destination, signal, formData, info, userInitiated, hasUAVisualTransition } = e;
33
37
  if (formData && navigationOrigins[1]?.hasAttribute('webflo-no-intercept')) return;
34
38
  if (formData && (navigationOrigins[0] || {}).name) { formData.set(navigationOrigins[0].name, navigationOrigins[0].value); }
35
39
  // Navigation details
@@ -39,6 +43,7 @@ export class WebfloRootClient2 extends WebfloRootClient1 {
39
43
  destination,
40
44
  source: this.currentEntry(),
41
45
  userInitiated,
46
+ hasUAVisualTransition,
42
47
  info
43
48
  };
44
49
  navigationOrigins = [];
@@ -50,18 +55,11 @@ export class WebfloRootClient2 extends WebfloRootClient1 {
50
55
  body: formData,
51
56
  //signal TODO: auto-aborts on a redirect response which thus fails to parse
52
57
  };
53
- this.updateCurrentEntry({
54
- state: {
55
- ...(this.currentEntry().getState() || {}),
56
- scrollPosition: [window.scrollX, window.scrollY],
57
- }
58
- });
59
58
  const runtime = this;
60
59
  e.intercept({
61
60
  scroll: 'after-transition',
62
61
  focusReset: 'after-transition',
63
62
  async handler() {
64
- if (navigationType === 'replace') return;
65
63
  await runtime.navigate(url, init, detail);
66
64
  },
67
65
  });
@@ -100,7 +100,7 @@ export class WebfloSubClient extends WebfloClient {
100
100
  if (response && LiveResponse.hasBackground(response)) {
101
101
  Observer.set(this.navigator, 'redirecting', new Url/*NOT URL*/(location), { diff: true });
102
102
  const backgroundPort = LiveResponse.getBackground(response);
103
- backgroundPort.postMessage('keep-alive');
103
+ backgroundPort.postMessage(true, { wqEventOptions: { type: 'keep-alive' } });
104
104
  backgroundPort.addEventListener('close', (e) => {
105
105
  window.removeEventListener('message', windowMessageHandler);
106
106
  Observer.set(this.navigator, 'redirecting', null);