@webqit/webflo 1.0.13 → 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.13",
15
+ "version": "1.0.14",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -21,7 +21,7 @@ import { ClientMessagingRegistry } from './ClientMessagingRegistry.js';
21
21
  import { HttpEvent } from '../HttpEvent.js';
22
22
  import { HttpUser } from '../HttpUser.js';
23
23
  import { Router } from './Router.js';
24
- import { pattern } from '../util-url.js';
24
+ import { params, pattern } from '../util-url.js';
25
25
  import xfetch from '../xfetch.js';
26
26
  import '../util-http.js';
27
27
 
@@ -652,25 +652,29 @@ export class WebfloServer extends WebfloRuntime {
652
652
  url: dirPublic.href,// httpEvent.url.href,
653
653
  root: this.#cx.CWD,
654
654
  });
655
- const window = createWindow(renderFile, instanceParams);
656
- const document = window.document;
655
+ const { window, document } = createWindow(renderFile, instanceParams);
657
656
  //const { window, document } = await import('@webqit/oohtml-ssr/src/instance.js?' + instanceParams);
658
657
  await new Promise(res => {
659
- if (document.readyState === 'complete') return res();
658
+ if (document.readyState === 'complete') return res(1);
660
659
  document.addEventListener('load', res);
661
660
  });
662
- // Await rendering engine
663
- if (window.webqit.$qCompilerImport) {
664
- await new Promise(res => {
665
- window.webqit.$qCompilerImport.then(res);
666
- setTimeout(res, 300);
667
- });
668
- }
669
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
+ }
670
670
  const {
671
- BINDINGS_API: { api: bindingsConfig } = {},
672
671
  HTML_IMPORTS: { attr: modulesContextAttrs } = {},
672
+ BINDINGS_API: { api: bindingsConfig } = {},
673
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
+ }
674
678
  if (bindingsConfig) {
675
679
  document[bindingsConfig.bind]({
676
680
  state: {},
@@ -687,11 +691,7 @@ export class WebfloServer extends WebfloRuntime {
687
691
  console.error(`The following data properties were overridden: ${overridenKeys.join(', ')}`);
688
692
  }
689
693
  }
690
- if (modulesContextAttrs) {
691
- const newRoute = '/' + `routes/${httpEvent.url.pathname}`.split('/').map(a => (a => a.startsWith('$') ? '-' : a)(a.trim())).filter(a => a).join('/');
692
- document.body.setAttribute(modulesContextAttrs.importscontext, newRoute);
693
- }
694
- await new Promise(res => setTimeout(res, 500));
694
+ await new Promise(res => setTimeout(res, 300));
695
695
  }
696
696
  // Append background-activity meta
697
697
  let backgroundActivityMeta = document.querySelector('meta[name="X-Background-Messaging"]');
@@ -711,7 +711,11 @@ export class WebfloServer extends WebfloRuntime {
711
711
  hydrationData.setAttribute('rel', 'hydration');
712
712
  hydrationData.textContent = JSON.stringify(data);
713
713
  document.body.append(hydrationData);
714
- return window;
714
+ const rendering = window.toString();
715
+ document.documentElement.remove();
716
+ document.writeln('');
717
+ try { window.close(); } catch(e) {}
718
+ return rendering;
715
719
  });
716
720
  // Validate rendering
717
721
  if (typeof scope.rendering !== 'string' && !(typeof scope.rendering?.toString === 'function')) {
@@ -722,7 +726,6 @@ export class WebfloServer extends WebfloRuntime {
722
726
  headers: response.headers,
723
727
  status: response.status,
724
728
  });
725
- scope.rendering.close?.();
726
729
  scope.response.headers.set('Content-Type', 'text/html');
727
730
  scope.response.headers.set('Content-Length', (new Blob([scope.rendering])).size);
728
731
  return scope.response;