@jscutlery/microwave 0.1.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.
@@ -0,0 +1,6 @@
1
+ import { Observable } from 'rxjs';
2
+ import { IvyComponentType } from './shared/decorator';
3
+ export declare function Microwave({ strategy }?: {
4
+ strategy?: import("@jscutlery/microwave").Strategy<unknown> | undefined;
5
+ }): <T>(componentType: IvyComponentType<T>) => void;
6
+ export declare function watch<T, K extends keyof T = keyof T>(component: T, property: K): Observable<T[K] | undefined>;
@@ -0,0 +1,47 @@
1
+ import { Type } from '@angular/core';
2
+ import { ChangeDetectionFns } from '../core/change-detection-fns';
3
+ /**
4
+ * Decorate Angular components with custom hooks.
5
+ *
6
+ * @param componentType the component class to decorate.
7
+ * @param hooks
8
+ */
9
+ export declare function decorateComponent<T, K extends keyof T = keyof T>(componentType: IvyComponentType<T>, hooks: DecoratorHooks<T>): void;
10
+ export interface DecoratorHooks<T, K extends keyof T = keyof T> {
11
+ /**
12
+ * Hook called when a new component is created.
13
+ *
14
+ * @param component the created component.
15
+ * @param args change detection functions for controlling change detection.
16
+ */
17
+ onCreate(component: T, args: ChangeDetectionFns): void;
18
+ /**
19
+ * Hook called when a new component is initialized.
20
+ *
21
+ * @param component the created component.
22
+ */
23
+ onInit(component: T): void;
24
+ /**
25
+ * Hook called just before the real ngOnDestroy (if implemented) is called.
26
+ */
27
+ onDestroy(component: T): void;
28
+ /**
29
+ * Hook called when a property is discovered.
30
+ * This is the opportunity to grab the initial value before
31
+ * the property is replaced by getters and setters.
32
+ */
33
+ onPropertyDeclare(component: T, property: K, value: T[K]): void;
34
+ /**
35
+ * Hook called to retrieve a property.
36
+ */
37
+ onPropertyGet(component: T, property: K): T[K] | undefined;
38
+ /**
39
+ * Hook called to set a property.
40
+ */
41
+ onPropertySet(component: T, property: K, value: T[K]): void;
42
+ }
43
+ export interface IvyComponentType<T> extends Type<T> {
44
+ ɵfac?: () => T;
45
+ }
46
+ export declare function _spyOnMethod<T>(klass: Type<T>, methodName: string, callback: (instance: T) => void): void;
47
+ export declare function _decorate<F extends (...args: any[]) => any>(fn: F, decorator: (fn: F) => F): F;
@@ -0,0 +1,5 @@
1
+ import { Strategy } from '../devkit';
2
+ /**
3
+ * A strategy that coalesces changes using microtask scheduling.
4
+ */
5
+ export declare const asapStrategy: Strategy<unknown>;
@@ -0,0 +1,5 @@
1
+ import { Strategy } from '../devkit';
2
+ /**
3
+ * A strategy that coalesces changes using macrotask scheduling.
4
+ */
5
+ export declare const asyncStrategy: Strategy<unknown>;
@@ -0,0 +1,5 @@
1
+ export { createLocalStrategy } from './local';
2
+ export { syncStrategy } from './sync';
3
+ export { asapStrategy } from './asap';
4
+ export { asyncStrategy } from './async';
5
+ export { rafStrategy } from './raf';
@@ -0,0 +1,14 @@
1
+ import { MonoTypeOperatorFunction } from 'rxjs';
2
+ import { Strategy } from '../devkit';
3
+ /**
4
+ * Creates a change detection strategy which is local to the component.
5
+ * It implements optional coalescing which can be customized using `coalescer` parameter.
6
+ *
7
+ * @example createLocalStrategy()
8
+ * @example createLocalStrategy({coalescer: audit(() => Promise.resolve())})
9
+ *
10
+ * @returns a strategy that can be used with Microwave decorator.
11
+ */
12
+ export declare const createLocalStrategy: ({ coalescer, }?: {
13
+ coalescer?: MonoTypeOperatorFunction<void> | undefined;
14
+ }) => Strategy<unknown>;
@@ -0,0 +1,5 @@
1
+ import { Strategy } from '../devkit';
2
+ /**
3
+ * A strategy that coalesces changes using requestAnimationFrame scheduler.
4
+ */
5
+ export declare const rafStrategy: Strategy<unknown>;
@@ -0,0 +1,2 @@
1
+ import { Strategy } from '../devkit';
2
+ export declare const syncStrategy: Strategy<unknown>;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@jscutlery/microwave",
3
+ "version": "0.1.0",
4
+ "peerDependencies": {
5
+ "@angular/common": "^13.0.0",
6
+ "@angular/core": "^13.0.0",
7
+ "rxjs": "^7.0.0",
8
+ "@jscutlery/cypress-angular": "0.9.0",
9
+ "@jscutlery/cypress-mount": "0.12.0",
10
+ "@angular/platform-browser": "13.0.3",
11
+ "@angular/platform-browser-dynamic": "13.0.3",
12
+ "zone.js": "~0.11.4",
13
+ "@jscutlery/cypress-angular-dev-server": "1.7.3"
14
+ },
15
+ "dependencies": {
16
+ "tslib": "^2.3.0"
17
+ },
18
+ "module": "fesm2015/jscutlery-microwave.mjs",
19
+ "es2020": "fesm2020/jscutlery-microwave.mjs",
20
+ "esm2020": "esm2020/jscutlery-microwave.mjs",
21
+ "fesm2020": "fesm2020/jscutlery-microwave.mjs",
22
+ "fesm2015": "fesm2015/jscutlery-microwave.mjs",
23
+ "typings": "jscutlery-microwave.d.ts",
24
+ "exports": {
25
+ "./package.json": {
26
+ "default": "./package.json"
27
+ },
28
+ ".": {
29
+ "types": "./jscutlery-microwave.d.ts",
30
+ "esm2020": "./esm2020/jscutlery-microwave.mjs",
31
+ "es2020": "./fesm2020/jscutlery-microwave.mjs",
32
+ "es2015": "./fesm2015/jscutlery-microwave.mjs",
33
+ "node": "./fesm2015/jscutlery-microwave.mjs",
34
+ "default": "./fesm2020/jscutlery-microwave.mjs"
35
+ }
36
+ },
37
+ "sideEffects": false
38
+ }