mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 14:32:50 +00:00
feat: migrate app to AOT compilation
refactor: temporarily replace @ionic/storage-angular with custom file until upgrade to Angular 14+
This commit is contained in:
@@ -56,7 +56,6 @@
|
||||
"@angular/core": "13.3.11",
|
||||
"@angular/forms": "13.3.11",
|
||||
"@angular/platform-browser": "13.3.11",
|
||||
"@angular/platform-browser-dynamic": "13.3.11",
|
||||
"@angular/router": "13.3.11",
|
||||
"@asymmetrik/ngx-leaflet": "13.0.2",
|
||||
"@asymmetrik/ngx-leaflet-markercluster": "13.0.1",
|
||||
@@ -80,7 +79,7 @@
|
||||
"@hugotomazi/capacitor-navigation-bar": "2.0.0",
|
||||
"@ionic-native/core": "5.36.0",
|
||||
"@ionic/angular": "6.3.9",
|
||||
"@ionic/storage-angular": "3.0.6",
|
||||
"@ionic/storage": "4.0.0",
|
||||
"@ngx-translate/core": "14.0.0",
|
||||
"@ngx-translate/http-loader": "7.0.0",
|
||||
"@openid/appauth": "1.3.1",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {NgModule} from '@angular/core';
|
||||
import {IonicStorageModule} from '@ionic/storage-angular';
|
||||
import {IonicStorageModule} from '../../util/ionic-storage.module';
|
||||
import {StorageProvider} from './storage.provider';
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {Storage} from '@ionic/storage-angular';
|
||||
import {Storage} from '@ionic/storage';
|
||||
import {StorageModule} from './storage.module';
|
||||
import {StorageProvider} from './storage.provider';
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Storage} from '@ionic/storage-angular';
|
||||
import {Storage} from '@ionic/storage';
|
||||
|
||||
/**
|
||||
* Provides interaction with the (ionic) storage on the device (in the browser)
|
||||
|
||||
105
frontend/app/src/app/util/ionic-storage.module.ts
Normal file
105
frontend/app/src/app/util/ionic-storage.module.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars,unicorn/no-null,jsdoc/require-jsdoc,@typescript-eslint/no-explicit-any,@typescript-eslint/ban-types */
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Drifty, co.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
// This is based on the Ionic Storage 4.0.0 implementation until we can
|
||||
// upgrade to Angular 14+ and use the new update.
|
||||
// https://github.com/ionic-team/ionic-storage/blob/main/angular/src/index.ts
|
||||
import {isPlatformServer} from '@angular/common';
|
||||
import type {ModuleWithProviders} from '@angular/core';
|
||||
import {InjectionToken, NgModule, PLATFORM_ID} from '@angular/core';
|
||||
import {Storage, StorageConfig} from '@ionic/storage';
|
||||
|
||||
const StorageConfigToken = new InjectionToken<any>('STORAGE_CONFIG_TOKEN');
|
||||
|
||||
export {StorageConfigToken};
|
||||
|
||||
class NoopStorage extends Storage {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async create() {
|
||||
return this;
|
||||
}
|
||||
|
||||
async defineDriver() {}
|
||||
|
||||
get driver(): string | null {
|
||||
return 'noop';
|
||||
}
|
||||
|
||||
// @ts-expect-error unused
|
||||
async get(key: string) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @ts-expect-error unused
|
||||
async set(key: string, value: any) {}
|
||||
|
||||
// @ts-expect-error unused
|
||||
async remove(key: string): Promise<any> {}
|
||||
|
||||
async clear(): Promise<void> {}
|
||||
|
||||
async length(): Promise<number> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
async keys() {
|
||||
return [];
|
||||
}
|
||||
|
||||
// @ts-expect-error unused
|
||||
async forEach(iteratorCallback: (value: any, key: string, iterationNumber: Number) => any): Promise<void> {}
|
||||
|
||||
// @ts-expect-error unused
|
||||
setEncryptionKey(key: string) {}
|
||||
}
|
||||
|
||||
export function provideStorage(platformId: any, storageConfig: StorageConfig): Storage {
|
||||
if (isPlatformServer(platformId)) {
|
||||
// When running in a server context return the NoopStorage
|
||||
return new NoopStorage();
|
||||
}
|
||||
|
||||
return new Storage(storageConfig);
|
||||
}
|
||||
|
||||
@NgModule()
|
||||
export class IonicStorageModule {
|
||||
// @ts-expect-error unused
|
||||
static forRoot(storageConfig: StorageConfig = null): ModuleWithProviders<IonicStorageModule> {
|
||||
return {
|
||||
ngModule: IonicStorageModule,
|
||||
providers: [
|
||||
{provide: StorageConfigToken, useValue: storageConfig},
|
||||
{
|
||||
provide: Storage,
|
||||
useFactory: provideStorage,
|
||||
deps: [PLATFORM_ID, StorageConfigToken],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {enableProdMode} from '@angular/core';
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {platformBrowser} from '@angular/platform-browser';
|
||||
import {AppModule} from './app/app.module';
|
||||
import {environment} from './environments/environment';
|
||||
|
||||
@@ -21,7 +21,7 @@ if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic()
|
||||
platformBrowser()
|
||||
.bootstrapModule(AppModule)
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
.catch(async error => console.error(error));
|
||||
|
||||
Reference in New Issue
Block a user