Skip to content

Commit

Permalink
feat: upgrade to Angular 18
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed Oct 25, 2024
1 parent 3c48293 commit bed034b
Show file tree
Hide file tree
Showing 19 changed files with 9,004 additions and 6,295 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:

- run: git fetch --no-tags --prune --depth 2 origin master

- uses: actions/cache@v3
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ~/.cache # Default cache directory for both Yarn and Cypress
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16.13.0
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
Expand Down
69 changes: 56 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,63 @@
/.angular/cache
dist
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
/elements
/functions

# dependencies
node_modules
.idea
.vscode
.cache

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
.history/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# IDE - Visual Studio
.vs/

# misc
/.sass-cache
/.angular/cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
coverage
testem.log
__diff_output__

# System Files
.DS_Store
Thumbs.db
/reports/
migrations.json

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn

.angular
# there's a bug in Nx that forces creation of prettier config in a default format
# should be fixed by https://github.com/nrwl/nx/pull/17157
.prettierrc

.env

# The incremental cache file, so local type-checks should become faster.
/tsconfig.spec.tsbuildinfo

.nx/cache
.nx/workspace-data
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.firebase
/dist
node_modules
/package.json
/.vscode
/.idea

.angular

/.nx/cache

/.nx/workspace-data
102 changes: 0 additions & 102 deletions decorate-angular-cli.js

This file was deleted.

4 changes: 2 additions & 2 deletions libs/emitter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"sideEffects": false,
"peerDependencies": {
"@angular/core": ">=15.0.0",
"@ngxs/store": ">=3.7.4"
"@angular/core": ">=17.0.0",
"@ngxs/store": ">=18.0.0"
}
}
16 changes: 4 additions & 12 deletions libs/emitter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,9 @@
"executor": "@nrwl/angular:package",
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
"options": {
"project": "libs/emitter/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/emitter/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "libs/emitter/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
"project": "libs/emitter/ng-package.json",
"tsConfig": "libs/emitter/tsconfig.lib.json"
}
},
"test": {
"executor": "@nrwl/jest:jest",
Expand All @@ -36,7 +28,7 @@
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/emitter/**/*.ts", "libs/emitter/**/*.html"]
Expand Down
7 changes: 4 additions & 3 deletions libs/emitter/src/lib/core/decorators/receiver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ensureStoreMetadata, StateContext } from '@ngxs/store';
import type { StateContext } from '@ngxs/store';
import { ɵensureStoreMetadata } from '@ngxs/store/internals';

import { RECEIVER_META_KEY, ReceiverMetaData } from '../internal/internals';
import { RECEIVER_META_KEY, type ReceiverMetaData } from '../internal/internals';

declare const ngDevMode: boolean;

Expand Down Expand Up @@ -73,7 +74,7 @@ export function Receiver(options?: Partial<ReceiverMetaData>): MethodDecorator {
key = String(key);
}

const meta = ensureStoreMetadata(target);
const meta = ɵensureStoreMetadata(target);
const { type, payload, action, cancelUncompleted } = getActionProperties(options, target, key);

if (NG_DEV_MODE && Object.prototype.hasOwnProperty.call(meta.actions, type)) {
Expand Down
16 changes: 4 additions & 12 deletions libs/emitter/src/lib/core/internal/internals.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { Type } from '@angular/core';
import { StateContext } from '@ngxs/store';
import type { ActionStatus, StateContext } from '@ngxs/store';

import { Observable } from 'rxjs';

export const enum ActionStatus {
Dispatched = 'DISPATCHED',
Successful = 'SUCCESSFUL',
Canceled = 'CANCELED',
Errored = 'ERRORED'
}

export type Action<T> = Type<T> & {
type: string;
};
Expand All @@ -21,9 +13,9 @@ export interface ReceiverMetaData<T extends Function = any> {
cancelUncompleted: boolean;
}

export interface Emittable<T = void, U = any> {
emit(payload: T): Observable<U>;
emitMany(payloads: T[]): Observable<U>;
export interface Emittable<T = void> {
emit(payload: T): Observable<void>;
emitMany(payloads: T[]): Observable<void>;
}

export interface ActionContext {
Expand Down
12 changes: 3 additions & 9 deletions libs/emitter/src/lib/core/operators/of-emittable.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { getActionTypeFromInstance } from '@ngxs/store';
import { ActionStatus, getActionTypeFromInstance } from '@ngxs/store';

import { OperatorFunction } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { type OperatorFunction, filter, map } from 'rxjs';

import {
ActionStatus,
ActionContext,
OfEmittableActionContext,
Types
} from '../internal/internals';
import { getReceiverMetadata } from '../utils';
import type { ActionContext, OfEmittableActionContext, Types } from '../internal/internals';

declare const ngDevMode: boolean;

Expand Down
10 changes: 5 additions & 5 deletions libs/emitter/src/lib/core/services/emit-store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;

@Injectable()
export class EmitStore extends Store {
emitter<T = void, U = any>(receiver: Function): Emittable<T, U> {
emitter<T = void>(receiver: Function): Emittable<T> {
const metadata = getReceiverMetadata(receiver);

if (NG_DEV_MODE && metadata == null) {
Expand All @@ -28,12 +28,12 @@ export class EmitStore extends Store {
}

return {
emit: (payload: T) => this._dispatchSingle<T, U>(metadata, payload),
emitMany: (payloads: T[]) => this._dispatchMany<T, U>(metadata, payloads)
emit: (payload: T) => this._dispatchSingle<T>(metadata, payload),
emitMany: (payloads: T[]) => this._dispatchMany<T>(metadata, payloads)
};
}

private _dispatchSingle<T, U>(metadata: ReceiverMetaData, payload: T): Observable<U> {
private _dispatchSingle<T>(metadata: ReceiverMetaData, payload: T): Observable<void> {
if (payload === undefined && metadata.payload !== undefined) {
payload = metadata.payload;
}
Expand All @@ -48,7 +48,7 @@ export class EmitStore extends Store {
return this.dispatch(new EmitterAction(payload, metadata.type));
}

private _dispatchMany<T, U>(metadata: ReceiverMetaData, payloads: T[]): Observable<U> {
private _dispatchMany<T>(metadata: ReceiverMetaData, payloads: T[]): Observable<void> {
if (!Array.isArray(payloads)) {
return this.dispatch([]);
}
Expand Down
2 changes: 1 addition & 1 deletion libs/emitter/src/lib/core/services/emitter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Emittable } from '../internal/internals';
export class EmitterService {
constructor(private _emitStore: EmitStore) {}

action<T = void, U = any>(receiver: Function): Emittable<T, U> {
action<T = void>(receiver: Function): Emittable<T> {
return this._emitStore.emitter(receiver);
}
}
Loading

0 comments on commit bed034b

Please sign in to comment.