@rs-x/angular 0.4.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 robert-sanders-software-ontwikkeling
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Rsx
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.1.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
12
+
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
+
15
+ ```bash
16
+ ng generate --help
17
+ ```
18
+
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build rsx
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+ ```bash
35
+ cd dist/rsx
36
+ ```
37
+
38
+ 2. Run the `npm publish` command to publish your library to the npm registry:
39
+ ```bash
40
+ npm publish
41
+ ```
42
+
43
+ ## Running unit tests
44
+
45
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46
+
47
+ ```bash
48
+ ng test
49
+ ```
50
+
51
+ ## Running end-to-end tests
52
+
53
+ For end-to-end (e2e) testing, run:
54
+
55
+ ```bash
56
+ ng e2e
57
+ ```
58
+
59
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
60
+
61
+ ## Additional Resources
62
+
63
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -0,0 +1,104 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, APP_INITIALIZER, NgModule, inject, ChangeDetectorRef, Pipe } from '@angular/core';
3
+ import { InjectionContainer } from '@rs-x/core';
4
+ import { RsXExpressionParserInjectionTokens, RsXExpressionParserModule } from '@rs-x/expression-parser';
5
+
6
+ const IExpressionFactoryToken = new InjectionToken('IExpressionFactoryProvider');
7
+ function initializeRsx() {
8
+ return () => {
9
+ if (InjectionContainer.isBound(RsXExpressionParserInjectionTokens.IExpressionFactory)) {
10
+ return Promise.resolve();
11
+ }
12
+ return InjectionContainer.load(RsXExpressionParserModule);
13
+ };
14
+ }
15
+ class RsxModule {
16
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
17
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.1", ngImport: i0, type: RsxModule });
18
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxModule, providers: [
19
+ {
20
+ provide: APP_INITIALIZER,
21
+ useFactory: initializeRsx,
22
+ multi: true
23
+ },
24
+ {
25
+ provide: IExpressionFactoryToken,
26
+ useFactory: () => InjectionContainer.get(RsXExpressionParserInjectionTokens.IExpressionFactory)
27
+ }
28
+ ] });
29
+ }
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
+
47
+ class RsxPipe {
48
+ _changeDetectorRef = inject(ChangeDetectorRef);
49
+ _expressionFactory = inject(IExpressionFactoryToken);
50
+ _expression;
51
+ _changedSubscription;
52
+ _lastExpressionString;
53
+ _lastContext;
54
+ _value;
55
+ transform(expressionString, context) {
56
+ if (!expressionString || !context) {
57
+ return null;
58
+ }
59
+ if (expressionString !== this._lastExpressionString ||
60
+ context !== this._lastContext) {
61
+ this.disposeExpression();
62
+ this.createExpression(expressionString, context);
63
+ }
64
+ return this._value;
65
+ }
66
+ ngOnDestroy() {
67
+ this.disposeExpression();
68
+ }
69
+ createExpression(expressionString, context) {
70
+ this._lastExpressionString = expressionString;
71
+ this._lastContext = context;
72
+ this._expression = this._expressionFactory.create(context, expressionString);
73
+ this._changedSubscription = this._expression.changed.subscribe(() => {
74
+ this._value = this._expression.value;
75
+ this._changeDetectorRef.markForCheck();
76
+ });
77
+ }
78
+ disposeExpression() {
79
+ this._changedSubscription?.unsubscribe();
80
+ this._changedSubscription = undefined;
81
+ this._expression?.dispose();
82
+ this._expression = undefined;
83
+ }
84
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
85
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.1", ngImport: i0, type: RsxPipe, isStandalone: true, name: "rsx", pure: false });
86
+ }
87
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: RsxPipe, decorators: [{
88
+ type: Pipe,
89
+ args: [{
90
+ name: 'rsx',
91
+ pure: false,
92
+ }]
93
+ }] });
94
+
95
+ /*
96
+ * Public API Surface of rsx
97
+ */
98
+
99
+ /**
100
+ * Generated bundle index. Do not edit.
101
+ */
102
+
103
+ export { IExpressionFactoryToken, RsxModule, RsxPipe };
104
+ //# sourceMappingURL=rs-x-angular.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rs-x-angular.mjs","sources":["../../../projects/rsx/src/lib/rsx.module.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, NgModule } from '@angular/core';\nimport { InjectionContainer } from '@rs-x/core';\nimport { 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\n@NgModule({\n providers: [\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})\nexport class RsxModule { }","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.module';\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(expressionString: string, context: object): unknown {\n if (!expressionString || !context) {\n return null;\n }\n\n if (\n expressionString !== this._lastExpressionString ||\n context !== this._lastContext\n ) {\n this.disposeExpression();\n this.createExpression(expressionString, context);\n }\n\n return this._value;\n }\n\n public ngOnDestroy(): void {\n this.disposeExpression();\n }\n\n private createExpression(expressionString: string, context: object): void {\n this._lastExpressionString = expressionString;\n this._lastContext = context;\n this._expression = this._expressionFactory.create(context, expressionString)\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 this._expression?.dispose();\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;AAClB,IAAA,OAAO,MAAK;QACR,IAAG,kBAAkB,CAAC,OAAO,CAAC,kCAAkC,CAAC,kBAAkB,CAAC,EAAE;AAClF,YAAA,OAAO,OAAO,CAAC,OAAO,EAAE;QAC5B;AACA,QAAA,OAAO,kBAAkB,CAAC,IAAI,CAAC,yBAAyB,CAAC;AAC7D,IAAA,CAAC;AACL;MAea,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AAA;;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;;;AChBD;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@rs-x/angular",
3
+ "version": "0.4.4",
4
+ "description": "Angular integration for RS-X, providing the RsxPipe",
5
+ "type": "module",
6
+ "module": "fesm2022/rs-x-angular.mjs",
7
+ "types": "./dist/rsx/types/rs-x-angular.d.ts",
8
+ "typings": "types/rs-x-angular.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/rs-x-angular.d.ts",
12
+ "import": "./dist/rsx/fesm2022/rs-x-angular.mjs",
13
+ "default": "./fesm2022/rs-x-angular.mjs"
14
+ },
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ }
18
+ },
19
+ "sideEffects": false,
20
+ "files": [
21
+ "fesm2022",
22
+ "types"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/robert-sanders-software-ontwikkeling/rs-x"
27
+ },
28
+ "homepage": "https://github.com/robert-sanders-software-ontwikkeling/rs-x",
29
+ "bugs": {
30
+ "url": "https://github.com/robert-sanders-software-ontwikkeling/rs-x/issues"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": true
35
+ },
36
+ "peerDependencies": {
37
+ "@angular/core": "^21.1.0",
38
+ "@angular/common": "^21.1.0",
39
+ "rxjs": "^7.8.0",
40
+ "@rs-x/core": "0.4.4",
41
+ "@rs-x/expression-parser": "0.4.4"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "@rs-x/core": {
45
+ "optional": false
46
+ },
47
+ "@rs-x/expression-parser": {
48
+ "optional": false
49
+ }
50
+ },
51
+ "engines": {
52
+ "node": ">=24"
53
+ },
54
+ "keywords": [
55
+ "angular",
56
+ "rs-x",
57
+ "pipe",
58
+ "expression",
59
+ "reactive",
60
+ "typescript"
61
+ ],
62
+ "dependencies": {
63
+ "tslib": "^2.3.0"
64
+ }
65
+ }
@@ -0,0 +1,28 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, PipeTransform, OnDestroy } from '@angular/core';
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
+ }
11
+
12
+ declare class RsxPipe implements PipeTransform, OnDestroy {
13
+ private readonly _changeDetectorRef;
14
+ private readonly _expressionFactory;
15
+ private _expression?;
16
+ private _changedSubscription?;
17
+ private _lastExpressionString?;
18
+ private _lastContext?;
19
+ private _value;
20
+ transform(expressionString: string, context: object): unknown;
21
+ ngOnDestroy(): void;
22
+ private createExpression;
23
+ private disposeExpression;
24
+ static ɵfac: i0.ɵɵFactoryDeclaration<RsxPipe, never>;
25
+ static ɵpipe: i0.ɵɵPipeDeclaration<RsxPipe, "rsx", true>;
26
+ }
27
+
28
+ export { IExpressionFactoryToken, RsxModule, RsxPipe };