@webqit/webflo 1.0.12 → 1.0.14

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": "1.0.12",
15
+ "version": "1.0.14",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -3,8 +3,7 @@ import { WebfloRootClient2 } from './WebfloRootClient2.js';
3
3
  import { WebfloSubClient } from './WebfloSubClient.js';
4
4
 
5
5
  export function start() {
6
- const navigationAPIMeta = document.querySelector('meta[name="webflo-navigationapi"]')?.value;
7
- const WebfloRootClient = window.navigation && navigationAPIMeta ? WebfloRootClient2 : WebfloRootClient1;
6
+ const WebfloRootClient = window.navigation ? WebfloRootClient2 : WebfloRootClient1;
8
7
  const instance = WebfloRootClient.create(document, this || {});
9
8
  instance.initialize();
10
9
  WebfloSubClient.defineElement();
@@ -6,7 +6,7 @@ export class SessionStorage extends WebfloStorage {
6
6
 
7
7
  static create(request, params = {}) {
8
8
  let sessionID = request.headers.get('Cookie', true).find((c) => c.name === '__sessid')?.value;
9
- if (sessionID?.includes('.')) {
9
+ if (sessionID?.includes('.') && params.secret) {
10
10
  const [rand, signature] = sessionID.split('.');
11
11
  const expectedSignature = crypto.createHmac('sha256', params.secret)
12
12
  .update(rand)
@@ -12,6 +12,7 @@ import { _each } from '@webqit/util/obj/index.js';
12
12
  import { slice as _streamSlice } from 'stream-slice';
13
13
  import { Readable as _ReadableStream } from 'stream';
14
14
  import { WebfloRuntime } from '../WebfloRuntime.js';
15
+ import { createWindow } from '@webqit/oohtml-ssr';
15
16
  import { Context } from './Context.js';
16
17
  import { CookieStorage } from './CookieStorage.js';
17
18
  import { SessionStorage } from './SessionStorage.js';
@@ -20,7 +21,7 @@ import { ClientMessagingRegistry } from './ClientMessagingRegistry.js';
20
21
  import { HttpEvent } from '../HttpEvent.js';
21
22
  import { HttpUser } from '../HttpUser.js';
22
23
  import { Router } from './Router.js';
23
- import { pattern } from '../util-url.js';
24
+ import { params, pattern } from '../util-url.js';
24
25
  import xfetch from '../xfetch.js';
25
26
  import '../util-http.js';
26
27
 
@@ -646,28 +647,34 @@ export class WebfloServer extends WebfloRuntime {
646
647
  pathnameSplit.pop();
647
648
  }
648
649
  const dirPublic = Url.pathToFileURL(Path.resolve(Path.join(this.#cx.CWD, this.#cx.layout.PUBLIC_DIR)));
649
- const instanceParams = QueryString.stringify({
650
- file: renderFile,
650
+ const instanceParams = /*QueryString.stringify*/({
651
+ //file: renderFile,
651
652
  url: dirPublic.href,// httpEvent.url.href,
652
653
  root: this.#cx.CWD,
653
654
  });
654
- const { window, document } = await import('@webqit/oohtml-ssr/src/instance.js?' + instanceParams);
655
+ const { window, document } = createWindow(renderFile, instanceParams);
656
+ //const { window, document } = await import('@webqit/oohtml-ssr/src/instance.js?' + instanceParams);
655
657
  await new Promise(res => {
656
- if (document.readyState === 'complete') return res();
658
+ if (document.readyState === 'complete') return res(1);
657
659
  document.addEventListener('load', res);
658
660
  });
659
- // Await rendering engine
660
- if (window.webqit.$qCompilerImport) {
661
- await new Promise(res => {
662
- window.webqit.$qCompilerImport.then(res);
663
- setTimeout(res, 300);
664
- });
665
- }
666
661
  if (window.webqit?.oohtml?.configs) {
662
+ // Await rendering engine
663
+ if (window.webqit?.$qCompilerWorker) {
664
+ window.webqit.$qCompilerWorker.postMessage({ source: '1+1', params: {} }, []);
665
+ await new Promise(res => {
666
+ window.webqit.$qCompilerImport.then(res);
667
+ setTimeout(() => res(1), 1000);
668
+ });
669
+ }
667
670
  const {
668
- BINDINGS_API: { api: bindingsConfig } = {},
669
671
  HTML_IMPORTS: { attr: modulesContextAttrs } = {},
672
+ BINDINGS_API: { api: bindingsConfig } = {},
670
673
  } = window.webqit.oohtml.configs;
674
+ if (modulesContextAttrs) {
675
+ const newRoute = '/' + `routes/${httpEvent.url.pathname}`.split('/').map(a => (a => a.startsWith('$') ? '-' : a)(a.trim())).filter(a => a).join('/');
676
+ document.body.setAttribute(modulesContextAttrs.importscontext, newRoute);
677
+ }
671
678
  if (bindingsConfig) {
672
679
  document[bindingsConfig.bind]({
673
680
  state: {},
@@ -684,11 +691,7 @@ export class WebfloServer extends WebfloRuntime {
684
691
  console.error(`The following data properties were overridden: ${overridenKeys.join(', ')}`);
685
692
  }
686
693
  }
687
- if (modulesContextAttrs) {
688
- const newRoute = '/' + `routes/${httpEvent.url.pathname}`.split('/').map(a => (a => a.startsWith('$') ? '-' : a)(a.trim())).filter(a => a).join('/');
689
- document.body.setAttribute(modulesContextAttrs.importscontext, newRoute);
690
- }
691
- await new Promise(res => setTimeout(res, 500));
694
+ await new Promise(res => setTimeout(res, 300));
692
695
  }
693
696
  // Append background-activity meta
694
697
  let backgroundActivityMeta = document.querySelector('meta[name="X-Background-Messaging"]');
@@ -708,7 +711,11 @@ export class WebfloServer extends WebfloRuntime {
708
711
  hydrationData.setAttribute('rel', 'hydration');
709
712
  hydrationData.textContent = JSON.stringify(data);
710
713
  document.body.append(hydrationData);
711
- return window;
714
+ const rendering = window.toString();
715
+ document.documentElement.remove();
716
+ document.writeln('');
717
+ try { window.close(); } catch(e) {}
718
+ return rendering;
712
719
  });
713
720
  // Validate rendering
714
721
  if (typeof scope.rendering !== 'string' && !(typeof scope.rendering?.toString === 'function')) {