@rs-x/angular 0.4.7 → 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
2
|
import { InjectionToken, APP_INITIALIZER, inject, ChangeDetectorRef, Pipe } from '@angular/core';
|
|
3
|
-
import { InjectionContainer } from '@rs-x/core';
|
|
4
|
-
import { RsXExpressionParserInjectionTokens, RsXExpressionParserModule } from '@rs-x/expression-parser';
|
|
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() {
|
|
@@ -34,24 +34,39 @@ class RsxPipe {
|
|
|
34
34
|
_lastExpressionString;
|
|
35
35
|
_lastContext;
|
|
36
36
|
_value;
|
|
37
|
-
transform(
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (expressionString !== this._lastExpressionString ||
|
|
37
|
+
transform(expression, context) {
|
|
38
|
+
if ((expression instanceof AbstractExpression && this._expression !== expression) ||
|
|
39
|
+
expression !== this._lastExpressionString ||
|
|
42
40
|
context !== this._lastContext) {
|
|
43
41
|
this.disposeExpression();
|
|
44
|
-
this.createExpression(
|
|
42
|
+
this.createExpression(expression, context);
|
|
45
43
|
}
|
|
46
44
|
return this._value;
|
|
47
45
|
}
|
|
48
46
|
ngOnDestroy() {
|
|
49
47
|
this.disposeExpression();
|
|
50
48
|
}
|
|
51
|
-
createExpression(
|
|
52
|
-
|
|
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
|
+
}
|
|
53
63
|
this._lastContext = context;
|
|
54
|
-
this.
|
|
64
|
+
this.tryToSubscribeToExpression();
|
|
65
|
+
}
|
|
66
|
+
tryToSubscribeToExpression() {
|
|
67
|
+
if (!this._expression) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
55
70
|
this._changedSubscription = this._expression.changed.subscribe(() => {
|
|
56
71
|
this._value = this._expression.value;
|
|
57
72
|
this._changeDetectorRef.markForCheck();
|
|
@@ -60,7 +75,9 @@ class RsxPipe {
|
|
|
60
75
|
disposeExpression() {
|
|
61
76
|
this._changedSubscription?.unsubscribe();
|
|
62
77
|
this._changedSubscription = undefined;
|
|
63
|
-
this.
|
|
78
|
+
if (this._lastExpressionString) {
|
|
79
|
+
this._expression?.dispose();
|
|
80
|
+
}
|
|
64
81
|
this._expression = undefined;
|
|
65
82
|
}
|
|
66
83
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
@@ -1 +1 @@
|
|
|
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 {\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
|
|
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,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC7D,IAAA,WAAW;AACX,IAAA,oBAAoB;AACpB,IAAA,qBAAqB;AACrB,IAAA,YAAY;AACZ,IAAA,MAAM;IAEP,SAAS,CAAC,UAAgC,EAAE,OAAgB,EAAA;QAC/D,IACI,CAAC,UAAU,YAAY,kBAAkB,IAAI,IAAI,CAAC,WAAW,KAAK,UAAU;YAC5E,UAAU,KAAK,IAAI,CAAC,qBAAqB;AACzC,YAAA,OAAO,KAAK,IAAI,CAAC,YAAY,EAC/B;YACE,IAAI,CAAC,iBAAiB,EAAE;AACxB,YAAA,IAAI,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A,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,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { PipeTransform, OnDestroy, InjectionToken, Provider } from '@angular/core';
|
|
3
|
-
import { IExpressionFactory } from '@rs-x/expression-parser';
|
|
3
|
+
import { IExpression, IExpressionFactory } from '@rs-x/expression-parser';
|
|
4
4
|
|
|
5
5
|
declare class RsxPipe implements PipeTransform, OnDestroy {
|
|
6
6
|
private readonly _changeDetectorRef;
|
|
@@ -10,9 +10,10 @@ declare class RsxPipe implements PipeTransform, OnDestroy {
|
|
|
10
10
|
private _lastExpressionString?;
|
|
11
11
|
private _lastContext?;
|
|
12
12
|
private _value;
|
|
13
|
-
transform(
|
|
13
|
+
transform(expression: string | IExpression, context?: object): unknown;
|
|
14
14
|
ngOnDestroy(): void;
|
|
15
15
|
private createExpression;
|
|
16
|
+
private tryToSubscribeToExpression;
|
|
16
17
|
private disposeExpression;
|
|
17
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<RsxPipe, never>;
|
|
18
19
|
static ɵpipe: i0.ɵɵPipeDeclaration<RsxPipe, "rsx", true>;
|