diff --git a/packages/async-queue/src/main.ts b/packages/async-queue/src/main.ts index 028e02b2..9607352f 100644 --- a/packages/async-queue/src/main.ts +++ b/packages/async-queue/src/main.ts @@ -1,7 +1,7 @@ import {newFlatomise} from '@alwatr/flatomise'; import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * A queue that executes async tasks in order like mutex and semaphore methodology diff --git a/packages/dedupe/src/main.ts b/packages/dedupe/src/main.ts index 0e9abf12..1135b257 100644 --- a/packages/dedupe/src/main.ts +++ b/packages/dedupe/src/main.ts @@ -1,6 +1,9 @@ import {getGlobalThis} from '@alwatr/global-this'; +import {packageTracer} from '@alwatr/package-tracer'; import '@alwatr/polyfill-has-own'; +__dev_mode__: packageTracer.add(__package_name__, __package_version__); + const globalThis_ = getGlobalThis<{__alwatr_dedupe__: string | true}>(); if (typeof globalThis_.__alwatr_dedupe__ === 'undefined') { diff --git a/packages/deep-clone/src/main.ts b/packages/deep-clone/src/main.ts index 2cec71b8..78657be6 100644 --- a/packages/deep-clone/src/main.ts +++ b/packages/deep-clone/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * Clone deeply nested objects and arrays. diff --git a/packages/delay/src/main.ts b/packages/delay/src/main.ts index ee902c5f..c184a4ff 100644 --- a/packages/delay/src/main.ts +++ b/packages/delay/src/main.ts @@ -1,7 +1,7 @@ import {packageTracer} from '@alwatr/package-tracer'; import {parseDuration, type Duration} from '@alwatr/parse-duration'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); import {requestAnimationFrame, requestIdleCallback} from './polyfill.js'; diff --git a/packages/exit-hook/src/main.ts b/packages/exit-hook/src/main.ts index 761588e1..4112d18d 100644 --- a/packages/exit-hook/src/main.ts +++ b/packages/exit-hook/src/main.ts @@ -1,7 +1,7 @@ import {deduplicate} from '@alwatr/dedupe'; import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); deduplicate({name: __package_name__}); diff --git a/packages/fetch/src/core.ts b/packages/fetch/src/core.ts index 5e852336..8a2bfda6 100644 --- a/packages/fetch/src/core.ts +++ b/packages/fetch/src/core.ts @@ -1,17 +1,19 @@ import {delay} from '@alwatr/delay'; -import {globalScope} from '@alwatr/global-this'; +import {getGlobalThis} from '@alwatr/global-this'; import {createLogger} from '@alwatr/logger'; import {packageTracer} from '@alwatr/package-tracer'; import {parseDuration} from '@alwatr/parse-duration'; import type {FetchOptions} from './type.js'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); -export const logger_ = createLogger('@alwatr/fetch'); +export const logger_ = /* #__PURE__ */ createLogger('@alwatr/fetch'); + +const globalThis_ = /* #__PURE__ */ getGlobalThis(); let cacheStorage_: Cache; -export const cacheSupported = Object.hasOwn(globalScope, 'caches'); +export const cacheSupported = /* #__PURE__ */ Object.hasOwn(globalThis_, 'caches'); const duplicateRequestStorage_: Record> = {}; @@ -215,7 +217,7 @@ export async function handleRetryPattern_(options: Required): Prom catch (err) { logger_.accident('fetch', 'fetch_failed_retry', err); - if (globalScope.navigator?.onLine === false) { + if (globalThis_.navigator?.onLine === false) { logger_.accident('handleRetryPattern_', 'offline', 'Skip retry because offline'); throw err; } @@ -232,7 +234,7 @@ export async function handleRetryPattern_(options: Required): Prom */ export function handleTimeout_(options: FetchOptions): Promise { if (options.timeout === 0) { - return globalScope.fetch(options.url, options); + return globalThis_.fetch(options.url, options); } // else logger_.logMethod?.('handleTimeout_'); @@ -257,7 +259,7 @@ export function handleTimeout_(options: FetchOptions): Promise { // }); // }); - globalScope + globalThis_ .fetch(options.url, options) .then((response) => resolved(response)) .catch((reason) => reject(reason)) diff --git a/packages/flat-string/src/main.ts b/packages/flat-string/src/main.ts index f8d921fb..7a280e42 100644 --- a/packages/flat-string/src/main.ts +++ b/packages/flat-string/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * This function simplifies the complex C structures that are part of a combined JavaScript string. diff --git a/packages/flatomise/src/main.ts b/packages/flatomise/src/main.ts index ee648199..28edba40 100644 --- a/packages/flatomise/src/main.ts +++ b/packages/flatomise/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * Flat promise that can be resolved or rejected from outside. diff --git a/packages/is-number/src/main.ts b/packages/is-number/src/main.ts index 175eb45f..efbf4e7f 100644 --- a/packages/is-number/src/main.ts +++ b/packages/is-number/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * Check the value is number or can convert to a number, for example string ' 123 ' can be converted to 123 diff --git a/packages/local-storage/src/main.ts b/packages/local-storage/src/main.ts index 95611a6b..a54ce4fa 100644 --- a/packages/local-storage/src/main.ts +++ b/packages/local-storage/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * Parse json string without throwing error. diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts index 88f1fef4..ab2dcfa6 100644 --- a/packages/logger/src/logger.ts +++ b/packages/logger/src/logger.ts @@ -3,7 +3,7 @@ import {platformInfo} from '@alwatr/platform-info'; import type {AlwatrLogger} from './type.js'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); const defaultDebugMode = platformInfo.development || diff --git a/packages/node-fs/src/common.ts b/packages/node-fs/src/common.ts index 1ba39dba..a67de36e 100644 --- a/packages/node-fs/src/common.ts +++ b/packages/node-fs/src/common.ts @@ -2,8 +2,8 @@ import {AsyncQueue} from '@alwatr/async-queue'; import {createLogger} from '@alwatr/logger'; import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); -export const logger = createLogger('@alwatr/node-fs'); +export const logger = /* #__PURE__ */ createLogger('@alwatr/node-fs'); -export const asyncQueue = new AsyncQueue(); +export const asyncQueue = /* #__PURE__ */ new AsyncQueue(); diff --git a/packages/package-tracer/src/main.ts b/packages/package-tracer/src/main.ts index afb9f76e..efc3e152 100644 --- a/packages/package-tracer/src/main.ts +++ b/packages/package-tracer/src/main.ts @@ -77,3 +77,5 @@ export const packageTracer = { return this.list[packageName]; }, } as const; + +__dev_mode__: packageTracer.add(__package_name__, __package_version__); diff --git a/packages/parse-duration/src/main.ts b/packages/parse-duration/src/main.ts index 5916b3f8..646d01b7 100644 --- a/packages/parse-duration/src/main.ts +++ b/packages/parse-duration/src/main.ts @@ -1,7 +1,7 @@ import {isNumber} from '@alwatr/is-number'; import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * Unit conversion table diff --git a/packages/platform-info/src/main.ts b/packages/platform-info/src/main.ts index e4b0d0a9..28b2475e 100644 --- a/packages/platform-info/src/main.ts +++ b/packages/platform-info/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /** * Represents information about the current platform. diff --git a/packages/playground/src/main.ts b/packages/playground/src/main.ts index 72500ad3..1d43c3c3 100644 --- a/packages/playground/src/main.ts +++ b/packages/playground/src/main.ts @@ -1,8 +1,9 @@ import {createLogger} from '@alwatr/nanolib'; -// import {exitHook} from '@alwatr/nanolib/node'; +import {exitHook} from '@alwatr/nanolib/exit-hook'; +import '@alwatr/nanolib/node-fs' createLogger('playground'); -// exitHook(() => { -// console.log('Exiting...'); -// }); +exitHook(() => { + console.log('Exiting...'); +}); diff --git a/packages/polyfill-has-own/src/main.ts b/packages/polyfill-has-own/src/main.ts index 73df5ebb..37b5df24 100644 --- a/packages/polyfill-has-own/src/main.ts +++ b/packages/polyfill-has-own/src/main.ts @@ -1,6 +1,6 @@ import {packageTracer} from '@alwatr/package-tracer'; -packageTracer.add(__package_name__, __package_version__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); /* eslint-disable no-prototype-builtins */ diff --git a/packages/redner-state/src/main.ts b/packages/redner-state/src/main.ts index 447a31b5..f948de84 100644 --- a/packages/redner-state/src/main.ts +++ b/packages/redner-state/src/main.ts @@ -1,9 +1,9 @@ import {createLogger} from '@alwatr/logger'; import {packageTracer} from '@alwatr/package-tracer'; -const logger = createLogger(__package_name__); +__dev_mode__: packageTracer.add(__package_name__, __package_version__); -packageTracer.add(__package_name__, __package_version__); +const logger = /* #__PURE__ */ createLogger(__package_name__); export const renderState = ( state: T,