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