element-vir 16.4.0 → 16.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.
@@ -11,6 +11,7 @@ export type CleanupCallback<T> = (oldValue: T) => void;
11
11
  * Example use case: 3D graphics applications with classes that setup buffers and the like.
12
12
  */
13
13
  export declare function assignWithCleanup<DeclarativeElementGeneric extends ElementDefinitionWithInputsType>(elementDefinition: DeclarativeElementGeneric, inputsObject: DeclarativeElementGeneric extends ElementDefinitionWithInputsType<infer InputsGeneric> ? InputsGeneric : never, cleanupCallback: CleanupCallback<DeclarativeElementGeneric extends ElementDefinitionWithInputsType<infer InputsGeneric> ? InputsGeneric : never>): import("lit-html/directive").DirectiveResult<typeof AssignWithCleanupDirectiveClass>;
14
+ /** @internal */
14
15
  declare class AssignWithCleanupDirectiveClass extends AsyncDirective {
15
16
  private readonly element;
16
17
  private lastValue;
@@ -18,6 +18,7 @@ export function assignWithCleanup(elementDefinition, inputsObject, cleanupCallba
18
18
  */
19
19
  return assignWithCleanupDirective(elementDefinition, inputsObject, cleanupCallback);
20
20
  }
21
+ /** @internal */
21
22
  class AssignWithCleanupDirectiveClass extends AsyncDirective {
22
23
  constructor(partInfo) {
23
24
  super(partInfo);
@@ -1,12 +1,12 @@
1
- import { JsonCompatibleObject, MaybePromise, UnPromise } from '@augment-vir/common';
1
+ import { JsonCompatibleObject, MaybePromise } from '@augment-vir/common';
2
2
  import { ElementVirStateSetup } from '../properties/element-vir-state-setup';
3
3
  import { ObservableProperty } from '../properties/observable-property/observable-property';
4
- export type AsyncPropValue<ValueType> = Error | MaybePromise<ValueType>;
4
+ export type AsyncPropValue<ValueType> = Error | MaybePromise<Awaited<ValueType>>;
5
5
  export type AsyncPropTriggerInputBase = JsonCompatibleObject;
6
6
  export type AsyncPropUpdateCallback<TriggerInput extends AsyncPropTriggerInputBase, UpdaterInput, ReturnType> = Exclude<TriggerInput, undefined> extends never ? () => ReturnType : Exclude<UpdaterInput, undefined> extends never ? (trigger: TriggerInput) => ReturnType : (trigger: TriggerInput, inputs: UpdaterInput) => ReturnType;
7
7
  export type AsyncPropInit<ValueType, TriggerInput extends AsyncPropTriggerInputBase, UpdaterInput> = {
8
8
  /** Starting value */
9
- defaultValue: MaybePromise<ValueType>;
9
+ defaultValue: MaybePromise<Awaited<ValueType>>;
10
10
  } | {
11
11
  /**
12
12
  * When a trigger changes (according to deep equality checking through JSON stringify),
@@ -16,12 +16,12 @@ export type AsyncPropInit<ValueType, TriggerInput extends AsyncPropTriggerInputB
16
16
  * Set this to undefined to disabled automatic updating. Meaning, updateCallback will only
17
17
  * be called the first time.
18
18
  */
19
- updateCallback: AsyncPropUpdateCallback<TriggerInput, UpdaterInput, Promise<UnPromise<ValueType>>>;
19
+ updateCallback: AsyncPropUpdateCallback<TriggerInput, UpdaterInput, Promise<Awaited<ValueType>>>;
20
20
  };
21
21
  export type AsyncObservableProperty<ValueType, TriggerInput extends AsyncPropTriggerInputBase, UpdaterInput> = ObservableProperty<AsyncPropValue<ValueType>> & {
22
- setNewPromise(newPromise: Promise<UnPromise<ValueType>>): void;
22
+ setNewPromise(newPromise: Promise<Awaited<ValueType>>): void;
23
23
  updateTrigger: AsyncPropUpdateCallback<TriggerInput, UpdaterInput, void>;
24
- setResolvedValue(resolvedValue: UnPromise<ValueType>): void;
24
+ setResolvedValue(resolvedValue: Awaited<ValueType>): void;
25
25
  /**
26
26
  * Forces the updater callback to re-run with the last given trigger and updaterInput. If this
27
27
  * asyncProp has no updater callback defined, this will result in an error.
@@ -2,7 +2,9 @@ import { noChange } from 'lit';
2
2
  import { directive, Directive } from 'lit/directive.js';
3
3
  import { extractElement } from './directive-helpers';
4
4
  export function createAttributeDirective(attributeName) {
5
- const newDirective = directive(class extends Directive {
5
+ const newDirective = directive(
6
+ /** @internal */
7
+ class extends Directive {
6
8
  constructor(partInfo) {
7
9
  super(partInfo);
8
10
  this.element = extractElement(partInfo, 'testId');
@@ -1,5 +1,4 @@
1
- import { UnPromise } from '@augment-vir/common';
2
1
  import { AsyncPropValue } from './async-prop';
3
- export declare function isRenderReady<T>(asyncPropInput: AsyncPropValue<T>): asyncPropInput is UnPromise<T>;
2
+ export declare function isRenderReady<T>(asyncPropInput: AsyncPropValue<T>): asyncPropInput is Awaited<T>;
4
3
  export declare function isResolved<T>(asyncPropInput: AsyncPropValue<T>): asyncPropInput is Exclude<AsyncPropValue<T>, Promise<T>>;
5
- export declare function readyOrUndefined<T>(asyncPropInput: AsyncPropValue<T>): UnPromise<T> | undefined;
4
+ export declare function readyOrUndefined<T>(asyncPropInput: AsyncPropValue<T>): Awaited<T> | undefined;
@@ -2,7 +2,9 @@ import { directive, Directive } from 'lit/directive.js';
2
2
  import { assertIsElementPartInfo } from './directive-helpers';
3
3
  const directiveName = 'onDomCreated';
4
4
  /** Only fires once, when the element has been created. */
5
- export const onDomCreated = directive(class extends Directive {
5
+ export const onDomCreated = directive(
6
+ /** @internal */
7
+ class extends Directive {
6
8
  constructor(partInfo) {
7
9
  super(partInfo);
8
10
  assertIsElementPartInfo(partInfo, directiveName);
@@ -1,7 +1,9 @@
1
1
  import { directive, Directive } from 'lit/directive.js';
2
2
  import { assertIsElementPartInfo } from './directive-helpers';
3
3
  const directiveName = 'onResize';
4
- export const onResize = directive(class extends Directive {
4
+ export const onResize = directive(
5
+ /** @internal */
6
+ class extends Directive {
5
7
  constructor(partInfo) {
6
8
  super(partInfo);
7
9
  this.resizeObserver = new ResizeObserver((entries) => this.fireCallback(entries));
@@ -1,6 +1,5 @@
1
- import { UnPromise } from '@augment-vir/common';
2
1
  import { AsyncObservableProperty } from './async-prop';
3
- export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender: (resolved: UnPromise<T>) => ResolutionRenderResult, errorRender: (error: Error) => ErrorRenderResult): FallbackResult | ResolutionRenderResult | ErrorRenderResult;
4
- export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender: (resolved: UnPromise<T>) => ResolutionRenderResult, errorRender?: undefined): FallbackResult | ResolutionRenderResult | string;
5
- export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender: undefined, errorRender: (error: Error) => ErrorRenderResult): FallbackResult | UnPromise<T> | ErrorRenderResult;
6
- export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender?: undefined, errorRender?: undefined): FallbackResult | UnPromise<T> | string;
2
+ export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender: (resolved: Awaited<T>) => ResolutionRenderResult, errorRender: (error: Error) => ErrorRenderResult): FallbackResult | ResolutionRenderResult | ErrorRenderResult;
3
+ export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender: (resolved: Awaited<T>) => ResolutionRenderResult, errorRender?: undefined): FallbackResult | ResolutionRenderResult | string;
4
+ export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender: undefined, errorRender: (error: Error) => ErrorRenderResult): FallbackResult | Awaited<T> | ErrorRenderResult;
5
+ export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: AsyncObservableProperty<T, any, any>, fallback: FallbackResult, resolutionRender?: undefined, errorRender?: undefined): FallbackResult | Awaited<T> | string;
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './declarative-element/properties/css-properties';
22
22
  export * from './declarative-element/properties/css-vars';
23
23
  export * from './declarative-element/properties/element-events';
24
24
  export * from './declarative-element/properties/element-properties';
25
+ export * from './declarative-element/properties/element-vir-state-setup';
25
26
  export * from './declarative-element/properties/host-classes';
26
27
  export * from './declarative-element/properties/observable-property/create-observable-property';
27
28
  export * from './declarative-element/properties/observable-property/observable-property';
@@ -31,7 +32,9 @@ export * from './declarative-element/properties/tag-name';
31
32
  export * from './declarative-element/render-callback';
32
33
  export * from './declarative-element/wrap-define-element';
33
34
  export { requireAllCustomElementsToBeDeclarativeElements } from './require-declarative-element';
35
+ export * from './template-transforms/minimal-element-definition';
34
36
  export * from './template-transforms/vir-css/vir-css';
35
37
  export * from './template-transforms/vir-html/vir-html';
36
38
  export * from './typed-event/typed-event';
37
39
  export * from './util/lit-template';
40
+ export * from './util/type';
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ export * from './declarative-element/properties/css-properties';
21
21
  export * from './declarative-element/properties/css-vars';
22
22
  export * from './declarative-element/properties/element-events';
23
23
  export * from './declarative-element/properties/element-properties';
24
+ export * from './declarative-element/properties/element-vir-state-setup';
24
25
  export * from './declarative-element/properties/host-classes';
25
26
  export * from './declarative-element/properties/observable-property/create-observable-property';
26
27
  export * from './declarative-element/properties/observable-property/observable-property';
@@ -30,7 +31,9 @@ export * from './declarative-element/properties/tag-name';
30
31
  export * from './declarative-element/render-callback';
31
32
  export * from './declarative-element/wrap-define-element';
32
33
  export { requireAllCustomElementsToBeDeclarativeElements } from './require-declarative-element';
34
+ export * from './template-transforms/minimal-element-definition';
33
35
  export * from './template-transforms/vir-css/vir-css';
34
36
  export * from './template-transforms/vir-html/vir-html';
35
37
  export * from './typed-event/typed-event';
36
38
  export * from './util/lit-template';
39
+ export * from './util/type';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "element-vir",
3
- "version": "16.4.0",
3
+ "version": "16.4.2",
4
4
  "keywords": [
5
5
  "custom",
6
6
  "web",
@@ -26,33 +26,33 @@
26
26
  "types": "dist/index.d.ts",
27
27
  "scripts": {
28
28
  "compile": "rm -rf dist && tsc --project tsconfig.json",
29
- "docs:update": "virmator code-in-markdown",
29
+ "docs": "virmator docs",
30
30
  "format": "virmator format",
31
31
  "publish": "virmator publish \"npm run compile && npm run test:all\"",
32
32
  "start": "npm install && virmator frontend",
33
33
  "test": "virmator test-web",
34
34
  "test:all": "concurrently -c auto --kill-others-on-fail --colors --names types,tests,spelling,format,docs \"npm run test:types\" \"npm run test:coverage\" \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\"",
35
35
  "test:coverage": "virmator test-web coverage",
36
- "test:docs": "virmator code-in-markdown check",
36
+ "test:docs": "virmator docs check",
37
37
  "test:format": "virmator format check",
38
38
  "test:spelling": "virmator spellcheck",
39
39
  "test:types": "tsc --noEmit"
40
40
  },
41
41
  "dependencies": {
42
- "@augment-vir/browser": "^19.0.0",
43
- "@augment-vir/common": "^19.0.0",
42
+ "@augment-vir/browser": "^19.4.1",
43
+ "@augment-vir/common": "^19.4.1",
44
44
  "lit": "2.8.0",
45
45
  "lit-css-vars": "^3.0.1",
46
46
  "object-shape-tester": "^0.4.3",
47
47
  "run-time-assertions": "^0.0.2"
48
48
  },
49
49
  "devDependencies": {
50
- "@augment-vir/browser-testing": "^19.0.0",
51
- "@augment-vir/node-js": "^19.0.0",
50
+ "@augment-vir/browser-testing": "^19.4.1",
51
+ "@augment-vir/node-js": "^19.4.1",
52
52
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
53
53
  "@open-wc/testing": "^3.2.0",
54
54
  "@types/chai": "^4.3.6",
55
- "@types/mocha": "^10.0.1",
55
+ "@types/mocha": "^10.0.2",
56
56
  "@web/dev-server-esbuild": "^0.4.1",
57
57
  "@web/test-runner": "^0.17.1",
58
58
  "@web/test-runner-commands": "^0.8.0",
@@ -60,11 +60,11 @@
60
60
  "@web/test-runner-visual-regression": "^0.8.2",
61
61
  "ansi-colors": "^4.1.3",
62
62
  "concurrently": "^8.2.1",
63
- "cspell": "^7.3.6",
63
+ "cspell": "^7.3.7",
64
64
  "element-book": "^10.1.2",
65
- "esbuild": "^0.19.3",
65
+ "esbuild": "^0.19.4",
66
66
  "istanbul-smart-text-reporter": "^1.1.2",
67
- "markdown-code-example-inserter": "^0.3.1",
67
+ "markdown-code-example-inserter": "^0.3.2",
68
68
  "mocha-spec-reporter-with-file-names": "^0.0.3",
69
69
  "npm-check-updates": "~16.12.3",
70
70
  "nyc": "^15.1.0",
@@ -73,14 +73,15 @@
73
73
  "prettier-plugin-jsdoc": "^0.4.2",
74
74
  "prettier-plugin-multiline-arrays": "^2.0.0",
75
75
  "prettier-plugin-organize-imports": "^3.2.3",
76
- "prettier-plugin-packagejson": "^2.4.5",
76
+ "prettier-plugin-packagejson": "^2.4.6",
77
77
  "prettier-plugin-sort-json": "^2.0.0",
78
78
  "prettier-plugin-toml": "^0.3.1",
79
79
  "ts-node": "^10.9.1",
80
- "type-fest": "^4.3.1",
80
+ "type-fest": "^4.3.3",
81
+ "typedoc": "^0.25.1",
81
82
  "typescript": "~5.2.2",
82
- "virmator": "^7.4.1",
83
- "vite": "^4.4.9",
83
+ "virmator": "^8.0.5",
84
+ "vite": "^4.4.10",
84
85
  "vite-tsconfig-paths": "^4.2.1"
85
86
  },
86
87
  "overrides": {