@nice-code/state 0.11.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.
@@ -1,11 +1,6 @@
1
- import { createRequire } from "node:module";
2
1
  import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
3
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
3
  import { useVirtualizer } from "@tanstack/react-virtual";
5
- //#region \0rolldown/runtime.js
6
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
7
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
8
- //#endregion
9
4
  //#region src/devtools/core/StateDevtoolsCore.ts
10
5
  /**
11
6
  * Framework-agnostic collector for nice-state stores.
@@ -213,6 +208,44 @@ const DEVTOOL_JSON_PUNCTUATION = "#475569";
213
208
  const MONO_FONT = "ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace";
214
209
  const SANS_FONT = "ui-sans-serif, system-ui, sans-serif";
215
210
  //#endregion
211
+ //#region ../nice-devtools-shared/src/env.ts
212
+ function readViteEnv() {
213
+ try {
214
+ return import.meta.env;
215
+ } catch {
216
+ return;
217
+ }
218
+ }
219
+ function readNodeEnv() {
220
+ try {
221
+ return process.env.NODE_ENV;
222
+ } catch {
223
+ return;
224
+ }
225
+ }
226
+ /**
227
+ * Whether the devtools should be active.
228
+ *
229
+ * Detection order: Vite's `import.meta.env`, then `process.env.NODE_ENV`, then —
230
+ * if neither is resolvable (e.g. unbundled browser ESM) — default to enabled so
231
+ * the panel never silently vanishes. Real production builds always resolve one
232
+ * of the first two and correctly get `false`.
233
+ *
234
+ * `forceEnable` short-circuits to `true` for consumers who want the panel in
235
+ * production builds as well.
236
+ */
237
+ function isDevtoolsEnabled(forceEnable) {
238
+ if (forceEnable === true) return true;
239
+ const viteEnv = readViteEnv();
240
+ if (viteEnv != null) {
241
+ if (typeof viteEnv.DEV === "boolean") return viteEnv.DEV;
242
+ if (typeof viteEnv.MODE === "string") return viteEnv.MODE !== "production";
243
+ }
244
+ const nodeEnv = readNodeEnv();
245
+ if (nodeEnv != null) return nodeEnv !== "production";
246
+ return true;
247
+ }
248
+ //#endregion
216
249
  //#region ../nice-devtools-shared/src/format.ts
217
250
  /** Pretty-print any value to JSON, degrading gracefully for cyclic / non-JSON values. */
218
251
  function safeStringify(value, indent = 2) {
@@ -480,32 +513,6 @@ function SectionLabel({ label, color = DEVTOOL_COLOR_SEMANTIC_SYSTEM }) {
480
513
  });
481
514
  }
482
515
  //#endregion
483
- //#region ../../node_modules/.bun/react-dom@19.2.7+e14d3f224186685e/node_modules/react-dom/cjs/react-dom.production.js
484
- /**
485
- * @license React
486
- * react-dom.production.js
487
- *
488
- * Copyright (c) Meta Platforms, Inc. and affiliates.
489
- *
490
- * This source code is licensed under the MIT license found in the
491
- * LICENSE file in the root directory of this source tree.
492
- */
493
- var require_react_dom_production = /* @__PURE__ */ __commonJSMin(((exports) => {
494
- __require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
495
- }));
496
- (/* @__PURE__ */ __commonJSMin(((exports, module) => {
497
- function checkDCE() {
498
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== "function") return;
499
- try {
500
- __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
501
- } catch (err) {
502
- console.error(err);
503
- }
504
- }
505
- checkDCE();
506
- module.exports = require_react_dom_production();
507
- })))();
508
- //#endregion
509
516
  //#region ../nice-devtools-shared/src/components/PanelChrome.tsx
510
517
  const DOCKED_SIZE_MIN = 140;
511
518
  const POSITION_GRID = [
@@ -2538,7 +2545,7 @@ const EMPTY_SNAPSHOT = {
2538
2545
  paused: false
2539
2546
  };
2540
2547
  function NiceStateDevtools({ forceEnable, ...props }) {
2541
- if (!forceEnable && true) return null;
2548
+ if (!isDevtoolsEnabled(forceEnable)) return null;
2542
2549
  return /* @__PURE__ */ jsx(NiceStateDevtools_Panel, { ...props });
2543
2550
  }
2544
2551
  function NiceStateDevtools_Panel({ core, position: defaultPosition = "dock-right", initialOpen = false }) {