@rs-x/angular 0.4.6 → 0.4.8
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, APP_INITIALIZER,
|
|
3
|
-
import { InjectionContainer } from '@rs-x/core';
|
|
4
|
-
import { RsXExpressionParserInjectionTokens, RsXExpressionParserModule } from '@rs-x/expression-parser';
|
|
2
|
+
import { InjectionToken, APP_INITIALIZER, inject, ChangeDetectorRef, Pipe } from '@angular/core';
|
|
3
|
+
import { InjectionContainer, Type, UnsupportedException } from '@rs-x/core';
|
|
4
|
+
import { RsXExpressionParserInjectionTokens, RsXExpressionParserModule, AbstractExpression } from '@rs-x/expression-parser';
|
|
5
5
|
|
|
6
6
|
const IExpressionFactoryToken = new InjectionToken('IExpressionFactoryProvider');
|
|
7
7
|
function initializeRsx() {
|
|
@@ -12,37 +12,19 @@ function initializeRsx() {
|
|
|
12
12
|
return InjectionContainer.load(RsXExpressionParserModule);
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
] });
|
|
15
|
+
function providexRsx() {
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
provide: APP_INITIALIZER,
|
|
19
|
+
useFactory: initializeRsx,
|
|
20
|
+
multi: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
provide: IExpressionFactoryToken,
|
|
24
|
+
useFactory: () => InjectionContainer.get(RsXExpressionParserInjectionTokens.IExpressionFactory)
|
|
25
|
+
}
|
|
26
|
+
];
|
|
29
27
|
}
|
|
30
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxModule, decorators: [{
|
|
31
|
-
type: NgModule,
|
|
32
|
-
args: [{
|
|
33
|
-
providers: [
|
|
34
|
-
{
|
|
35
|
-
provide: APP_INITIALIZER,
|
|
36
|
-
useFactory: initializeRsx,
|
|
37
|
-
multi: true
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
provide: IExpressionFactoryToken,
|
|
41
|
-
useFactory: () => InjectionContainer.get(RsXExpressionParserInjectionTokens.IExpressionFactory)
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
}]
|
|
45
|
-
}] });
|
|
46
28
|
|
|
47
29
|
class RsxPipe {
|
|
48
30
|
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
@@ -52,24 +34,39 @@ class RsxPipe {
|
|
|
52
34
|
_lastExpressionString;
|
|
53
35
|
_lastContext;
|
|
54
36
|
_value;
|
|
55
|
-
transform(
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
if (expressionString !== this._lastExpressionString ||
|
|
37
|
+
transform(expression, context) {
|
|
38
|
+
if ((expression instanceof AbstractExpression && this._expression !== expression) ||
|
|
39
|
+
expression !== this._lastExpressionString ||
|
|
60
40
|
context !== this._lastContext) {
|
|
61
41
|
this.disposeExpression();
|
|
62
|
-
this.createExpression(
|
|
42
|
+
this.createExpression(expression, context);
|
|
63
43
|
}
|
|
64
44
|
return this._value;
|
|
65
45
|
}
|
|
66
46
|
ngOnDestroy() {
|
|
67
47
|
this.disposeExpression();
|
|
68
48
|
}
|
|
69
|
-
createExpression(
|
|
70
|
-
|
|
49
|
+
createExpression(expression, context) {
|
|
50
|
+
if (expression instanceof AbstractExpression) {
|
|
51
|
+
this._lastExpressionString = undefined;
|
|
52
|
+
this._expression = expression;
|
|
53
|
+
}
|
|
54
|
+
else if (Type.isString(expression)) {
|
|
55
|
+
this._lastExpressionString = expression;
|
|
56
|
+
if (context) {
|
|
57
|
+
this._expression = this._expressionFactory.create(context, expression);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (!Type.isNullOrUndefined(expression)) {
|
|
61
|
+
throw new UnsupportedException(`string or IExpression expected`);
|
|
62
|
+
}
|
|
71
63
|
this._lastContext = context;
|
|
72
|
-
this.
|
|
64
|
+
this.tryToSubscribeToExpression();
|
|
65
|
+
}
|
|
66
|
+
tryToSubscribeToExpression() {
|
|
67
|
+
if (!this._expression) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
73
70
|
this._changedSubscription = this._expression.changed.subscribe(() => {
|
|
74
71
|
this._value = this._expression.value;
|
|
75
72
|
this._changeDetectorRef.markForCheck();
|
|
@@ -78,7 +75,9 @@ class RsxPipe {
|
|
|
78
75
|
disposeExpression() {
|
|
79
76
|
this._changedSubscription?.unsubscribe();
|
|
80
77
|
this._changedSubscription = undefined;
|
|
81
|
-
this.
|
|
78
|
+
if (this._lastExpressionString) {
|
|
79
|
+
this._expression?.dispose();
|
|
80
|
+
}
|
|
82
81
|
this._expression = undefined;
|
|
83
82
|
}
|
|
84
83
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
@@ -100,5 +99,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
100
99
|
* Generated bundle index. Do not edit.
|
|
101
100
|
*/
|
|
102
101
|
|
|
103
|
-
export { IExpressionFactoryToken,
|
|
102
|
+
export { IExpressionFactoryToken, RsxPipe, providexRsx };
|
|
104
103
|
//# sourceMappingURL=rs-x-angular.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rs-x-angular.mjs","sources":["../../../projects/rsx/src/lib/rsx.
|
|
1
|
+
{"version":3,"file":"rs-x-angular.mjs","sources":["../../../projects/rsx/src/lib/rsx.providers.ts","../../../projects/rsx/src/lib/rsx.pipe.ts","../../../projects/rsx/src/public-api.ts","../../../projects/rsx/src/rs-x-angular.ts"],"sourcesContent":["import { APP_INITIALIZER, InjectionToken, type Provider } from '@angular/core';\nimport { InjectionContainer } from '@rs-x/core';\nimport { type IExpressionFactory, RsXExpressionParserInjectionTokens, RsXExpressionParserModule } from '@rs-x/expression-parser';\n\nexport const IExpressionFactoryToken = new InjectionToken<IExpressionFactory>('IExpressionFactoryProvider');\n\nfunction initializeRsx(): () => Promise<void> {\n return () => {\n if (InjectionContainer.isBound(RsXExpressionParserInjectionTokens.IExpressionFactory)) {\n return Promise.resolve();\n }\n return InjectionContainer.load(RsXExpressionParserModule);\n }\n}\n\nexport function providexRsx(): Provider[] {\n return [\n {\n provide: APP_INITIALIZER,\n useFactory: initializeRsx,\n multi: true\n },\n {\n provide: IExpressionFactoryToken,\n useFactory: () => InjectionContainer.get(RsXExpressionParserInjectionTokens.IExpressionFactory)\n }\n ];\n}","import {\n ChangeDetectorRef,\n inject,\n Pipe,\n type OnDestroy,\n type PipeTransform\n} from '@angular/core';\nimport { Type, UnsupportedException } from '@rs-x/core';\nimport {\n AbstractExpression,\n type IExpression\n} from '@rs-x/expression-parser';\nimport { Subscription } from 'rxjs';\nimport { IExpressionFactoryToken } from './rsx.providers';\n\n@Pipe({\n name: 'rsx',\n pure: false,\n})\nexport class RsxPipe implements PipeTransform, OnDestroy {\n private readonly _changeDetectorRef = inject(ChangeDetectorRef);\n private readonly _expressionFactory = inject(IExpressionFactoryToken);\n private _expression?: IExpression<unknown>;\n private _changedSubscription?: Subscription;\n private _lastExpressionString?: string;\n private _lastContext?: object;\n private _value: unknown;\n\n public transform(expression: string | IExpression, context?: object): unknown {\n if (\n (expression instanceof AbstractExpression && this._expression !== expression) ||\n expression !== this._lastExpressionString ||\n context !== this._lastContext\n ) {\n this.disposeExpression();\n this.createExpression(expression, context);\n }\n\n return this._value;\n }\n\n public ngOnDestroy(): void {\n this.disposeExpression();\n }\n\n private createExpression(expression: string | IExpression, context?: object): void {\n if (expression instanceof AbstractExpression) {\n this._lastExpressionString = undefined;\n this._expression = expression;\n } else if (Type.isString(expression)) {\n this._lastExpressionString = expression;\n if (context) {\n this._expression = this._expressionFactory.create(context, expression)\n }\n\n } else if(!Type.isNullOrUndefined(expression)) {\n throw new UnsupportedException(`string or IExpression expected`)\n }\n\n this._lastContext = context;\n\n this.tryToSubscribeToExpression();\n }\n\n private tryToSubscribeToExpression(): void {\n if (!this._expression) {\n return;\n }\n this._changedSubscription = this._expression.changed.subscribe(() => {\n this._value = this._expression!.value;\n this._changeDetectorRef.markForCheck();\n });\n }\n\n private disposeExpression(): void {\n this._changedSubscription?.unsubscribe();\n this._changedSubscription = undefined;\n\n if (this._lastExpressionString) {\n this._expression?.dispose();\n }\n this._expression = undefined;\n }\n}","/*\n * Public API Surface of rsx\n */\n\nexport * from './lib'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAIa,uBAAuB,GAAG,IAAI,cAAc,CAAqB,4BAA4B;AAE1G,SAAS,aAAa,GAAA;AACpB,IAAA,OAAO,MAAK;QACV,IAAI,kBAAkB,CAAC,OAAO,CAAC,kCAAkC,CAAC,kBAAkB,CAAC,EAAE;AACrF,YAAA,OAAO,OAAO,CAAC,OAAO,EAAE;QAC1B;AACA,QAAA,OAAO,kBAAkB,CAAC,IAAI,CAAC,yBAAyB,CAAC;AAC3D,IAAA,CAAC;AACH;SAEgB,WAAW,GAAA;IACzB,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,UAAU,EAAE,aAAa;AACzB,YAAA,KAAK,EAAE;AACR,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,uBAAuB;YAChC,UAAU,EAAE,MAAM,kBAAkB,CAAC,GAAG,CAAC,kCAAkC,CAAC,kBAAkB;AAC/F;KACF;AACH;;MCRa,OAAO,CAAA;AACC,IAAA,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC9C,IAAA,kBAAkB,GA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WAAW,EAAE;YACnB;QACJ;AACA,QAAA,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,MAAK;YAChE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAY,CAAC,KAAK;AACrC,YAAA,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE;AAC1C,QAAA,CAAC,CAAC;IACN;IAEQ,iBAAiB,GAAA;AACrB,QAAA,IAAI,CAAC,oBAAoB,EAAE,WAAW,EAAE;AACxC,QAAA,IAAI,CAAC,oBAAoB,GAAG,SAAS;AAErC,QAAA,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC5B,YAAA,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE;QAC/B;AACA,QAAA,IAAI,CAAC,WAAW,GAAG,SAAS;IAChC;uGA/DS,OAAO,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAAP,OAAO,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,KAAA,EAAA,IAAA,EAAA,KAAA,EAAA,CAAA;;2FAAP,OAAO,EAAA,UAAA,EAAA,CAAA;kBAJnB,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACF,oBAAA,IAAI,EAAE,KAAK;AACX,oBAAA,IAAI,EAAE,KAAK;AACd,iBAAA;;;AClBD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rs-x/angular",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Angular integration for RS-X, providing the RsxPipe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "fesm2022/rs-x-angular.mjs",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@angular/core": "^21.1.0",
|
|
39
39
|
"@angular/common": "^21.1.0",
|
|
40
40
|
"rxjs": "^7.8.0",
|
|
41
|
-
"@rs-x/core": "^0.4.
|
|
42
|
-
"@rs-x/expression-parser": "^0.4.
|
|
41
|
+
"@rs-x/core": "^0.4.0",
|
|
42
|
+
"@rs-x/expression-parser": "^0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@rs-x/core": {
|
package/types/rs-x-angular.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { IExpressionFactory } from '@rs-x/expression-parser';
|
|
4
|
-
|
|
5
|
-
declare const IExpressionFactoryToken: InjectionToken<IExpressionFactory>;
|
|
6
|
-
declare class RsxModule {
|
|
7
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<RsxModule, never>;
|
|
8
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<RsxModule, never, never, never>;
|
|
9
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<RsxModule>;
|
|
10
|
-
}
|
|
2
|
+
import { PipeTransform, OnDestroy, InjectionToken, Provider } from '@angular/core';
|
|
3
|
+
import { IExpression, IExpressionFactory } from '@rs-x/expression-parser';
|
|
11
4
|
|
|
12
5
|
declare class RsxPipe implements PipeTransform, OnDestroy {
|
|
13
6
|
private readonly _changeDetectorRef;
|
|
@@ -17,12 +10,16 @@ declare class RsxPipe implements PipeTransform, OnDestroy {
|
|
|
17
10
|
private _lastExpressionString?;
|
|
18
11
|
private _lastContext?;
|
|
19
12
|
private _value;
|
|
20
|
-
transform(
|
|
13
|
+
transform(expression: string | IExpression, context?: object): unknown;
|
|
21
14
|
ngOnDestroy(): void;
|
|
22
15
|
private createExpression;
|
|
16
|
+
private tryToSubscribeToExpression;
|
|
23
17
|
private disposeExpression;
|
|
24
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<RsxPipe, never>;
|
|
25
19
|
static ɵpipe: i0.ɵɵPipeDeclaration<RsxPipe, "rsx", true>;
|
|
26
20
|
}
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
declare const IExpressionFactoryToken: InjectionToken<IExpressionFactory>;
|
|
23
|
+
declare function providexRsx(): Provider[];
|
|
24
|
+
|
|
25
|
+
export { IExpressionFactoryToken, RsxPipe, providexRsx };
|