@sentinel-core/sentinel 1.0.46 → 1.0.47

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.
Files changed (2) hide show
  1. package/README.md +176 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # @sentinel-core/sentinel
2
+
3
+ Runtime intelligence for your React UI — hover to inspect, click to deep-dive into props, Redux state, and Saga effects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @sentinel-core/sentinel
9
+ ```
10
+
11
+ Import the CSS in your client entry point:
12
+
13
+ ```js
14
+ import "@sentinel-core/sentinel/index.css";
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Wrap your app with `SentinelProvider` in the **client entry point only** (never server-side):
20
+
21
+ ```jsx
22
+ import { SentinelProvider } from "@sentinel-core/sentinel";
23
+ import "@sentinel-core/sentinel/index.css";
24
+
25
+ function ClientApp() {
26
+ return (
27
+ <SentinelProvider>
28
+ <App />
29
+ </SentinelProvider>
30
+ );
31
+ }
32
+ ```
33
+
34
+ Toggle the toolbar with the floating button (bottom-right) or `Ctrl+Shift+S`.
35
+
36
+ ## SentinelProvider Props
37
+
38
+ | Prop | Type | Description |
39
+ |---|---|---|
40
+ | `store` | `ReduxStore` | Redux store for live state inspection |
41
+ | `sagaMonitor` | `SentinelSagaMonitor` | Saga monitor from `createSentinelSagaMonitor()` |
42
+ | `serverState` | `unknown` | Server-side Redux state snapshot (SSR) |
43
+ | `serverSagaEffects` | `EffectRecord[]` | Server-side saga effects (SSR) |
44
+ | `externalLinks` | `ExternalLink[]` | Deep-link buttons shown in the component dialog header |
45
+
46
+ ## Redux Integration
47
+
48
+ ```jsx
49
+ import { SentinelProvider } from "@sentinel-core/sentinel";
50
+
51
+ <SentinelProvider store={reduxStore}>
52
+ <App />
53
+ </SentinelProvider>
54
+ ```
55
+
56
+ Pass `serverState` for SSR apps to show a Client/Server toggle in the Redux tab:
57
+
58
+ ```jsx
59
+ <SentinelProvider store={reduxStore} serverState={window.__INITIAL_STATE__}>
60
+ <App />
61
+ </SentinelProvider>
62
+ ```
63
+
64
+ ## Saga Integration
65
+
66
+ ```js
67
+ import { createSentinelSagaMonitor } from "@sentinel-core/sentinel";
68
+
69
+ const sagaMonitor = createSentinelSagaMonitor();
70
+ const sagaMiddleware = createSagaMiddleware({ sagaMonitor });
71
+
72
+ // Pass to both the middleware and the provider
73
+ ```
74
+
75
+ ```jsx
76
+ <SentinelProvider sagaMonitor={sagaMonitor}>
77
+ <App />
78
+ </SentinelProvider>
79
+ ```
80
+
81
+ Supports redux-saga v1.x and v0.x.
82
+
83
+ ## External Links
84
+
85
+ `externalLinks` lets you add custom deep-link buttons to the component dialog header. When a component is clicked, matching links are resolved and shown.
86
+
87
+ ```jsx
88
+ import { SentinelProvider } from "@sentinel-core/sentinel";
89
+
90
+ <SentinelProvider
91
+ externalLinks={[
92
+ {
93
+ label: "Open in Storybook",
94
+ match: (componentName) => storybookComponents.includes(componentName),
95
+ url: (props) => `https://storybook.example.com/?path=/story/${props.id}`,
96
+ },
97
+ ]}
98
+ >
99
+ <App />
100
+ </SentinelProvider>
101
+ ```
102
+
103
+ ### `ExternalLink` type
104
+
105
+ ```ts
106
+ type ExternalLink = {
107
+ match: (componentName: string, props: Record<string, any>) => boolean;
108
+ url: (props: Record<string, any>, sagaEffects: EffectRecord[]) => string;
109
+ label: string;
110
+ };
111
+ ```
112
+
113
+ ## Voltran MFE Integration
114
+
115
+ Use the built-in `voltranExternalLink` helper to deep-link to Voltran microfrontend components. It resolves the URL automatically from `getFragments` saga effects.
116
+
117
+ ```jsx
118
+ import { SentinelProvider, voltranExternalLink } from "@sentinel-core/sentinel";
119
+
120
+ <SentinelProvider
121
+ sagaMonitor={sagaMonitor}
122
+ serverSagaEffects={serverSagaEffects}
123
+ externalLinks={[
124
+ voltranExternalLink({
125
+ label: "Open in Voltran", // optional, default: "Open in Microfrontend"
126
+ baseUrl: "https://voltran.example.com", // optional, for relative fragment paths
127
+ preview: true, // optional, appends ?preview to the URL
128
+ }),
129
+ ]}
130
+ >
131
+ <App />
132
+ </SentinelProvider>
133
+ ```
134
+
135
+ The helper matches any component with a `fragmentInfo.id` prop and resolves the URL from the `getFragments` saga call's result (client) or config (server).
136
+
137
+ ## SSR
138
+
139
+ Pass server-side data to show Client/Server tabs in the toolbar:
140
+
141
+ ```jsx
142
+ // server entry — collect saga effects
143
+ const sagaMonitor = createSentinelSagaMonitor();
144
+ await store.dispatch(runSagas());
145
+ const serverSagaEffects = sagaMonitor._getSerializableEffects();
146
+
147
+ // send to client via window.__SENTINEL__ or similar
148
+
149
+ // client entry
150
+ <SentinelProvider
151
+ store={store}
152
+ sagaMonitor={clientSagaMonitor}
153
+ serverState={window.__SENTINEL__.state}
154
+ serverSagaEffects={window.__SENTINEL__.sagaEffects}
155
+ >
156
+ <App />
157
+ </SentinelProvider>
158
+ ```
159
+
160
+ ## Plugin
161
+
162
+ Use [`@sentinel-core/sentinel-plugin`](https://www.npmjs.com/package/@sentinel-core/sentinel-plugin) to automatically wrap your components at build time — no manual `<Sentinel>` wrapper needed.
163
+
164
+ ## Webpack
165
+
166
+ Add `conditionNames` to your resolve config:
167
+
168
+ ```js
169
+ resolve: {
170
+ conditionNames: ["require", "default"],
171
+ }
172
+ ```
173
+
174
+ ## License
175
+
176
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentinel-core/sentinel",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "Runtime intelligence for your UI.",
5
5
  "author": "firatorhan",
6
6
  "private": false,