@cosystem/angular 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Coaction
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.
@@ -0,0 +1,18 @@
1
+ import { EnvironmentProviders, InjectionToken, Signal } from "@angular/core";
2
+ import { App, InjectionToken as InjectionToken$1 } from "@cosystem/core";
3
+
4
+ //#region src/index.d.ts
5
+ interface InjectSignalOptions<T> {
6
+ readonly equals?: (value: T, previous: T) => boolean;
7
+ }
8
+ type AppSelector<T> = (app: App) => T;
9
+ type ModuleSelector<TModule, TValue> = (module: TModule, app: App) => TValue;
10
+ declare const COSYSTEM_APP: InjectionToken<App>;
11
+ declare function provideCoSystem(app: App): EnvironmentProviders;
12
+ declare function injectCoSystemApp(): App;
13
+ declare function injectModule<T>(token: InjectionToken$1<T>): T;
14
+ declare function injectSignal<T>(selector: AppSelector<T>, options?: InjectSignalOptions<T>): Signal<T>;
15
+ declare function injectSignal<TModule, TValue>(token: InjectionToken$1<TModule>, selector: ModuleSelector<TModule, TValue>, options?: InjectSignalOptions<TValue>): Signal<TValue>;
16
+ //#endregion
17
+ export { AppSelector, COSYSTEM_APP, InjectSignalOptions, ModuleSelector, injectCoSystemApp, injectModule, injectSignal, provideCoSystem };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UAYiB,mBAAA;EAAA,SACN,MAAA,IAAU,KAAA,EAAO,CAAA,EAAG,QAAA,EAAU,CAAA;AAAA;AAAA,KAG7B,WAAA,OAAkB,GAAA,EAAK,GAAA,KAAQ,CAAA;AAAA,KAC/B,cAAA,qBAAmC,MAAA,EAAQ,OAAA,EAAS,GAAA,EAAK,GAAA,KAAQ,MAAA;AAAA,cAEhE,YAAA,EAAc,cAAA,CAAe,GAAA;AAAA,iBAE1B,eAAA,CAAgB,GAAA,EAAK,GAAA,GAAM,oBAAA;AAAA,iBAS3B,iBAAA,IAAqB,GAAA;AAAA,iBAIrB,YAAA,IAAgB,KAAA,EAAO,gBAAA,CAAc,CAAA,IAAK,CAAA;AAAA,iBAI1C,YAAA,IACd,QAAA,EAAU,WAAA,CAAY,CAAA,GACtB,OAAA,GAAU,mBAAA,CAAoB,CAAA,IAC7B,MAAA,CAAO,CAAA;AAAA,iBACM,YAAA,kBACd,KAAA,EAAO,gBAAA,CAAc,OAAA,GACrB,QAAA,EAAU,cAAA,CAAe,OAAA,EAAS,MAAA,GAClC,OAAA,GAAU,mBAAA,CAAoB,MAAA,IAC7B,MAAA,CAAO,MAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ import { DestroyRef, InjectionToken, inject, makeEnvironmentProviders, signal } from "@angular/core";
2
+ import "@cosystem/core";
3
+ //#region src/index.ts
4
+ const COSYSTEM_APP = new InjectionToken("CoSystem App");
5
+ function provideCoSystem(app) {
6
+ return makeEnvironmentProviders([{
7
+ provide: COSYSTEM_APP,
8
+ useValue: app
9
+ }]);
10
+ }
11
+ function injectCoSystemApp() {
12
+ return inject(COSYSTEM_APP);
13
+ }
14
+ function injectModule(token) {
15
+ return injectCoSystemApp().getModule(token);
16
+ }
17
+ function injectSignal(first, second, third) {
18
+ const app = injectCoSystemApp();
19
+ const destroyRef = inject(DestroyRef);
20
+ const selector = typeof second === "function" ? (currentApp) => second(currentApp.getModule(first), currentApp) : first;
21
+ const equals = (typeof second === "function" ? third : second)?.equals ?? Object.is;
22
+ const value = signal(selector(app), { equal: equals });
23
+ const unsubscribe = app.watch(() => selector(app), (next) => {
24
+ value.set(next);
25
+ }, { equals });
26
+ destroyRef.onDestroy(unsubscribe);
27
+ return value.asReadonly();
28
+ }
29
+ //#endregion
30
+ export { COSYSTEM_APP, injectCoSystemApp, injectModule, injectSignal, provideCoSystem };
31
+
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n DestroyRef,\n InjectionToken,\n inject,\n makeEnvironmentProviders,\n signal,\n type EnvironmentProviders,\n type Signal,\n} from \"@angular/core\";\n\nimport { type App, type InjectionToken as CoSystemToken } from \"@cosystem/core\";\n\nexport interface InjectSignalOptions<T> {\n readonly equals?: (value: T, previous: T) => boolean;\n}\n\nexport type AppSelector<T> = (app: App) => T;\nexport type ModuleSelector<TModule, TValue> = (module: TModule, app: App) => TValue;\n\nexport const COSYSTEM_APP: InjectionToken<App> = new InjectionToken<App>(\"CoSystem App\");\n\nexport function provideCoSystem(app: App): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: COSYSTEM_APP,\n useValue: app,\n },\n ]);\n}\n\nexport function injectCoSystemApp(): App {\n return inject(COSYSTEM_APP);\n}\n\nexport function injectModule<T>(token: CoSystemToken<T>): T {\n return injectCoSystemApp().getModule(token);\n}\n\nexport function injectSignal<T>(\n selector: AppSelector<T>,\n options?: InjectSignalOptions<T>,\n): Signal<T>;\nexport function injectSignal<TModule, TValue>(\n token: CoSystemToken<TModule>,\n selector: ModuleSelector<TModule, TValue>,\n options?: InjectSignalOptions<TValue>,\n): Signal<TValue>;\nexport function injectSignal<TModule, TValue>(\n first: AppSelector<TValue> | CoSystemToken<TModule>,\n second?: ModuleSelector<TModule, TValue> | InjectSignalOptions<TValue>,\n third?: InjectSignalOptions<TValue>,\n): Signal<TValue> {\n const app = injectCoSystemApp();\n const destroyRef = inject(DestroyRef);\n const selector =\n typeof second === \"function\"\n ? (currentApp: App) =>\n second(currentApp.getModule(first as CoSystemToken<TModule>), currentApp)\n : (first as AppSelector<TValue>);\n const options = typeof second === \"function\" ? third : second;\n const equals = options?.equals ?? Object.is;\n const value = signal(selector(app), { equal: equals });\n const unsubscribe = app.watch(\n () => selector(app),\n (next) => {\n value.set(next);\n },\n { equals },\n );\n\n destroyRef.onDestroy(unsubscribe);\n\n return value.asReadonly();\n}\n"],"mappings":";;;AAmBA,MAAa,eAAoC,IAAI,eAAoB,cAAc;AAEvF,SAAgB,gBAAgB,KAAgC;CAC9D,OAAO,yBAAyB,CAC9B;EACE,SAAS;EACT,UAAU;CACZ,CACF,CAAC;AACH;AAEA,SAAgB,oBAAyB;CACvC,OAAO,OAAO,YAAY;AAC5B;AAEA,SAAgB,aAAgB,OAA4B;CAC1D,OAAO,kBAAkB,CAAC,CAAC,UAAU,KAAK;AAC5C;AAWA,SAAgB,aACd,OACA,QACA,OACgB;CAChB,MAAM,MAAM,kBAAkB;CAC9B,MAAM,aAAa,OAAO,UAAU;CACpC,MAAM,WACJ,OAAO,WAAW,cACb,eACC,OAAO,WAAW,UAAU,KAA+B,GAAG,UAAU,IACzE;CAEP,MAAM,UADU,OAAO,WAAW,aAAa,QAAQ,OAAA,EAC/B,UAAU,OAAO;CACzC,MAAM,QAAQ,OAAO,SAAS,GAAG,GAAG,EAAE,OAAO,OAAO,CAAC;CACrD,MAAM,cAAc,IAAI,YAChB,SAAS,GAAG,IACjB,SAAS;EACR,MAAM,IAAI,IAAI;CAChB,GACA,EAAE,OAAO,CACX;CAEA,WAAW,UAAU,WAAW;CAEhC,OAAO,MAAM,WAAW;AAC1B"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@cosystem/angular",
3
+ "version": "0.0.2",
4
+ "description": "Angular adapter for CoSystem.",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "sideEffects": false,
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@cosystem/core": "0.0.2"
24
+ },
25
+ "devDependencies": {
26
+ "@angular/core": "22.0.2",
27
+ "rxjs": "7.8.2",
28
+ "tsdown": "0.22.3",
29
+ "typescript": "6.0.3",
30
+ "vitest": "4.1.9",
31
+ "@cosystem/tsconfig": "0.0.2"
32
+ },
33
+ "peerDependencies": {
34
+ "@angular/core": ">=17.0.0 <23",
35
+ "rxjs": ">=7.5.0 <8"
36
+ },
37
+ "scripts": {
38
+ "build": "tsdown",
39
+ "clean": "rm -rf coverage dist .turbo",
40
+ "dev": "tsdown --watch",
41
+ "test": "cd ../.. && vitest run --project @cosystem/angular",
42
+ "test:coverage": "cd ../.. && vitest run --coverage --project @cosystem/angular",
43
+ "typecheck": "tsc -p tsconfig.json --noEmit"
44
+ }
45
+ }