Skip to content

Commit 3f8d42f

Browse files
authored
refactor: split Angular utilities into a dedicated package (#960)
fixed #956
1 parent 8e110e3 commit 3f8d42f

File tree

14 files changed

+557
-292
lines changed

14 files changed

+557
-292
lines changed

.changeset/cold-brooms-wait.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@logto/angular": major
3+
"@logto/angular-sample": major
4+
"@logto/js": major
5+
---
6+
7+
extract Angular-specific utilities from JS package into standalone package
8+
9+
Check the Angular sample app for usage, replace the existing import (`@logto/js`) with the new package (`@logto/angular`).

packages/angular-sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@angular/platform-server": "^19.0.0",
2222
"@angular/router": "^19.0.0",
2323
"@angular/ssr": "^19.0.0",
24-
"@logto/js": "link:../js",
24+
"@logto/angular": "link:../angular",
2525
"angular-auth-oidc-client": "^19.0.0",
2626
"express": "^4.20.0",
2727
"rxjs": "~7.8.0",

packages/angular-sample/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
22
import { RouterOutlet } from '@angular/router';
33
import { CommonModule } from '@angular/common';
44
import { OidcSecurityService } from 'angular-auth-oidc-client';
5-
import type { UserInfoResponse } from '@logto/js';
5+
import type { UserInfoResponse } from '@logto/angular';
66

77
@Component({
88
selector: 'app-root',

packages/angular-sample/src/app/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { provideAuth } from 'angular-auth-oidc-client';
55
import { routes } from './app.routes';
66
import { provideClientHydration } from '@angular/platform-browser';
77
import { provideHttpClient, withFetch } from '@angular/common/http';
8-
import { UserScope, buildAngularAuthConfig } from '@logto/js';
8+
import { UserScope, buildAngularAuthConfig } from '@logto/angular';
99

1010
export const appConfig: ApplicationConfig = {
1111
providers: [

packages/angular/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Logto Angular helper
2+
3+
This package provides a helper for Angular to use Logto.

packages/angular/package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "@logto/angular",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"module": "./lib/index.js",
6+
"types": "./lib/index.d.ts",
7+
"exports": {
8+
"types": "./lib/index.d.ts",
9+
"import": "./lib/index.js",
10+
"default": "./lib/index.js"
11+
},
12+
"files": [
13+
"lib"
14+
],
15+
"license": "MIT",
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/logto-io/js.git",
19+
"directory": "packages/angular"
20+
},
21+
"scripts": {
22+
"dev:tsc": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
23+
"precommit": "lint-staged",
24+
"check": "tsc --noEmit",
25+
"build": "rm -rf lib/ && tsc -p tsconfig.build.json --noEmit && rollup -c",
26+
"lint": "eslint --ext .ts --ext .tsx src",
27+
"prepack": "pnpm build && pnpm test"
28+
},
29+
"dependencies": {
30+
"@logto/js": "workspace:^",
31+
"@silverhand/essentials": "^2.9.2"
32+
},
33+
"devDependencies": {
34+
"@silverhand/eslint-config": "^6.0.1",
35+
"@silverhand/eslint-config-react": "^6.0.2",
36+
"@silverhand/ts-config": "^6.0.0",
37+
"@silverhand/ts-config-react": "^6.0.0",
38+
"angular-auth-oidc-client": "^19.0.0",
39+
"eslint": "^8.57.0",
40+
"lint-staged": "^15.0.0",
41+
"prettier": "^3.0.0",
42+
"typescript": "^5.3.3",
43+
"vitest": "^2.1.9"
44+
},
45+
"eslintConfig": {
46+
"extends": "@silverhand"
47+
},
48+
"prettier": "@silverhand/eslint-config/.prettierrc",
49+
"publishConfig": {
50+
"access": "public"
51+
}
52+
}

packages/angular/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '../../rollup.config.js';

packages/js/src/utils/angular.ts renamed to packages/angular/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1+
import { Prompt, QueryKey, type SignInUriParameters, withReservedScopes } from '@logto/js';
12
import { conditional } from '@silverhand/essentials';
23
import { type OpenIdConfiguration } from 'angular-auth-oidc-client';
34

4-
import { Prompt, QueryKey } from '../consts/index.js';
5-
import { type SignInUriParameters } from '../index.js';
6-
7-
import { withReservedScopes } from './scopes.js';
8-
95
/** The Logto configuration object for Angular apps. */
106
export type LogtoAngularConfig = {
117
/**
@@ -166,3 +162,6 @@ export const buildAngularAuthConfig = (logtoConfig: LogtoAngularConfig): OpenIdC
166162
},
167163
};
168164
};
165+
166+
export type { UserInfoResponse } from '@logto/js';
167+
export { UserScope } from '@logto/js';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig",
3+
"include": [
4+
"src",
5+
]
6+
}

packages/angular/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "@silverhand/ts-config-react/tsconfig.base",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"outDir": "lib",
6+
"types": ["vitest/globals"]
7+
},
8+
"include": [
9+
"src",
10+
"vitest.config.ts"
11+
]
12+
}

0 commit comments

Comments
 (0)