element-vir 26.14.0 → 26.14.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/dist/declarative-element/directives/render-async.directive.d.ts +23 -4
- package/dist/declarative-element/directives/render-async.directive.js +6 -3
- package/dist/declarative-element/is-declarative-element-definition.d.ts +2 -4
- package/dist/declarative-element/is-declarative-element-definition.js +2 -4
- package/dist/lit-exports/base-lit-exports.d.ts +2 -2
- package/dist/lit-exports/base-lit-exports.js +1 -1
- package/dist/lit-exports/lit-repeat-fix.d.ts +1 -1
- package/package.json +11 -11
|
@@ -1,4 +1,23 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
1
2
|
import { type AsyncProp } from './async-prop.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link renderAsync}.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export type RenderAsyncOptions = PartialWithUndefined<{
|
|
9
|
+
/**
|
|
10
|
+
* When set to `true`, uses `lastResolvedValue` instead of `value` from the async prop. This is
|
|
11
|
+
* useful when you want to keep showing the last resolved value while a new promise is pending.
|
|
12
|
+
*/
|
|
13
|
+
useLastResolvedValue: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Properties from AsyncProp used by {@link renderAsync}.
|
|
17
|
+
*
|
|
18
|
+
* @category Internal
|
|
19
|
+
*/
|
|
20
|
+
export type RenderAsyncPropInput<T> = Pick<AsyncProp<T, any>, 'value' | 'lastResolvedValue'>;
|
|
2
21
|
/**
|
|
3
22
|
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
|
|
4
23
|
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
|
|
@@ -9,7 +28,7 @@ import { type AsyncProp } from './async-prop.js';
|
|
|
9
28
|
*
|
|
10
29
|
* @category Async
|
|
11
30
|
*/
|
|
12
|
-
export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp:
|
|
31
|
+
export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: RenderAsyncPropInput<T>, fallback: FallbackResult, resolutionRender: (resolved: Awaited<T>) => ResolutionRenderResult, errorRender: (error: Error) => ErrorRenderResult, options?: RenderAsyncOptions): FallbackResult | ResolutionRenderResult | ErrorRenderResult;
|
|
13
32
|
/**
|
|
14
33
|
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
|
|
15
34
|
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
|
|
@@ -20,7 +39,7 @@ export declare function renderAsync<T, FallbackResult, ResolutionRenderResult =
|
|
|
20
39
|
*
|
|
21
40
|
* @category Async
|
|
22
41
|
*/
|
|
23
|
-
export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never>(asyncProp:
|
|
42
|
+
export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never>(asyncProp: RenderAsyncPropInput<T>, fallback: FallbackResult, resolutionRender: (resolved: Awaited<T>) => ResolutionRenderResult, errorRender?: undefined, options?: RenderAsyncOptions): FallbackResult | ResolutionRenderResult | string;
|
|
24
43
|
/**
|
|
25
44
|
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
|
|
26
45
|
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
|
|
@@ -31,7 +50,7 @@ export declare function renderAsync<T, FallbackResult, ResolutionRenderResult =
|
|
|
31
50
|
*
|
|
32
51
|
* @category Async
|
|
33
52
|
*/
|
|
34
|
-
export declare function renderAsync<T, FallbackResult, ErrorRenderResult = never>(asyncProp:
|
|
53
|
+
export declare function renderAsync<T, FallbackResult, ErrorRenderResult = never>(asyncProp: RenderAsyncPropInput<T>, fallback: FallbackResult, resolutionRender: undefined, errorRender: (error: Error) => ErrorRenderResult, options?: RenderAsyncOptions): FallbackResult | Awaited<T> | ErrorRenderResult;
|
|
35
54
|
/**
|
|
36
55
|
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
|
|
37
56
|
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
|
|
@@ -42,4 +61,4 @@ export declare function renderAsync<T, FallbackResult, ErrorRenderResult = never
|
|
|
42
61
|
*
|
|
43
62
|
* @category Async
|
|
44
63
|
*/
|
|
45
|
-
export declare function renderAsync<T, FallbackResult>(asyncProp:
|
|
64
|
+
export declare function renderAsync<T, FallbackResult>(asyncProp: RenderAsyncPropInput<T>, fallback: FallbackResult, resolutionRender?: undefined, errorRender?: undefined, options?: RenderAsyncOptions): FallbackResult | Awaited<T> | string;
|
|
@@ -12,15 +12,18 @@ import { extractErrorMessage } from '@augment-vir/common';
|
|
|
12
12
|
*/
|
|
13
13
|
export function renderAsync(asyncProp,
|
|
14
14
|
/** This value will be rendered if the async prop has not settled yet. */
|
|
15
|
-
fallback, resolutionRender, errorRender) {
|
|
16
|
-
const asyncPropValue =
|
|
15
|
+
fallback, resolutionRender, errorRender, options = {}) {
|
|
16
|
+
const asyncPropValue = options.useLastResolvedValue
|
|
17
|
+
? asyncProp.lastResolvedValue
|
|
18
|
+
: asyncProp.value;
|
|
17
19
|
if (asyncPropValue instanceof Error) {
|
|
18
20
|
const errorResult = errorRender
|
|
19
21
|
? errorRender(asyncPropValue)
|
|
20
22
|
: extractErrorMessage(asyncPropValue);
|
|
21
23
|
return errorResult;
|
|
22
24
|
}
|
|
23
|
-
else if (check.isPromiseLike(asyncPropValue)
|
|
25
|
+
else if (check.isPromiseLike(asyncPropValue) ||
|
|
26
|
+
(options.useLastResolvedValue && asyncPropValue === undefined)) {
|
|
24
27
|
const fallbackResult = fallback;
|
|
25
28
|
return fallbackResult;
|
|
26
29
|
}
|
|
@@ -3,15 +3,13 @@ import { type DeclarativeElementDefinition } from './declarative-element.js';
|
|
|
3
3
|
* Asserts that the given input is a declarative element definition.
|
|
4
4
|
*
|
|
5
5
|
* @category Util
|
|
6
|
-
* @see
|
|
7
|
-
* - {@link isDeclarativeElementDefinition}
|
|
6
|
+
* @see {@link isDeclarativeElementDefinition}
|
|
8
7
|
*/
|
|
9
8
|
export declare function assertDeclarativeElementDefinition(input: unknown, failMessage?: string | undefined): asserts input is DeclarativeElementDefinition;
|
|
10
9
|
/**
|
|
11
10
|
* Checks that the given input is a declarative element definition.
|
|
12
11
|
*
|
|
13
12
|
* @category Util
|
|
14
|
-
* @see
|
|
15
|
-
* - {@link assertDeclarativeElementDefinition}
|
|
13
|
+
* @see {@link assertDeclarativeElementDefinition}
|
|
16
14
|
*/
|
|
17
15
|
export declare function isDeclarativeElementDefinition(input: unknown): input is DeclarativeElementDefinition;
|
|
@@ -21,8 +21,7 @@ const expectedStaticProperties = getObjectTypedKeys({
|
|
|
21
21
|
* Asserts that the given input is a declarative element definition.
|
|
22
22
|
*
|
|
23
23
|
* @category Util
|
|
24
|
-
* @see
|
|
25
|
-
* - {@link isDeclarativeElementDefinition}
|
|
24
|
+
* @see {@link isDeclarativeElementDefinition}
|
|
26
25
|
*/
|
|
27
26
|
export function assertDeclarativeElementDefinition(input, failMessage) {
|
|
28
27
|
if (!check.isFunction(input)) {
|
|
@@ -38,8 +37,7 @@ export function assertDeclarativeElementDefinition(input, failMessage) {
|
|
|
38
37
|
* Checks that the given input is a declarative element definition.
|
|
39
38
|
*
|
|
40
39
|
* @category Util
|
|
41
|
-
* @see
|
|
42
|
-
* - {@link assertDeclarativeElementDefinition}
|
|
40
|
+
* @see {@link assertDeclarativeElementDefinition}
|
|
43
41
|
*/
|
|
44
42
|
export function isDeclarativeElementDefinition(input) {
|
|
45
43
|
return wrapInTry(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { LitElement, noChange, nothing, svg, unsafeCSS } from 'lit';
|
|
2
|
-
export type {
|
|
1
|
+
export { CSSResult, LitElement, noChange, nothing, svg, unsafeCSS } from 'lit';
|
|
2
|
+
export type { CSSResultGroup, CompiledTemplate, CompiledTemplateResult, HTMLTemplateResult, SVGTemplateResult, TemplateResult, } from 'lit';
|
|
3
3
|
export * from 'lit/async-directive.js';
|
|
4
4
|
export * from 'lit/decorators.js';
|
|
5
5
|
export * from 'lit/directive-helpers.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { LitElement, noChange, nothing, svg, unsafeCSS } from 'lit';
|
|
1
|
+
export { CSSResult, LitElement, noChange, nothing, svg, unsafeCSS } from 'lit';
|
|
2
2
|
export * from 'lit/async-directive.js';
|
|
3
3
|
export * from 'lit/decorators.js';
|
|
4
4
|
export * from 'lit/directive-helpers.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { KeyFn } from 'lit/directives/repeat.js';
|
|
2
2
|
export type { RepeatDirective };
|
|
3
|
+
import { type ChildPart, type noChange } from 'lit-html';
|
|
3
4
|
import { type Directive, type PartInfo } from 'lit-html/directive.js';
|
|
4
5
|
import { type KeyFn } from 'lit-html/directives/repeat.js';
|
|
5
|
-
import { type ChildPart, type noChange } from 'lit-html/lit-html.js';
|
|
6
6
|
import { type HtmlInterpolation } from '../template-transforms/vir-html/html-interpolation.js';
|
|
7
7
|
/**
|
|
8
8
|
* A modified class type for the built-in lit `repeat` directive which works for element-vir
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "26.14.
|
|
3
|
+
"version": "26.14.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"test:docs": "virmator docs check"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/assert": "^31.
|
|
43
|
-
"@augment-vir/common": "^31.
|
|
42
|
+
"@augment-vir/assert": "^31.59.0",
|
|
43
|
+
"@augment-vir/common": "^31.59.0",
|
|
44
44
|
"date-vir": "^8.1.0",
|
|
45
45
|
"lit": "^3.3.2",
|
|
46
|
-
"lit-css-vars": "^3.
|
|
46
|
+
"lit-css-vars": "^3.1.1",
|
|
47
47
|
"lit-html": "^3.3.2",
|
|
48
48
|
"object-shape-tester": "^6.11.0",
|
|
49
|
-
"observavir": "^2.3.
|
|
49
|
+
"observavir": "^2.3.1",
|
|
50
50
|
"typed-event-target": "^4.1.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@augment-vir/test": "^31.
|
|
54
|
-
"@augment-vir/web": "^31.
|
|
53
|
+
"@augment-vir/test": "^31.59.0",
|
|
54
|
+
"@augment-vir/web": "^31.59.0",
|
|
55
55
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
56
56
|
"@web/test-runner": "^0.20.2",
|
|
57
57
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"html-spec-tags": "^2.2.3",
|
|
61
61
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
62
62
|
"markdown-code-example-inserter": "^3.0.3",
|
|
63
|
-
"type-fest": "^5.
|
|
64
|
-
"typedoc": "^0.28.
|
|
63
|
+
"type-fest": "^5.4.1",
|
|
64
|
+
"typedoc": "^0.28.16",
|
|
65
65
|
"typescript": "5.9.3",
|
|
66
|
-
"vite": "^7.3.
|
|
67
|
-
"vite-tsconfig-paths": "^6.0.
|
|
66
|
+
"vite": "^7.3.1",
|
|
67
|
+
"vite-tsconfig-paths": "^6.0.4"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=22"
|