@har-analyzer/components 0.0.15 → 0.0.17

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 (59) hide show
  1. package/README.md +59 -28
  2. package/dist/chunks/collapsible-key-value-list.js +24 -0
  3. package/dist/chunks/collapsible-section.js +22 -0
  4. package/dist/chunks/content-viewer.js +3056 -0
  5. package/dist/chunks/context.js +5 -0
  6. package/dist/chunks/headers-viewer.js +32 -0
  7. package/dist/chunks/index.js +2265 -174
  8. package/dist/chunks/index2.js +49 -0
  9. package/dist/chunks/payload-viewer.js +15 -0
  10. package/dist/chunks/provider.js +11 -0
  11. package/dist/chunks/response-viewer.js +10 -0
  12. package/dist/chunks/vertical-gap.js +1 -1
  13. package/dist/components/collapsible-section.d.ts +2 -1
  14. package/dist/components/enhanced-board/constants/i18n.d.ts +11 -6
  15. package/dist/components/enhanced-board/index.d.ts +7 -9
  16. package/dist/components/enhanced-table.d.ts +14 -2
  17. package/dist/components/horizontal-padding.d.ts +2 -0
  18. package/dist/components/inline-copy-to-clipboard.d.ts +6 -0
  19. package/dist/components/lazy-load.d.ts +2 -0
  20. package/dist/context/user-preferences/index.d.ts +6 -0
  21. package/dist/context/user-preferences/provider.d.ts +9 -0
  22. package/dist/context/user-preferences-store/context.d.ts +5 -0
  23. package/dist/context/user-preferences-store/hooks.d.ts +1 -0
  24. package/dist/context/user-preferences-store/provider.d.ts +5 -0
  25. package/dist/features/har-analyzer/components/app-layout.d.ts +7 -0
  26. package/dist/features/har-analyzer/components/preferences/index.d.ts +1 -0
  27. package/dist/features/har-analyzer/components/top-navigation.d.ts +8 -0
  28. package/dist/features/har-analyzer/context/preferences.d.ts +2 -0
  29. package/dist/features/har-analyzer-preferences-store/index.d.ts +2 -0
  30. package/dist/features/har-entries-viewer/index.d.ts +1 -1
  31. package/dist/features/list-har-entries/components/compare-mode-switcher.d.ts +1 -0
  32. package/dist/features/list-har-entries/components/content-type-filter.d.ts +1 -0
  33. package/dist/features/list-har-entries/components/errors-filter.d.ts +1 -0
  34. package/dist/features/list-har-entries/components/har-entries-table.d.ts +8 -0
  35. package/dist/features/list-har-entries/context/preferences.d.ts +5 -0
  36. package/dist/features/list-har-entries/index.d.ts +3 -7
  37. package/dist/har-analyzer-preferences-store.js +4 -0
  38. package/dist/har-analyzer.js +94 -81
  39. package/dist/har-entries-viewer.js +167 -7
  40. package/dist/index.d.ts +7 -2
  41. package/dist/index.js +12 -13
  42. package/dist/list-har-entries.js +3 -2126
  43. package/dist/utils/har.d.ts +1 -1
  44. package/dist/view-har-entry.js +5 -3128
  45. package/package.json +1 -1
  46. package/dist/chunks/json.js +0 -10
  47. package/dist/components/enhanced-top-navigation.d.ts +0 -7
  48. package/dist/components/simple-app-layout.d.ts +0 -6
  49. package/dist/components/simple-app-preferences/index.d.ts +0 -1
  50. package/dist/features/har-analyzer-preferences/index.d.ts +0 -7
  51. package/dist/features/har-entries-viewer/components/har-entries-filters/components/content-type-filter.d.ts +0 -7
  52. package/dist/features/har-entries-viewer/components/har-entries-filters/components/errors-filter.d.ts +0 -6
  53. package/dist/features/har-entries-viewer/components/har-entries-filters/index.d.ts +0 -1
  54. package/dist/features/har-entries-viewer/hooks/preferences.d.ts +0 -2
  55. package/dist/har-analyzer-preferences.js +0 -25
  56. package/dist/hooks/app-preferences.d.ts +0 -2
  57. package/dist/hooks/table-preferences.d.ts +0 -12
  58. /package/dist/{components/simple-app-preferences → features/har-analyzer/components/preferences/components}/content-width-switcher.d.ts +0 -0
  59. /package/dist/{components/simple-app-preferences → features/har-analyzer/components/preferences/components}/theme-switcher.d.ts +0 -0
package/README.md CHANGED
@@ -13,7 +13,7 @@ Reusable React components for HAR Analyzer.
13
13
  - ⚖️ **Entry Comparison**: Compare multiple HAR entries side-by-side to easily spot differences in headers, payloads, and responses by simply selecting multiple rows in the network table.
14
14
  - 🔍 **Advanced Filtering**: Filter network entries quickly by content types (JSON, HTML, JS, CSS, etc.) or error statuses via `<HAREntriesFilters />`.
15
15
  - 🕵️ **Deep Inspection**: Inspect detailed request/response headers, decoded payloads, and syntax-highlighted response bodies with `<ViewHAREntry />`.
16
- - 🛠️ **Persistent Preferences**: Context providers remember user preferences like themes (dark/light mode) and table column layouts effortlessly via the `<HARAnalyzerPreferencesProvider />`.
16
+ - 🛠️ **Persistent Preferences**: Context providers remember user preferences like themes (dark/light mode) and table column layouts effortlessly via the `<HARAnalyzerPreferencesStore />`.
17
17
  - 🎨 **Cloudscape UI**: Built on top of the [Cloudscape Design System](https://cloudscape.design/).
18
18
  - ⌨️ **Type Safe**: Fully written in TypeScript with exported utility types (`HARContent`, `HAREntry`) for standard HTTP Archive structures.
19
19
 
@@ -43,25 +43,28 @@ npm install react react-dom \
43
43
 
44
44
  ## Usage & Setup
45
45
 
46
- Clients **must** wrap the components with `HARAnalyzerPreferencesProvider` (to handle user preferences like themes and table settings) and Cloudscape's `<I18nProvider>` (for localization).
46
+ Clients **must** wrap the components with `HARAnalyzerPreferencesStore` (to handle user preferences like themes and table settings) and Cloudscape's `<I18nProvider>` (for localization).
47
47
 
48
- ```jsx
48
+ ```tsx
49
49
  import enMessages from '@cloudscape-design/components/i18n/messages/all.en.js';
50
50
  import { I18nProvider } from '@cloudscape-design/components/i18n';
51
- import useLocalStorageState from 'use-local-storage-state';
52
51
  import HAREntriesViewer from '@har-analyzer/components/har-entries-viewer';
53
- import HARAnalyzerPreferencesProvider from '@har-analyzer/components/har-analyzer-preferences';
52
+ import HARAnalyzerPreferencesStore, { type UserPreferencesStore } from '@har-analyzer/components/har-analyzer-preferences-store';
54
53
 
55
- // Provide a custom usePreference hook conforming to:
56
- // (key: string) => readonly [string | undefined, (preference: string) => void]
57
- const useWebStorage = (key) => useLocalStorageState(key);
54
+ // Provide a store conforming to the UserPreferencesStore interface:
55
+ // getPreference: (key: string) => Promise<string | undefined>
56
+ // setPreference: (key: string, value: string) => Promise<void>
57
+ const myStorage: UserPreferencesStore = {
58
+ getPreference: async (key) => localStorage.getItem(key) || undefined,
59
+ setPreference: async (key, value) => localStorage.setItem(key, value),
60
+ };
58
61
 
59
62
  function App() {
60
63
  return (
61
64
  <I18nProvider locale="en" messages={[enMessages]}>
62
- <HARAnalyzerPreferencesProvider usePreferenceStore={useWebStorage}>
63
- <HAREntriesViewer harEntries={yourHarEntriesArray} />
64
- </HARAnalyzerPreferencesProvider>
65
+ <HARAnalyzerPreferencesStore userPreferencesStore={myStorage}>
66
+ <HAREntriesViewer tableTitle="My HAR Entries" harEntries={yourHarEntriesArray} />
67
+ </HARAnalyzerPreferencesStore>
65
68
  </I18nProvider>
66
69
  );
67
70
  }
@@ -75,7 +78,7 @@ The library supports both **top-level** imports and **component-level** imports.
75
78
  ```javascript
76
79
  import {
77
80
  HARAnalyzer,
78
- HARAnalyzerPreferencesProvider,
81
+ HARAnalyzerPreferencesStore,
79
82
  HAREntriesViewer,
80
83
  HARFileUploader,
81
84
  ListHAREntries,
@@ -86,7 +89,7 @@ import {
86
89
  **Component-level:**
87
90
  ```javascript
88
91
  import HARAnalyzer from '@har-analyzer/components/har-analyzer';
89
- import HARAnalyzerPreferencesProvider from '@har-analyzer/components/har-analyzer-preferences';
92
+ import HARAnalyzerPreferencesStore from '@har-analyzer/components/har-analyzer-preferences-store';
90
93
  import HAREntriesViewer from '@har-analyzer/components/har-entries-viewer';
91
94
  import HARFileUploader from '@har-analyzer/components/har-file-uploader';
92
95
  import ListHAREntries from '@har-analyzer/components/list-har-entries';
@@ -123,7 +126,7 @@ import HAREntriesViewer from '@har-analyzer/components/har-entries-viewer';
123
126
 
124
127
  function App() {
125
128
  return (
126
- <HAREntriesViewer harEntries={yourHarEntriesArray} />
129
+ <HAREntriesViewer tableTitle="Requests" harEntries={yourHarEntriesArray} />
127
130
  );
128
131
  }
129
132
  ```
@@ -132,8 +135,8 @@ function App() {
132
135
 
133
136
  | Name | Type | Required | Description |
134
137
  |---------------|-------------------------------|----------|--------------------------------------------------|
135
- | title | string | no | Title of the table displaying the HAR entries |
136
138
  | harEntries | HAREntry[] | Yes | An array of HAR entries. |
139
+ | tableTitle | string | No | Title of the table displaying the HAR entries. |
137
140
 
138
141
  ---
139
142
 
@@ -147,8 +150,10 @@ import ListHAREntries from '@har-analyzer/components/list-har-entries';
147
150
  function App() {
148
151
  return (
149
152
  <ListHAREntries
153
+ title="Requests"
150
154
  harEntries={yourHarEntriesArray}
151
- onChange={(entries) => console.log('Selected:', entries)}
155
+ selectedHAREntries={[]}
156
+ onSelectionChange={(entries) => console.log('Selected:', entries)}
152
157
  />
153
158
  );
154
159
  }
@@ -156,10 +161,12 @@ function App() {
156
161
 
157
162
  **Props:**
158
163
 
159
- | Name | Type | Required | Description |
160
- |-----------|-------------------------------------------|----------|--------------------------------------|
161
- | harEntries| HAREntry[] | Yes | The entries to display in the table. |
162
- | onChange | (selectedHAREntries: HAREntry[]) => void | Yes | Callback when entries are selected. |
164
+ | Name | Type | Required | Description |
165
+ |---------------------|-------------------------------------------|----------|------------------------------------------|
166
+ | title | string | No | Optional title for the list. |
167
+ | harEntries | HAREntry[] | Yes | The entries to display in the table. |
168
+ | selectedHAREntries | HAREntry[] | Yes | Entries to remain selected in the table. |
169
+ | onSelectionChange | (selectedHAREntries: HAREntry[]) => void | Yes | Callback when entries are selected. |
163
170
 
164
171
  ---
165
172
 
@@ -206,19 +213,23 @@ function App() {
206
213
 
207
214
  ---
208
215
 
209
- ### HARAnalyzerPreferencesProvider
216
+ ### HARAnalyzerPreferencesStore
210
217
 
211
- Provides a persistent context for managing user preferences (like theme, content width, table preferences and board layouts). You must wrap your application in `HARAnalyzerPreferencesProvider` and provide a `usePreferenceStore` hook that bridges external storage (like browser storage or Chrome Extensions API) into the library.
212
- ```jsx
213
- import HARAnalyzerPreferencesProvider from '@har-analyzer/components/har-analyzer-preferences';
218
+ Provides a persistent context for managing user preferences (like theme, content width, table preferences, and board layouts). You must wrap your application in `HARAnalyzerPreferencesStore` and provide a `userPreferencesStore` object that bridges external async storage (like browser storage APIs or Chrome Extensions API) into the library.
214
219
 
215
- const useWebStorage = (key) => useLocalStorageState(key);
220
+ ```tsx
221
+ import HARAnalyzerPreferencesStore, { type UserPreferencesStore } from '@har-analyzer/components/har-analyzer-preferences-store';
222
+
223
+ const myStorage: UserPreferencesStore = {
224
+ getPreference: async (key) => localStorage.getItem(key) || undefined,
225
+ setPreference: async (key, value) => { localStorage.setItem(key, value); }
226
+ };
216
227
 
217
228
  function App() {
218
229
  return (
219
- <HARAnalyzerPreferencesProvider usePreferenceStore={useWebStorage}>
230
+ <HARAnalyzerPreferencesStore userPreferencesStore={myStorage}>
220
231
  ...your HAR Analyzer components
221
- </HARAnalyzerPreferencesProvider>
232
+ </HARAnalyzerPreferencesStore>
222
233
  );
223
234
  }
224
235
  ```
@@ -232,11 +243,31 @@ Various types and utilities for working with HTTP Archive (.har) files are direc
232
243
  ```typescript
233
244
  import {
234
245
  getHARContentFromFile,
246
+ getHAREntriesFilteredByContentType,
247
+ getHAREntriesWithErrorResponse,
248
+ getHAREntryId,
249
+ isErrorResponse,
235
250
  type HARContent,
236
- type HAREntry
251
+ type HAREntry,
252
+ type ContentTypeGroup
237
253
  } from '@har-analyzer/components';
238
254
  ```
239
255
 
256
+ ### `getHARContentFromFile(fileContent: unknown): HARContent`
257
+ Parses a JSON string into a structured `HARContent` object. Throws an error if the content is not a valid JSON string.
258
+
259
+ ### `getHAREntriesFilteredByContentType(harEntries: HAREntry[], contentTypeFilters: ContentTypeGroup[]): HAREntry[]`
260
+ Filters an array of HAR entries by their response MIME types mapped to high-level content type groups (e.g., `'JSON'`, `'XML'`, `'JS'`, `'CSS'`, `'HTML'`, `'Doc'`, `'Img'`, `'Font'`, `'Media'`, `'Other'`).
261
+
262
+ ### `isErrorResponse(harEntry: HAREntry): boolean`
263
+ Returns `true` if the HAR entry's response has a status code less than 200 or greater than or equal to 400.
264
+
265
+ ### `getHAREntriesWithErrorResponse(harEntries: HAREntry[]): HAREntry[]`
266
+ Returns a filtered array of HAR entries containing only those that resulted in an error (based on `isErrorResponse`).
267
+
268
+ ### `getHAREntryId(harEntry: HAREntry): string`
269
+ Generates a unique deterministic ID for a given HAR entry using a combination of `startedDateTime`, `time`, and `request.url`.
270
+
240
271
  ---
241
272
 
242
273
  ## Development
@@ -0,0 +1,24 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import n from "@cloudscape-design/components/box";
3
+ import p from "@cloudscape-design/components/column-layout";
4
+ import { C as a } from "./collapsible-section.js";
5
+ import s from "@cloudscape-design/components/copy-to-clipboard";
6
+ function u(i) {
7
+ const { textToCopy: t, textToDisplay: r } = i;
8
+ return /* @__PURE__ */ o(
9
+ s,
10
+ {
11
+ variant: "inline",
12
+ textToCopy: t,
13
+ textToDisplay: r,
14
+ copyErrorText: "Failed to copy",
15
+ copySuccessText: "Copied!"
16
+ }
17
+ );
18
+ }
19
+ function x({ title: i, items: t = [] }) {
20
+ return /* @__PURE__ */ o(a, { variant: "inline", title: i, children: /* @__PURE__ */ o(p, { borders: "horizontal", columns: 2, disableGutters: !0, children: t.reduce((r, { name: l, value: e }) => (r.push(/* @__PURE__ */ o(n, { variant: "awsui-key-label", children: l })), r.push(e ? /* @__PURE__ */ o(u, { textToCopy: e }) : /* @__PURE__ */ o(n, { variant: "span", children: "-" })), r), []) }) });
21
+ }
22
+ export {
23
+ x as C
24
+ };
@@ -0,0 +1,22 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import a from "@cloudscape-design/components/expandable-section";
3
+ import { H as n } from "./index2.js";
4
+ function p({
5
+ title: t,
6
+ children: o,
7
+ variant: r = "default"
8
+ }) {
9
+ return /* @__PURE__ */ e(
10
+ a,
11
+ {
12
+ variant: r,
13
+ headerText: t,
14
+ defaultExpanded: !0,
15
+ disableContentPaddings: !0,
16
+ children: /* @__PURE__ */ e(n, { children: o })
17
+ }
18
+ );
19
+ }
20
+ export {
21
+ p as C
22
+ };