@crimsonsunset/jsg-logger 1.8.7 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/devtools/dist/__vite-browser-external-2Ng8QIWW.js +5 -0
- package/devtools/dist/__vite-browser-external-2Ng8QIWW.js.map +1 -0
- package/devtools/dist/panel-entry.js +14246 -0
- package/devtools/dist/panel-entry.js.map +1 -0
- package/devtools/dist/vite.svg +1 -0
- package/index.js +7 -50
- package/package.json +4 -2
- package/utils/devtools-loader.js +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/index.js
CHANGED
|
@@ -17,35 +17,6 @@ import {buildLogEntry, dispatchToTransports} from './utils/transport-dispatcher.
|
|
|
17
17
|
import {redactValue} from './utils/redaction.js';
|
|
18
18
|
import packageJson from './package.json' with {type: 'json'};
|
|
19
19
|
|
|
20
|
-
// Check default config for devtools at module load time
|
|
21
|
-
// This allows bundlers to tree-shake if disabled
|
|
22
|
-
const defaultDevtoolsEnabled = defaultConfig.devtools?.enabled ?? false;
|
|
23
|
-
|
|
24
|
-
// Conditional static import.
|
|
25
|
-
// The NODE_ENV check MUST come first: production bundlers (Next.js/webpack DefinePlugin)
|
|
26
|
-
// replace it with `false`, making the whole condition statically false so the entire
|
|
27
|
-
// block — and the devtools chunk graph — is dead-code-eliminated from client bundles.
|
|
28
|
-
// A bare `if (defaultDevtoolsEnabled)` is NOT eliminable because the value comes from a
|
|
29
|
-
// JSON property access webpack cannot constant-fold.
|
|
30
|
-
// Use lazy initialization to avoid top-level await (which would make module async)
|
|
31
|
-
let devtoolsModule = null;
|
|
32
|
-
let devtoolsModulePromise = null;
|
|
33
|
-
if (process.env.NODE_ENV !== 'production' && defaultDevtoolsEnabled) {
|
|
34
|
-
metaLog('[JSG-LOGGER] DevTools module pre-loading started (default config enabled)');
|
|
35
|
-
// Start loading immediately but don't await (non-blocking)
|
|
36
|
-
// Bundlers can still analyze this static import for tree-shaking
|
|
37
|
-
devtoolsModulePromise = import('@crimsonsunset/jsg-logger/devtools').then(module => {
|
|
38
|
-
devtoolsModule = module;
|
|
39
|
-
metaLog('[JSG-LOGGER] DevTools module pre-loaded successfully');
|
|
40
|
-
return module;
|
|
41
|
-
}).catch(error => {
|
|
42
|
-
metaError('[JSG-LOGGER] DevTools module pre-load failed:', error);
|
|
43
|
-
return null;
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
metaLog('[JSG-LOGGER] DevTools module NOT pre-loaded (default config disabled - will tree-shake)');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
20
|
/**
|
|
50
21
|
* Main Logger Class
|
|
51
22
|
* Manages logger instances and provides the public API
|
|
@@ -717,29 +688,15 @@ class JSGLogger {
|
|
|
717
688
|
}
|
|
718
689
|
|
|
719
690
|
try {
|
|
720
|
-
|
|
691
|
+
const {loadDevtoolsModule} = await import('./utils/devtools-loader.js');
|
|
692
|
+
const devtoolsModule = await loadDevtoolsModule();
|
|
693
|
+
|
|
721
694
|
if (!devtoolsModule) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
devtoolsLogger.info('Waiting for pre-loaded DevTools module...');
|
|
725
|
-
// Wait for pre-load to complete
|
|
726
|
-
devtoolsModule = await devtoolsModulePromise;
|
|
727
|
-
} else if (process.env.NODE_ENV !== 'production') {
|
|
728
|
-
// Runtime config override: consumer enabled devtools but default was disabled.
|
|
729
|
-
// Load on demand via dynamic import. Guarded by NODE_ENV so production
|
|
730
|
-
// bundlers (Next.js/webpack) statically eliminate the devtools subtree
|
|
731
|
-
// instead of pulling its chunks into the client bundle.
|
|
732
|
-
devtoolsLogger.info('Loading DevTools module dynamically (runtime config override)...');
|
|
733
|
-
devtoolsModule = await import('@crimsonsunset/jsg-logger/devtools');
|
|
734
|
-
} else {
|
|
735
|
-
devtoolsLogger.warn('DevTools panel is not available in production builds');
|
|
736
|
-
return null;
|
|
737
|
-
}
|
|
738
|
-
} else {
|
|
739
|
-
devtoolsLogger.info('Using pre-loaded DevTools module');
|
|
695
|
+
devtoolsLogger.warn('DevTools panel is not available in this build');
|
|
696
|
+
return null;
|
|
740
697
|
}
|
|
741
|
-
|
|
742
|
-
if (!devtoolsModule
|
|
698
|
+
|
|
699
|
+
if (!devtoolsModule.initializePanel) {
|
|
743
700
|
throw new Error('DevTools panel module missing initializePanel export');
|
|
744
701
|
}
|
|
745
702
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crimsonsunset/jsg-logger",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-environment logger with smart detection, file-level overrides, and beautiful console formatting. Test it live: https://logger.joesangiorgio.com/",
|
|
6
6
|
"main": "index.js",
|
|
@@ -94,12 +94,14 @@
|
|
|
94
94
|
"dev": "vite",
|
|
95
95
|
"dev:devtools": "cd devtools && npm run dev",
|
|
96
96
|
"test:devtools": "vite",
|
|
97
|
-
"build:devtools": "cd devtools && npm run build",
|
|
97
|
+
"build:devtools": "cd devtools && npm ci && npm run build",
|
|
98
|
+
"prepublishOnly": "npm run build:devtools",
|
|
98
99
|
"build:devtools:netlify": "npm install && cd devtools && npm install && npm run build:netlify",
|
|
99
100
|
"preview:devtools": "cd devtools && npm run preview",
|
|
100
101
|
"release:patch": "node scripts/release.js patch",
|
|
101
102
|
"release:minor": "node scripts/release.js minor",
|
|
102
103
|
"release:major": "node scripts/release.js major",
|
|
104
|
+
"publish:ci": "node scripts/publish.js",
|
|
103
105
|
"publish:public": "npm publish --access public",
|
|
104
106
|
"publish:github": "npm publish --registry=https://npm.pkg.github.com/ --access public",
|
|
105
107
|
"check": "npm run test && echo 'Package ready for publishing'"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy devtools panel loader — isolated from index.js so the devtools Vite
|
|
3
|
+
* build (which imports index.js) does not try to resolve panel-entry.js
|
|
4
|
+
* before it exists.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
let devtoolsModule = null;
|
|
8
|
+
let devtoolsModulePromise = null;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Load the devtools panel bundle on demand.
|
|
12
|
+
* @returns {Promise<Object|null>}
|
|
13
|
+
*/
|
|
14
|
+
export async function loadDevtoolsModule() {
|
|
15
|
+
if (devtoolsModule) {
|
|
16
|
+
return devtoolsModule;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (devtoolsModulePromise) {
|
|
20
|
+
return devtoolsModulePromise;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (process.env.NODE_ENV === 'production') {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const entry = ['./devtools', 'dist', 'panel-entry.js'].join('/');
|
|
28
|
+
|
|
29
|
+
devtoolsModulePromise = import(
|
|
30
|
+
/* webpackIgnore: true */
|
|
31
|
+
/* @vite-ignore */
|
|
32
|
+
entry
|
|
33
|
+
).then((module) => {
|
|
34
|
+
devtoolsModule = module;
|
|
35
|
+
return module;
|
|
36
|
+
}).catch((error) => {
|
|
37
|
+
console.error('[JSG-LOGGER] DevTools module load failed:', error);
|
|
38
|
+
devtoolsModulePromise = null;
|
|
39
|
+
return null;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return devtoolsModulePromise;
|
|
43
|
+
}
|