@inglorious/web 5.0.0 → 5.0.1

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 +3 -3
  2. package/src/mount.js +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
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",
@@ -51,8 +51,8 @@
51
51
  "dependencies": {
52
52
  "@lit-labs/ssr-client": "^1.1.8",
53
53
  "lit-html": "^3.3.1",
54
- "@inglorious/store": "10.0.0",
55
- "@inglorious/utils": "3.8.0"
54
+ "@inglorious/utils": "3.8.0",
55
+ "@inglorious/store": "10.0.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "prettier": "^3.6.2",
package/src/mount.js CHANGED
@@ -10,20 +10,21 @@ import { html, render } from "lit-html"
10
10
  * @param {Store} store - The application state store.
11
11
  * @param {(api: Api) => TemplateResult | null} renderFn - The root render function.
12
12
  * @param {HTMLElement | DocumentFragment} element - The DOM element to mount the template to.
13
+ * @param {Object} [options] - Mount options.
14
+ * @param {boolean} [options.hydrate=true] - Whether to hydrate the existing DOM.
13
15
  * @returns {() => void} An unsubscribe function
14
16
  */
15
- export async function mount(store, renderFn, element) {
17
+ export async function mount(store, renderFn, element, options = {}) {
16
18
  const api = { ...store._api }
17
19
  api.render = createRender(api)
18
20
 
19
- let shouldHydrate = element.hasChildNodes()
21
+ const shouldHydrate = options.hydrate !== false && element.hasChildNodes()
20
22
 
21
23
  // If we need to hydrate, load the heavy lifting only now
22
24
  if (shouldHydrate) {
23
25
  const { hydrate } = await import("@lit-labs/ssr-client")
24
26
  const template = renderFn(api)
25
27
  hydrate(template, element)
26
- shouldHydrate = false
27
28
  }
28
29
 
29
30
  const unsubscribe = store.subscribe(() => {