Skip to content

Commit

Permalink
fix startup
Browse files Browse the repository at this point in the history
  • Loading branch information
silicia-apps committed Sep 18, 2024
1 parent 0b40ffe commit b5b17a4
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 113 deletions.
178 changes: 98 additions & 80 deletions libs/core/src/lib/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
import {
CUSTOM_ELEMENTS_SCHEMA,
ErrorHandler,
// ErrorHandler,
ModuleWithProviders,
NgModule,
Optional,
SkipSelf,
} from '@angular/core';
} from "@angular/core";

import { CommonModule } from '@angular/common';
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { CommonModule } from "@angular/common";
import {
HttpClient,
provideHttpClient,
withInterceptorsFromDi,
} from "@angular/common/http";

import { IonicModule } from '@ionic/angular';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { sioCoreStates } from './store';
import { IonicModule } from "@ionic/angular";
import { TranslateModule, TranslateLoader } from "@ngx-translate/core";
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
import { sioCoreStates } from "./store";

/* ngxs */
import { NgxsDataPluginModule } from '@angular-ru/ngxs';
import { NgxsModule, NoopNgxsExecutionStrategy } from '@ngxs/store';
import { NgxsReduxDevtoolsPluginModule } from '@ngxs/devtools-plugin';
import { NgxsRouterPluginModule } from '@ngxs/router-plugin';
import { NgxsFormPluginModule } from '@ngxs/form-plugin';
import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MaskitoModule } from '@maskito/angular';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { NgxsDataPluginModule } from "@angular-ru/ngxs";
import { NgxsModule, NoopNgxsExecutionStrategy } from "@ngxs/store";
import { NgxsReduxDevtoolsPluginModule } from "@ngxs/devtools-plugin";
import { NgxsRouterPluginModule } from "@ngxs/router-plugin";
import { NgxsFormPluginModule } from "@ngxs/form-plugin";
import { NgxsLoggerPluginModule } from "@ngxs/logger-plugin";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
//import { MaskitoModule } from '@maskito/angular';
import { ScrollingModule } from "@angular/cdk/scrolling";

import { SioCoreComponents } from './components';
import { SioCoreComponents } from "./components";

import {
SioCoreEnvironmentConfig,
SioCoreEnvironmentInterface,
} from './services';
} from "./services";

import { SioCoreErrorHandlerService } from './shared/error.handle';
import { LoggerModule } from '@angular-ru/cdk/logger';
import { RouterModule } from '@angular/router';
//import { SioCoreErrorHandlerService } from "./shared/error.handle";
import { LoggerModule } from "@angular-ru/cdk/logger";
import { RouterModule } from "@angular/router";

export class EnsureModuleLoadedOnceGuard {
constructor(targetModule: NgModule) {
if (targetModule) {
throw new Error(
`${targetModule.constructor.name} has already been loaded. Import this module in the AppModule only.`,
`${targetModule.constructor.name} has already been loaded. Import this module in the AppModule only.`
);
}
}
Expand All @@ -51,76 +55,90 @@ export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http);
}

@NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [...SioCoreComponents],
exports: [...SioCoreComponents, IonicModule, TranslateModule], imports: [CommonModule,
FormsModule,
RouterModule,
MaskitoModule,
ReactiveFormsModule,
IonicModule,
ScrollingModule,
TranslateModule.forChild({
extend: true,
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient],
},
}),
NgxsFormPluginModule], providers: [provideHttpClient(withInterceptorsFromDi())] })
export class SioCommonModule {

}
@NgModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [...SioCoreComponents],
exports: [...SioCoreComponents, IonicModule, TranslateModule],
imports: [
CommonModule,
FormsModule,
RouterModule,
//MaskitoModule,
ReactiveFormsModule,
IonicModule,
ScrollingModule,
TranslateModule.forChild({
extend: true,
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient],
},
}),
NgxsFormPluginModule,
],
providers: [provideHttpClient(withInterceptorsFromDi())],
})
export class SioCommonModule {}

@NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [],
exports: [IonicModule, TranslateModule], imports: [CommonModule,
FormsModule,
RouterModule,
ReactiveFormsModule,
IonicModule,
TranslateModule.forChild({
extend: true,
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient],
},
}),
NgxsFormPluginModule], providers: [provideHttpClient(withInterceptorsFromDi())] })
export class SioMinimalModule {

}
@NgModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [],
exports: [IonicModule, TranslateModule],
imports: [
CommonModule,
FormsModule,
RouterModule,
ReactiveFormsModule,
IonicModule,
TranslateModule.forChild({
extend: true,
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient],
},
}),
NgxsFormPluginModule,
],
providers: [provideHttpClient(withInterceptorsFromDi())],
})
export class SioMinimalModule {}

@NgModule({ exports: [TranslateModule], imports: [CommonModule,
TranslateModule.forRoot(),
LoggerModule.forRoot(),
FormsModule,
ReactiveFormsModule,
IonicModule.forRoot(),
NgxsModule.forRoot(sioCoreStates, {
developmentMode: true,
executionStrategy: NoopNgxsExecutionStrategy,
}),
NgxsLoggerPluginModule.forRoot(),
NgxsDataPluginModule.forRoot(),
NgxsReduxDevtoolsPluginModule.forRoot(),
NgxsRouterPluginModule.forRoot(),
NgxsFormPluginModule.forRoot()], providers: [provideHttpClient(withInterceptorsFromDi())] })
@NgModule({
exports: [TranslateModule],
imports: [
CommonModule,
TranslateModule.forRoot(),
LoggerModule.forRoot(),
FormsModule,
ReactiveFormsModule,
IonicModule.forRoot(),
NgxsModule.forRoot(sioCoreStates, {
developmentMode: true,
executionStrategy: NoopNgxsExecutionStrategy,
}),
NgxsLoggerPluginModule.forRoot(),
NgxsDataPluginModule.forRoot(),
NgxsReduxDevtoolsPluginModule.forRoot(),
NgxsRouterPluginModule.forRoot(),
NgxsFormPluginModule.forRoot(),
],
providers: [provideHttpClient(withInterceptorsFromDi())],
})
export class SioCoreModule extends EnsureModuleLoadedOnceGuard {
constructor(@Optional() @SkipSelf() parentModule: SioCoreModule) {
super(parentModule);
}

static forRoot(
config?: SioCoreEnvironmentInterface,
config?: SioCoreEnvironmentInterface
): ModuleWithProviders<SioCoreModule> {
return {
ngModule: SioCoreModule,
providers: [
{ provide: SioCoreEnvironmentConfig, useValue: config },
// { provide: ErrorHandler, useClass: SioCoreErrorHandlerService },
// { provide: ErrorHandler, useClass: SioCoreErrorHandlerService },
],
};
}
Expand Down
67 changes: 39 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@capacitor/app": "6.0.1",
"@capacitor/core": "6.1.2",
"@capawesome/capacitor-file-picker": "6.0.1",
"@ionic/angular": "8.3.0",
"@ionic/angular": "8.3.1",
"@maskito/angular": "3.0.1",
"@maskito/core": "3.0.1",
"@ngx-translate/core": "^15.0.0",
Expand Down Expand Up @@ -71,12 +71,12 @@
"@swc/core": "1.7.26",
"@types/jest": "29.5.13",
"@types/node": "22.5.5",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@typescript-eslint/utils": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^7",
"@typescript-eslint/parser": "^7",
"@typescript-eslint/utils": "^7",
"autoprefixer": "^10.4.0",
"cypress": "13.14.2",
"eslint": "^8.0.0",
"eslint": "^8",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "3.5.0",
"jest": "29.7.0",
Expand Down

0 comments on commit b5b17a4

Please sign in to comment.