@inglorious/web 4.1.3 → 4.1.5

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/mount.js +11 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "4.1.3",
3
+ "version": "4.1.5",
4
4
  "description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -68,13 +68,13 @@
68
68
  "dependencies": {
69
69
  "@lit-labs/ssr-client": "^1.1.8",
70
70
  "lit-html": "^3.3.1",
71
- "@inglorious/store": "9.3.0",
72
- "@inglorious/utils": "3.7.2"
71
+ "@inglorious/store": "9.3.1",
72
+ "@inglorious/utils": "3.7.3"
73
73
  },
74
74
  "devDependencies": {
75
75
  "prettier": "^3.6.2",
76
76
  "vitest": "^4.0.15",
77
- "@inglorious/eslint-config": "1.1.1"
77
+ "@inglorious/eslint-config": "1.1.2"
78
78
  },
79
79
  "engines": {
80
80
  "node": ">= 22"
package/src/mount.js CHANGED
@@ -1,4 +1,3 @@
1
- import { hydrate } from "@lit-labs/ssr-client"
2
1
  import { html, render } from "lit-html"
3
2
 
4
3
  /**
@@ -8,25 +7,27 @@ import { html, render } from "lit-html"
8
7
  * @param {HTMLElement | DocumentFragment} element - The DOM element to mount the template to.
9
8
  * @returns {() => void} An unsubscribe function
10
9
  */
11
- export function mount(store, renderFn, element) {
10
+ export async function mount(store, renderFn, element) {
12
11
  const api = { ...store._api }
13
12
  api.render = createRender(api)
14
13
 
15
14
  let shouldHydrate = element.hasChildNodes()
16
15
 
17
- const unsubscribe = store.subscribe(() => {
16
+ // If we need to hydrate, load the heavy lifting only now
17
+ if (shouldHydrate) {
18
+ const { hydrate } = await import("@lit-labs/ssr-client")
18
19
  const template = renderFn(api)
20
+ hydrate(template, element)
21
+ shouldHydrate = false
22
+ }
19
23
 
20
- if (shouldHydrate) {
21
- hydrate(template, element)
22
- shouldHydrate = false
23
- } else {
24
- render(template, element)
25
- }
24
+ const unsubscribe = store.subscribe(() => {
25
+ const template = renderFn(api)
26
+ // Standard render is already in the main bundle (it's small)
27
+ render(template, element)
26
28
  })
27
29
 
28
30
  store.notify("init")
29
-
30
31
  return unsubscribe
31
32
  }
32
33