@inglorious/web 6.4.0 → 6.4.2
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/README.md +11 -7
- package/package.json +7 -7
- package/src/decorators/with-debounce/index.js +1 -1
- package/src/decorators/with-throttle/index.js +1 -1
- package/src/form/handlers.js +1 -1
- package/src/form/helpers.js +1 -1
- package/src/mount.js +32 -28
- package/types/decorators/with-debounce.d.ts +1 -2
- package/types/decorators/with-throttle.d.ts +1 -2
package/README.md
CHANGED
|
@@ -1290,10 +1290,12 @@ const renderApp = (api) => {
|
|
|
1290
1290
|
<p>Loading: ${geolocation.isLoading ? "yes" : "no"}</p>
|
|
1291
1291
|
<p>
|
|
1292
1292
|
Position:
|
|
1293
|
-
${
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1293
|
+
${
|
|
1294
|
+
position
|
|
1295
|
+
? html`${position.coords.latitude.toFixed(4)},
|
|
1296
|
+
${position.coords.longitude.toFixed(4)}`
|
|
1297
|
+
: "unknown"
|
|
1298
|
+
}
|
|
1297
1299
|
</p>
|
|
1298
1300
|
<p>Error: ${geolocation.error ? geolocation.error.message : "none"}</p>
|
|
1299
1301
|
<button
|
|
@@ -1383,9 +1385,11 @@ const renderApp = (api) => {
|
|
|
1383
1385
|
<p>Active: ${compass.isCompassActive ? "yes" : "no"}</p>
|
|
1384
1386
|
<p>
|
|
1385
1387
|
Heading:
|
|
1386
|
-
${
|
|
1387
|
-
|
|
1388
|
-
|
|
1388
|
+
${
|
|
1389
|
+
compass.heading !== null
|
|
1390
|
+
? `${compass.heading.toFixed(1)}°`
|
|
1391
|
+
: "unknown"
|
|
1392
|
+
}
|
|
1389
1393
|
</p>
|
|
1390
1394
|
<p>Error: ${compass.error ? compass.error.message : "none"}</p>
|
|
1391
1395
|
<button @click=${() => api.notify("compassPermissionsRequest")}>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/web",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.2",
|
|
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": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"contributors": [
|
|
@@ -104,17 +104,17 @@
|
|
|
104
104
|
},
|
|
105
105
|
"sideEffects": false,
|
|
106
106
|
"dependencies": {
|
|
107
|
+
"@inglorious/utils": "4.0.0",
|
|
107
108
|
"@lit-labs/ssr-client": "^1.1.8",
|
|
108
|
-
"lit-html": "^3.3.
|
|
109
|
-
"@inglorious/utils": "3.8.0"
|
|
109
|
+
"lit-html": "^3.3.3"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
|
-
"@inglorious/store": "11.0.
|
|
112
|
+
"@inglorious/store": "11.0.2"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
115
|
+
"@inglorious/eslint-config": "1.1.2",
|
|
116
|
+
"prettier": "^3.9.6",
|
|
117
|
+
"vitest": "^5.0.0"
|
|
118
118
|
},
|
|
119
119
|
"engines": {
|
|
120
120
|
"node": ">= 22"
|
package/src/form/handlers.js
CHANGED
package/src/form/helpers.js
CHANGED
package/src/mount.js
CHANGED
|
@@ -5,32 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { html, render } from "lit-html"
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Root-level error boundary. Unlike the per-entity `withErrorBoundary`
|
|
10
|
-
* decorator (which isolates a single failing type's render), this catches
|
|
11
|
-
* errors thrown by the *root* render function itself — before any entity is
|
|
12
|
-
* reached (e.g. a missing router entity), or by an unguarded child.
|
|
13
|
-
*
|
|
14
|
-
* Without it, a throwing root render takes down the whole app: on the initial
|
|
15
|
-
* pass it aborts the mount, and inside the store subscription it throws out of
|
|
16
|
-
* the notify loop on every subsequent update, freezing the UI. Catching it
|
|
17
|
-
* keeps the subscription alive so one bad tick can't kill the app.
|
|
18
|
-
*
|
|
19
|
-
* @param {(api: Api) => TemplateResult | null} renderFn
|
|
20
|
-
* @param {Api} api
|
|
21
|
-
* @param {(error: unknown, api: Api) => void} onError
|
|
22
|
-
* @param {((error: unknown, api: Api) => TemplateResult | null) | undefined} fallback
|
|
23
|
-
* @returns {{ ok: true, template: TemplateResult | null } | { ok: false, fallback: TemplateResult | null }}
|
|
24
|
-
*/
|
|
25
|
-
function renderRoot(renderFn, api, onError, fallback) {
|
|
26
|
-
try {
|
|
27
|
-
return { ok: true, template: renderFn(api) }
|
|
28
|
-
} catch (error) {
|
|
29
|
-
onError(error, api)
|
|
30
|
-
return { ok: false, fallback: fallback ? fallback(error, api) : null }
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
8
|
/**
|
|
35
9
|
* Mounts a lit-html template to the DOM and subscribes to a store for re-rendering.
|
|
36
10
|
* @param {Store} store - The application state store.
|
|
@@ -44,12 +18,16 @@ function renderRoot(renderFn, api, onError, fallback) {
|
|
|
44
18
|
* @returns {() => void} An unsubscribe function
|
|
45
19
|
*/
|
|
46
20
|
export async function mount(store, renderFn, element, options = {}) {
|
|
47
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
onError = defaultOnError,
|
|
23
|
+
fallback,
|
|
24
|
+
hydrate: allowHydrate = true,
|
|
25
|
+
} = options
|
|
48
26
|
|
|
49
27
|
const api = { ...store._api }
|
|
50
28
|
api.render = createRender(api)
|
|
51
29
|
|
|
52
|
-
const shouldHydrate = element.hasChildNodes()
|
|
30
|
+
const shouldHydrate = allowHydrate && element.hasChildNodes()
|
|
53
31
|
|
|
54
32
|
// If we need to hydrate, load the heavy lifting only now
|
|
55
33
|
if (shouldHydrate) {
|
|
@@ -78,6 +56,32 @@ export async function mount(store, renderFn, element, options = {}) {
|
|
|
78
56
|
return unsubscribe
|
|
79
57
|
}
|
|
80
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Root-level error boundary. Unlike the per-entity `withErrorBoundary`
|
|
61
|
+
* decorator (which isolates a single failing type's render), this catches
|
|
62
|
+
* errors thrown by the *root* render function itself — before any entity is
|
|
63
|
+
* reached (e.g. a missing router entity), or by an unguarded child.
|
|
64
|
+
*
|
|
65
|
+
* Without it, a throwing root render takes down the whole app: on the initial
|
|
66
|
+
* pass it aborts the mount, and inside the store subscription it throws out of
|
|
67
|
+
* the notify loop on every subsequent update, freezing the UI. Catching it
|
|
68
|
+
* keeps the subscription alive so one bad tick can't kill the app.
|
|
69
|
+
*
|
|
70
|
+
* @param {(api: Api) => TemplateResult | null} renderFn
|
|
71
|
+
* @param {Api} api
|
|
72
|
+
* @param {(error: unknown, api: Api) => void} onError
|
|
73
|
+
* @param {((error: unknown, api: Api) => TemplateResult | null) | undefined} fallback
|
|
74
|
+
* @returns {{ ok: true, template: TemplateResult | null } | { ok: false, fallback: TemplateResult | null }}
|
|
75
|
+
*/
|
|
76
|
+
function renderRoot(renderFn, api, onError, fallback) {
|
|
77
|
+
try {
|
|
78
|
+
return { ok: true, template: renderFn(api) }
|
|
79
|
+
} catch (error) {
|
|
80
|
+
onError(error, api)
|
|
81
|
+
return { ok: false, fallback: fallback ? fallback(error, api) : null }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
81
85
|
/**
|
|
82
86
|
* Default root-error handler: log without taking the app down.
|
|
83
87
|
* @param {unknown} error - The error thrown by the root render function.
|
|
@@ -3,8 +3,7 @@ import { Api } from "../mount"
|
|
|
3
3
|
export interface DebounceBehavior {
|
|
4
4
|
destroy?: (entity: any, payload?: any, api?: Api) => void
|
|
5
5
|
[handlerName: string]:
|
|
6
|
-
|
|
7
|
-
| undefined
|
|
6
|
+
((entity: any, payload?: any, api?: Api) => void) | undefined
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
export declare function withDebounce(
|
|
@@ -7,8 +7,7 @@ export interface ThrottleOptions {
|
|
|
7
7
|
export interface ThrottleBehavior {
|
|
8
8
|
destroy?: (entity: any, payload?: any, api?: Api) => void
|
|
9
9
|
[handlerName: string]:
|
|
10
|
-
|
|
11
|
-
| undefined
|
|
10
|
+
((entity: any, payload?: any, api?: Api) => void) | undefined
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export declare function withThrottle(
|