@inglorious/web 4.1.6 → 4.2.0

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 +10 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "4.1.6",
3
+ "version": "4.2.0",
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,8 +68,8 @@
68
68
  "dependencies": {
69
69
  "@lit-labs/ssr-client": "^1.1.8",
70
70
  "lit-html": "^3.3.1",
71
- "@inglorious/store": "9.4.0",
72
- "@inglorious/utils": "3.7.3"
71
+ "@inglorious/utils": "3.7.3",
72
+ "@inglorious/store": "9.5.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "prettier": "^3.6.2",
package/src/mount.js CHANGED
@@ -1,9 +1,13 @@
1
+ /** @typedef {import('lit-html').TemplateResult} TemplateResult */
2
+ /** @typedef {import('@inglorious/store').Store} Store */
3
+ /** @typedef {import('../types/mount').Api} Api */
4
+
1
5
  import { html, render } from "lit-html"
2
6
 
3
7
  /**
4
8
  * Mounts a lit-html template to the DOM and subscribes to a store for re-rendering.
5
- * @param {import('@inglorious/store').Store} store - The application state store.
6
- * @param {(api: import('../types/mount').Api) => import('lit-html').TemplateResult | null} renderFn - The root render function.
9
+ * @param {Store} store - The application state store.
10
+ * @param {(api: Api) => TemplateResult | null} renderFn - The root render function.
7
11
  * @param {HTMLElement | DocumentFragment} element - The DOM element to mount the template to.
8
12
  * @returns {() => void} An unsubscribe function
9
13
  */
@@ -33,30 +37,18 @@ export async function mount(store, renderFn, element) {
33
37
 
34
38
  /**
35
39
  * Creates a render function for the mount API.
36
- * @param {import('../types/mount').Api} api - The mount API.
37
- * @returns {import('../types/mount').Api['render']} A `render` function that can render an entity or a type by its ID.
40
+ * @param {Api} api - The mount API.
41
+ * @returns {Api['render']} A `render` function that can render an entity or a type by its ID.
38
42
  * @private
39
43
  */
40
44
  function createRender(api) {
41
- return function (id, options = {}) {
45
+ return function (id) {
42
46
  const entity = api.getEntity(id)
43
47
 
44
48
  if (!entity) {
45
- const { allowType } = options
46
- if (!allowType) {
47
- return ""
48
- }
49
-
50
- // No entity with this ID, try static type
51
- const type = api.getType(id)
52
- if (!type?.render) {
53
- console.warn(`No entity or type found: ${id}`)
54
- return html`<div>Not found: ${id}</div>`
55
- }
56
- return type.render(api)
49
+ return ""
57
50
  }
58
51
 
59
- // Entity exists, render it
60
52
  const type = api.getType(entity.type)
61
53
  if (!type?.render) {
62
54
  console.warn(`No render function for type: ${entity.type}`)