Compare commits

...

4 Commits

Author SHA1 Message Date
Brandy Smith
3f57768a86 fix(angular): setup config in provideIonicAngular 2025-04-14 17:24:18 -04:00
Brandy Smith
ec1e7e9c64 fix(core): need to export logging functions for this branch 2025-04-14 17:03:52 -04:00
Brandy Smith
9b982bcbde fix(angular): update console logs 2025-04-14 16:55:34 -04:00
Brandy Smith
cc389c0f43 fix(angular): initialize config in forRoot 2025-04-14 15:06:02 -04:00
7 changed files with 19 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ export { getTimeGivenProgression } from './utils/animation/cubic-bezier';
export { createGesture } from './utils/gesture';
export { initialize } from './global/ionic-global';
export { componentOnReady } from './utils/helpers';
export { LogLevel } from './utils/logging';
export { LogLevel, printIonError, printIonWarning } from './utils/logging';
export { isPlatform, Platforms, PlatformConfig, getPlatforms } from './utils/platform';
export { IonicSafeString } from './utils/sanitization';
export { IonicConfig, getMode, setupConfig } from './utils/config';

View File

@@ -13,6 +13,7 @@ export const enum LogLevel {
* @param message - The string message to be logged to the console.
*/
export const printIonWarning = (message: string, ...params: any[]) => {
console.log('printIonWarning', config.get('logLevel'));
const logLevel = config.get('logLevel', LogLevel.WARN);
if ([LogLevel.WARN].includes(logLevel)) {
return console.warn(`[Ionic Warning]: ${message}`, ...params);
@@ -27,6 +28,7 @@ export const printIonWarning = (message: string, ...params: any[]) => {
* @param params - Additional arguments to supply to the console.error.
*/
export const printIonError = (message: string, ...params: any[]) => {
console.log('printIonError', config.get('logLevel'));
const logLevel = config.get('logLevel', LogLevel.ERROR);
if ([LogLevel.ERROR, LogLevel.WARN].includes(logLevel)) {
return console.error(`[Ionic Error]: ${message}`, ...params);

View File

@@ -1,3 +1,5 @@
import { printIonWarning } from '@ionic/core';
/**
* @description
* NavParams are an object that exists on a page and can contain data for that particular view.
@@ -20,8 +22,8 @@
*/
export class NavParams {
constructor(public data: { [key: string]: any } = {}) {
console.warn(
`[Ionic Warning]: NavParams has been deprecated in favor of using Angular's input API. Developers should migrate to either the @Input decorator or the Signals-based input API.`
printIonWarning(
`NavParams has been deprecated in favor of using Angular's input API. Developers should migrate to either the @Input decorator or the Signals-based input API.`
);
}

View File

@@ -10,6 +10,7 @@ import {
AfterViewInit,
QueryList,
} from '@angular/core';
import { printIonError } from '@ionic/core';
import { NavController } from '../../providers/nav-controller';
@@ -184,7 +185,7 @@ export abstract class IonTabs implements AfterViewInit, AfterContentInit, AfterC
const selectedTab = tabs.find((t: any) => t.tab === tab);
if (!selectedTab) {
console.error(`[Ionic Error]: Tab with id: "${tab}" does not exist`);
printIonError(`Tab with id: "${tab}" does not exist`);
return;
}

View File

@@ -9,6 +9,7 @@ import {
InjectionToken,
ComponentRef,
} from '@angular/core';
import { printIonError } from '@ionic/core';
import {
FrameworkDelegate,
LIFECYCLE_DID_ENTER,
@@ -164,8 +165,8 @@ export const attachView = (
* which will cause collisions.
*/
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
console.error(
`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${
printIonError(
`${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${
component.name
}.`
);

View File

@@ -1,7 +1,7 @@
import { CommonModule, DOCUMENT } from '@angular/common';
import { ModuleWithProviders, APP_INITIALIZER, NgModule, NgZone } from '@angular/core';
import { ConfigToken, AngularDelegate, provideComponentInputBinding } from '@ionic/angular/common';
import { IonicConfig } from '@ionic/core';
import { initialize, IonicConfig, setupConfig } from '@ionic/core';
import { appInitialize } from './app-initialize';
import {
@@ -64,6 +64,9 @@ type OptInAngularFeatures = {
})
export class IonicModule {
static forRoot(config: IonicConfig & OptInAngularFeatures = {}): ModuleWithProviders<IonicModule> {
setupConfig(config);
initialize(config);
return {
ngModule: IonicModule,
providers: [

View File

@@ -2,7 +2,7 @@ import { DOCUMENT } from '@angular/common';
import { APP_INITIALIZER, makeEnvironmentProviders } from '@angular/core';
import type { EnvironmentProviders } from '@angular/core';
import { AngularDelegate, ConfigToken, provideComponentInputBinding } from '@ionic/angular/common';
import { initialize } from '@ionic/core/components';
import { initialize, setupConfig } from '@ionic/core/components';
import type { IonicConfig } from '@ionic/core/components';
import { ModalController } from './modal-controller';
@@ -13,6 +13,8 @@ type OptInAngularFeatures = {
};
export const provideIonicAngular = (config: IonicConfig & OptInAngularFeatures = {}): EnvironmentProviders => {
setupConfig(config);
return makeEnvironmentProviders([
{
provide: ConfigToken,