fix(config): allow LogLevel to work with isolatedModules and update all warns and errors to respect logLevel (#30350)

Issue number: internal

---------

## What is the current behavior?
- `LogLevel` throws error `Error: Cannot access ambient const enums when
'isolatedModules' is enabled`
- Several existing console warns and errors are not calling the function
that respects the `logLevel` config

## What is the new behavior?
- Remove `const` from the `enum` to work with `isolatedModules`
- Update `console.warn`s to `printIonWarning`
- Update `console.error`s to `printIonError`

## Does this introduce a breaking change?
- [ ] Yes
- [x] No

## Other information

Dev build: `8.5.5-dev.11744729748.174bf7e0`

---------

Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
This commit is contained in:
Brandy Smith
2025-04-16 12:23:16 -04:00
committed by GitHub
parent 8dd566b5c1
commit d52fca084c
41 changed files with 124 additions and 92 deletions

View File

@ -2,6 +2,7 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Component, Element, Event, Listen, Method, Prop } from '@stencil/core';
import type { BackButtonEvent } from '@utils/hardware-back-button';
import { debounce } from '@utils/helpers';
import { printIonError, printIonWarning } from '@utils/logging';
import type { AnimationBuilder } from '../../interface';
import type { NavigationHookResult } from '../route/route-interface';
@ -166,15 +167,15 @@ export class Router implements ComponentInterface {
@Method()
async navChanged(direction: RouterDirection): Promise<boolean> {
if (this.busy) {
console.warn('[ion-router] router is busy, navChanged was cancelled');
printIonWarning('[ion-router] - Router is busy, navChanged was cancelled.');
return false;
}
const { ids, outlet } = await readNavState(window.document.body);
const routes = readRoutes(this.el);
const chain = findChainForIDs(ids, routes);
if (!chain) {
console.warn(
'[ion-router] no matching URL for ',
printIonWarning(
'[ion-router] - No matching URL for',
ids.map((i) => i.id)
);
return false;
@ -182,7 +183,7 @@ export class Router implements ComponentInterface {
const segments = chainToSegments(chain);
if (!segments) {
console.warn('[ion-router] router could not match path because some required param is missing');
printIonWarning('[ion-router] - Router could not match path because some required param is missing.');
return false;
}
@ -232,7 +233,7 @@ export class Router implements ComponentInterface {
animation?: AnimationBuilder
): Promise<boolean> {
if (!segments) {
console.error('[ion-router] URL is not part of the routing set');
printIonError('[ion-router] - URL is not part of the routing set.');
return false;
}
@ -253,7 +254,7 @@ export class Router implements ComponentInterface {
const routes = readRoutes(this.el);
const chain = findChainForSegments(segments, routes);
if (!chain) {
console.error('[ion-router] the path does not match any route');
printIonError('[ion-router] - The path does not match any route.');
return false;
}
@ -275,7 +276,7 @@ export class Router implements ComponentInterface {
try {
changed = await this.writeNavState(node, chain, direction, segments, redirectFrom, index, animation);
} catch (e) {
console.error(e);
printIonError('[ion-router] - Exception in safeWriteNavState:', e);
}
unlock();
return changed;
@ -338,7 +339,7 @@ export class Router implements ComponentInterface {
animation?: AnimationBuilder
): Promise<boolean> {
if (this.busy) {
console.warn('[ion-router] router is busy, transition was cancelled');
printIonWarning('[ion-router] - Router is busy, transition was cancelled.');
return false;
}
this.busy = true;

View File

@ -1,4 +1,5 @@
import { componentOnReady } from '@utils/helpers';
import { printIonError } from '@utils/logging';
import type { AnimationBuilder } from '../../../interface';
@ -51,7 +52,7 @@ export const writeNavState = async (
}
return changed;
} catch (e) {
console.error(e);
printIonError('[ion-router] - Exception in writeNavState:', e);
return false;
}
};