@nice-code/action 0.12.0 → 0.13.0
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/build/devtools/browser/index.cjs +39 -1
- package/build/devtools/browser/index.cjs.map +1 -1
- package/build/devtools/browser/index.mjs +39 -1
- package/build/devtools/browser/index.mjs.map +1 -1
- package/build/devtools/server/index.cjs +1 -1
- package/build/devtools/server/index.cjs.map +1 -1
- package/build/devtools/server/index.mjs +1 -1
- package/build/devtools/server/index.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -34,6 +34,44 @@ const DEVTOOL_JSON_PUNCTUATION = "#475569";
|
|
|
34
34
|
const MONO_FONT = "ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace";
|
|
35
35
|
const SANS_FONT = "ui-sans-serif, system-ui, sans-serif";
|
|
36
36
|
//#endregion
|
|
37
|
+
//#region ../nice-devtools-shared/src/env.ts
|
|
38
|
+
function readViteEnv() {
|
|
39
|
+
try {
|
|
40
|
+
return import.meta.env;
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function readNodeEnv() {
|
|
46
|
+
try {
|
|
47
|
+
return process.env.NODE_ENV;
|
|
48
|
+
} catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether the devtools should be active.
|
|
54
|
+
*
|
|
55
|
+
* Detection order: Vite's `import.meta.env`, then `process.env.NODE_ENV`, then —
|
|
56
|
+
* if neither is resolvable (e.g. unbundled browser ESM) — default to enabled so
|
|
57
|
+
* the panel never silently vanishes. Real production builds always resolve one
|
|
58
|
+
* of the first two and correctly get `false`.
|
|
59
|
+
*
|
|
60
|
+
* `forceEnable` short-circuits to `true` for consumers who want the panel in
|
|
61
|
+
* production builds as well.
|
|
62
|
+
*/
|
|
63
|
+
function isDevtoolsEnabled(forceEnable) {
|
|
64
|
+
if (forceEnable === true) return true;
|
|
65
|
+
const viteEnv = readViteEnv();
|
|
66
|
+
if (viteEnv != null) {
|
|
67
|
+
if (typeof viteEnv.DEV === "boolean") return viteEnv.DEV;
|
|
68
|
+
if (typeof viteEnv.MODE === "string") return viteEnv.MODE !== "production";
|
|
69
|
+
}
|
|
70
|
+
const nodeEnv = readNodeEnv();
|
|
71
|
+
if (nodeEnv != null) return nodeEnv !== "production";
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
37
75
|
//#region ../nice-devtools-shared/src/format.ts
|
|
38
76
|
/** Pretty-print any value to JSON, degrading gracefully for cyclic / non-JSON values. */
|
|
39
77
|
function safeStringify(value, indent = 2) {
|
|
@@ -3640,7 +3678,7 @@ function groupEntries(entries) {
|
|
|
3640
3678
|
return groups;
|
|
3641
3679
|
}
|
|
3642
3680
|
function NiceActionDevtools({ forceEnable, ...props }) {
|
|
3643
|
-
if (!forceEnable
|
|
3681
|
+
if (!isDevtoolsEnabled(forceEnable)) return null;
|
|
3644
3682
|
return /* @__PURE__ */ jsx(NiceActionDevtools_Panel, { ...props });
|
|
3645
3683
|
}
|
|
3646
3684
|
function NiceActionDevtools_Panel({ core, position: defaultPosition = "dock-right", initialOpen = false }) {
|