@hakam-aldeen-kh/blix 0.8.0 → 0.10.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/README.md CHANGED
@@ -7,7 +7,8 @@ a dockable panel with cross-source links, diffing, replay and HAR/cURL
7
7
  export.
8
8
 
9
9
  The entire panel is eliminated from production builds — see
10
- [Production elimination](#production-elimination).
10
+ [Production elimination](#production-elimination). To keep it on a staging
11
+ server, see [Enabling Blix in a production build](#enabling-blix-in-a-production-build-staging).
11
12
 
12
13
  Release notes are in [CHANGELOG.md](https://github.com/Hakam-aldeen-Kh/blix/blob/main/CHANGELOG.md).
13
14
 
@@ -397,7 +398,9 @@ never creating one of its own — and the panel updates.
397
398
  It is a **silent no-op** — never a throw, never a console warning — in every
398
399
  one of these:
399
400
 
400
- - outside development (`process.env.NODE_ENV !== "development"`);
401
+ - outside development (`process.env.NODE_ENV !== "development"`), unless the
402
+ build opted in with `NEXT_PUBLIC_BLIX=true` (see
403
+ [staging](#enabling-blix-in-a-production-build-staging));
401
404
  - **outside the browser** — the gate is also `typeof window !== "undefined"`,
402
405
  so every call made while rendering on the server does nothing, by design (see
403
406
  [Production elimination](#production-elimination));
@@ -721,7 +724,11 @@ import { store } from "@/src/store";
721
724
  // module graph, which fails the production build. Importing them here keeps
722
725
  // that evaluation on the client side of the boundary.
723
726
  export default function BlixMount() {
724
- if (process.env.NODE_ENV !== "development") return null;
727
+ if (
728
+ process.env.NODE_ENV !== "development" &&
729
+ process.env.NEXT_PUBLIC_BLIX !== "true"
730
+ )
731
+ return null;
725
732
  return <Blix store={store} apiClient={apiClient} dbName="my-app" />;
726
733
  }
727
734
  ```
@@ -798,6 +805,20 @@ field carries its own count — `8 of 56` — and a clear button, so you never
798
805
  have to read the status bar to know one is applied. `.*` widens the search to
799
806
  request and response bodies.
800
807
 
808
+ **The red bin beside Export clears the source you are reading**, and only
809
+ that one: emptying Redux leaves Network alone. Pinned entries survive it, and
810
+ it is disabled when the source has nothing left to clear. To empty every
811
+ source at once, use **Clear log** in the overflow menu, or `⇧C`.
812
+
813
+ **The launcher badge summarizes the log while the panel is closed.** It shows
814
+ one count per source that has captured anything — Network, Realtime, Redux,
815
+ Query, each with its rail icon — and, in red beside a count, how many of that
816
+ source's entries failed. The dot is capture state: green while capturing,
817
+ amber while paused, pulsing while something is in flight.
818
+
819
+ The panel opens **floating** the first time. Dock it to the bottom or the
820
+ right from the header; the choice is saved per project.
821
+
801
822
  **`Ctrl/⌘ K` opens the command palette**, and for several things it is the only
802
823
  way in — sort order, row density, dock position, the copy formats, the filter
803
824
  syntax. The header spends its width on what you read constantly; everything you
@@ -853,9 +874,12 @@ literal rather than a pre-serialized string.
853
874
  ### Exporting the log
854
875
 
855
876
  The **Export** button in the header offers six formats and a scope
856
- toggle — **Shown** (what the current section and filters leave visible) or
857
- **All**. It defaults to Shown, with both counts on the control, so an export
858
- says what it will contain before you pick a format.
877
+ toggle — **Selected** (the one entry open in the detail pane: a request, a
878
+ Redux action or a query), **Shown** (what the current section and filters
879
+ leave visible) or **All**. It defaults to Shown, with every count on the
880
+ control, so an export says what it will contain before you pick a format.
881
+ Selected is disabled until you select an entry; if it was your last choice and
882
+ nothing is selected, the menu opens on Shown instead.
859
883
 
860
884
  | | Format | For |
861
885
  | --- | --- | --- |
@@ -1014,8 +1038,55 @@ payloads for the lifetime of the server. Keeping the server-side singleton
1014
1038
  permanently empty is the point.
1015
1039
 
1016
1040
  Practically: a `captureEncrypted` call that runs during SSR does nothing, and
1017
- `<Blix />` returns `null` there — it checks `typeof window` alongside
1018
- `NODE_ENV` before touching the panel import.
1041
+ `<Blix />` renders nothing there. It also renders nothing during hydration, so
1042
+ its first client render matches the server's HTML; the panel mounts on the
1043
+ render right after. (Before 0.9.0 it branched on `typeof window` instead,
1044
+ which Next.js reported as a hydration mismatch on every load.)
1045
+
1046
+ ### Enabling Blix in a production build (staging)
1047
+
1048
+ A staging or test server usually runs a production build, where the panel is
1049
+ gone by design. Setting `NODE_ENV=development` for that build does not bring
1050
+ it back on Next.js 16: `next build` runs on Turbopack and inlines `NODE_ENV`
1051
+ as `"production"` whatever the environment says.
1052
+
1053
+ Opt in explicitly instead, in that server's env file:
1054
+
1055
+ ```bash
1056
+ NEXT_PUBLIC_BLIX=true
1057
+ ```
1058
+
1059
+ The panel and the capture layer both check it next to `NODE_ENV`, as the same
1060
+ kind of literal comparison, so Next.js inlines it at build time.
1061
+
1062
+ > **Set `NEXT_PUBLIC_BLIX=false` in your production env file.** Next.js only
1063
+ > inlines variables that are defined. Left unset, the comparison stays in the
1064
+ > bundle as a runtime check: the panel still never loads — the variable is
1065
+ > undefined in the browser — but its chunk is emitted into your production
1066
+ > build. `false` lets the bundler fold the check and drop the chunk.
1067
+
1068
+ **Never set `NEXT_PUBLIC_BLIX=true` for a build that real users get.** It
1069
+ ships the monitor to them, and with it everything it captures — see
1070
+ [Security](#security).
1071
+
1072
+ **Your own guards need the variable too.** A mount component that returns
1073
+ `null` outside development (as in [Mounting the panel](#mounting-the-panel)),
1074
+ or a call-site guard around `attachHttpMonitor` (below), keeps Blix off on
1075
+ staging regardless of the variable. Add it to each:
1076
+
1077
+ ```ts
1078
+ if (
1079
+ (process.env.NODE_ENV === "development" ||
1080
+ process.env.NEXT_PUBLIC_BLIX === "true") &&
1081
+ typeof window !== "undefined"
1082
+ ) {
1083
+ attachHttpMonitor(apiClient);
1084
+ }
1085
+ ```
1086
+
1087
+ The variable is read under its `NEXT_PUBLIC_` name, which is a Next.js
1088
+ convention. The opt-in has been verified with Next.js 16 (Turbopack) only;
1089
+ other bundlers do not inline that name by default.
1019
1090
 
1020
1091
  ### Guard your call sites
1021
1092
 
@@ -1085,10 +1156,12 @@ option to keep a third party's traffic out of the log.
1085
1156
  By default all of that is **in memory only**. Nothing is written to disk, and
1086
1157
  a reload starts clean.
1087
1158
 
1088
- All of it is dev-only regardless. Capture is gated on
1159
+ All of it is dev-only unless you opt a build in. Capture is gated on
1089
1160
  `process.env.NODE_ENV === "development" && typeof window !== "undefined"`, and
1090
1161
  the database is opened only when the panel mounts — see
1091
- [Production elimination](#production-elimination).
1162
+ [Production elimination](#production-elimination). A build made with
1163
+ `NEXT_PUBLIC_BLIX=true` captures exactly as development does, so everything in
1164
+ this section applies to whoever uses that build.
1092
1165
 
1093
1166
  ### What reaches disk, and when
1094
1167