@buoy-gg/network 7.0.41 → 7.0.43
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 +11 -85
- package/lib/commonjs/index.js +1 -332
- package/lib/commonjs/index.web.js +1 -420
- package/lib/commonjs/network/components/DataViewer.web.js +1 -879
- package/lib/commonjs/network/components/NetworkCopyScreen.web.js +1 -48
- package/lib/commonjs/network/components/NetworkCopySettingsView.js +27 -755
- package/lib/commonjs/network/components/NetworkCopySettingsView.web.js +14 -1242
- package/lib/commonjs/network/components/NetworkDetailScreen.web.js +1 -101
- package/lib/commonjs/network/components/NetworkDetailStepper.js +1 -108
- package/lib/commonjs/network/components/NetworkDetailStepper.web.js +1 -298
- package/lib/commonjs/network/components/NetworkEventDetailView.js +15 -1130
- package/lib/commonjs/network/components/NetworkEventDetailView.web.js +15 -1484
- package/lib/commonjs/network/components/NetworkEventItemCompact.js +2 -401
- package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +2 -820
- package/lib/commonjs/network/components/NetworkFilterScreen.web.js +1 -55
- package/lib/commonjs/network/components/NetworkFilterViewV3.js +1 -442
- package/lib/commonjs/network/components/NetworkFilterViewV3.web.js +1 -1310
- package/lib/commonjs/network/components/NetworkHeaderLive.js +1 -375
- package/lib/commonjs/network/components/NetworkHeaderLive.web.js +1 -623
- package/lib/commonjs/network/components/NetworkHeaderMenu.js +1 -190
- package/lib/commonjs/network/components/NetworkListScreen.js +1 -403
- package/lib/commonjs/network/components/NetworkListScreen.web.js +1 -624
- package/lib/commonjs/network/components/NetworkModal.js +1 -786
- package/lib/commonjs/network/components/NetworkNumberPrompt.js +1 -178
- package/lib/commonjs/network/components/NetworkNumberPrompt.web.js +1 -232
- package/lib/commonjs/network/components/NetworkOverrideEditor.js +1 -814
- package/lib/commonjs/network/components/NetworkOverrideEditor.web.js +1 -942
- package/lib/commonjs/network/components/NetworkOverrideHeaderButton.js +1 -107
- package/lib/commonjs/network/components/NetworkOverrideHeaderButton.web.js +1 -133
- package/lib/commonjs/network/components/NetworkOverridesButton.js +1 -90
- package/lib/commonjs/network/components/NetworkOverridesButton.web.js +1 -143
- package/lib/commonjs/network/components/NetworkOverridesScreen.js +1 -543
- package/lib/commonjs/network/components/NetworkOverridesScreen.web.js +1 -830
- package/lib/commonjs/network/components/NetworkSavedScreen.js +1 -226
- package/lib/commonjs/network/components/NetworkSavedScreen.web.js +1 -463
- package/lib/commonjs/network/components/NetworkUpgradeBanner.js +1 -76
- package/lib/commonjs/network/components/response-editor/Explorer.js +1 -973
- package/lib/commonjs/network/components/response-editor/Explorer.web.js +1 -1136
- package/lib/commonjs/network/components/response-editor/deleteNestedDataByPath.js +1 -56
- package/lib/commonjs/network/components/response-editor/editorContext.js +1 -33
- package/lib/commonjs/network/components/response-editor/updateNestedDataByPath.js +1 -61
- package/lib/commonjs/network/conditions/NetworkConditionsControl.js +1 -235
- package/lib/commonjs/network/conditions/NetworkConditionsControl.test.js +1 -136
- package/lib/commonjs/network/conditions/NetworkConditionsIcon.js +1 -33
- package/lib/commonjs/network/conditions/NetworkFloatingTool.js +1 -310
- package/lib/commonjs/network/conditions/NetworkFloatingTool.test.js +1 -219
- package/lib/commonjs/network/conditions/store.js +1 -75
- package/lib/commonjs/network/conditions/wait.js +1 -43
- package/lib/commonjs/network/conditions/xhr.js +1 -135
- package/lib/commonjs/network/hooks/useLiveNetworkEvent.js +1 -62
- package/lib/commonjs/network/hooks/useNetworkBadgeCounts.js +1 -83
- package/lib/commonjs/network/hooks/useNetworkEventList.js +1 -108
- package/lib/commonjs/network/hooks/useNetworkEvents.js +1 -318
- package/lib/commonjs/network/hooks/useNetworkHasMatches.js +1 -56
- package/lib/commonjs/network/hooks/useNetworkSaved.js +1 -38
- package/lib/commonjs/network/hooks/useNetworkSelection.js +1 -53
- package/lib/commonjs/network/hooks/useOverrideRules.js +1 -36
- package/lib/commonjs/network/hooks/useTickEveryMinute.js +1 -21
- package/lib/commonjs/network/overrides/applyToFetch.js +1 -80
- package/lib/commonjs/network/overrides/applyToXhr.js +2 -510
- package/lib/commonjs/network/overrides/engine.js +1 -93
- package/lib/commonjs/network/overrides/matchRule.js +1 -87
- package/lib/commonjs/network/overrides/overriddenRows.js +1 -37
- package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -550
- package/lib/commonjs/network/overrides/presets.js +1 -70
- package/lib/commonjs/network/overrides/resolveOverride.js +1 -158
- package/lib/commonjs/network/overrides/types.js +1 -90
- package/lib/commonjs/network/sync/networkBodyResolver.js +1 -39
- package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -882
- package/lib/commonjs/network/sync/overrideHonesty.release.test.js +1 -36
- package/lib/commonjs/network/types/index.js +1 -5
- package/lib/commonjs/network/utils/extractOperationName.js +1 -80
- package/lib/commonjs/network/utils/filterNetworkEvents.js +1 -96
- package/lib/commonjs/network/utils/formatGraphQLVariables.js +1 -219
- package/lib/commonjs/network/utils/formatting.js +1 -30
- package/lib/commonjs/network/utils/generateCurl.js +2 -71
- package/lib/commonjs/network/utils/generateNetworkCopyText.js +37 -166
- package/lib/commonjs/network/utils/httpCompletion.js +1 -37
- package/lib/commonjs/network/utils/networkEventStore.js +1 -411
- package/lib/commonjs/network/utils/networkListener.js +4 -1352
- package/lib/commonjs/network/utils/networkSavedStore.js +3 -577
- package/lib/commonjs/network/utils/networkSelectionStore.js +1 -193
- package/lib/commonjs/network/utils/realNow.js +1 -0
- package/lib/commonjs/network/utils/requestId.js +1 -16
- package/lib/commonjs/network/utils/resolveRequestUrl.js +1 -15
- package/lib/commonjs/network/utils/selectSavedEvents.js +1 -39
- package/lib/commonjs/network/utils/startNetworkCapture.js +1 -24
- package/lib/commonjs/network/utils/withPinnedFirst.js +1 -32
- package/lib/commonjs/preset.js +1 -93
- package/lib/module/index.js +1 -104
- package/lib/module/index.web.js +1 -82
- package/lib/module/network/components/DataViewer.web.js +1 -875
- package/lib/module/network/components/NetworkCopyScreen.web.js +1 -44
- package/lib/module/network/components/NetworkCopySettingsView.js +27 -750
- package/lib/module/network/components/NetworkCopySettingsView.web.js +14 -1237
- package/lib/module/network/components/NetworkDetailScreen.web.js +1 -97
- package/lib/module/network/components/NetworkDetailStepper.js +1 -104
- package/lib/module/network/components/NetworkDetailStepper.web.js +1 -296
- package/lib/module/network/components/NetworkEventDetailView.js +15 -1129
- package/lib/module/network/components/NetworkEventDetailView.web.js +15 -1482
- package/lib/module/network/components/NetworkEventItemCompact.js +2 -398
- package/lib/module/network/components/NetworkEventItemCompact.web.js +2 -818
- package/lib/module/network/components/NetworkFilterScreen.web.js +1 -51
- package/lib/module/network/components/NetworkFilterViewV3.js +1 -438
- package/lib/module/network/components/NetworkFilterViewV3.web.js +1 -1306
- package/lib/module/network/components/NetworkHeaderLive.js +1 -366
- package/lib/module/network/components/NetworkHeaderLive.web.js +1 -617
- package/lib/module/network/components/NetworkHeaderMenu.js +1 -184
- package/lib/module/network/components/NetworkListScreen.js +1 -399
- package/lib/module/network/components/NetworkListScreen.web.js +1 -622
- package/lib/module/network/components/NetworkModal.js +1 -781
- package/lib/module/network/components/NetworkNumberPrompt.js +1 -174
- package/lib/module/network/components/NetworkNumberPrompt.web.js +1 -230
- package/lib/module/network/components/NetworkOverrideEditor.js +1 -811
- package/lib/module/network/components/NetworkOverrideEditor.web.js +1 -939
- package/lib/module/network/components/NetworkOverrideHeaderButton.js +1 -104
- package/lib/module/network/components/NetworkOverrideHeaderButton.web.js +1 -131
- package/lib/module/network/components/NetworkOverridesButton.js +1 -87
- package/lib/module/network/components/NetworkOverridesButton.web.js +1 -141
- package/lib/module/network/components/NetworkOverridesScreen.js +1 -539
- package/lib/module/network/components/NetworkOverridesScreen.web.js +1 -826
- package/lib/module/network/components/NetworkSavedScreen.js +1 -222
- package/lib/module/network/components/NetworkSavedScreen.web.js +1 -461
- package/lib/module/network/components/NetworkUpgradeBanner.js +1 -72
- package/lib/module/network/components/response-editor/Explorer.js +1 -972
- package/lib/module/network/components/response-editor/Explorer.web.js +1 -1133
- package/lib/module/network/components/response-editor/deleteNestedDataByPath.js +1 -51
- package/lib/module/network/components/response-editor/editorContext.js +1 -29
- package/lib/module/network/components/response-editor/updateNestedDataByPath.js +1 -56
- package/lib/module/network/conditions/NetworkConditionsControl.js +1 -231
- package/lib/module/network/conditions/NetworkConditionsControl.test.js +1 -135
- package/lib/module/network/conditions/NetworkConditionsIcon.js +1 -29
- package/lib/module/network/conditions/NetworkFloatingTool.js +1 -304
- package/lib/module/network/conditions/NetworkFloatingTool.test.js +1 -218
- package/lib/module/network/conditions/store.js +1 -65
- package/lib/module/network/conditions/wait.js +1 -38
- package/lib/module/network/conditions/xhr.js +1 -131
- package/lib/module/network/hooks/useLiveNetworkEvent.js +1 -58
- package/lib/module/network/hooks/useNetworkBadgeCounts.js +1 -79
- package/lib/module/network/hooks/useNetworkEventList.js +1 -104
- package/lib/module/network/hooks/useNetworkEvents.js +1 -314
- package/lib/module/network/hooks/useNetworkHasMatches.js +1 -52
- package/lib/module/network/hooks/useNetworkSaved.js +1 -34
- package/lib/module/network/hooks/useNetworkSelection.js +1 -46
- package/lib/module/network/hooks/useOverrideRules.js +1 -32
- package/lib/module/network/hooks/useTickEveryMinute.js +1 -11
- package/lib/module/network/overrides/applyToFetch.js +1 -72
- package/lib/module/network/overrides/applyToXhr.js +2 -502
- package/lib/module/network/overrides/engine.js +1 -85
- package/lib/module/network/overrides/matchRule.js +1 -81
- package/lib/module/network/overrides/overriddenRows.js +1 -33
- package/lib/module/network/overrides/overrideRulesStore.js +1 -547
- package/lib/module/network/overrides/presets.js +1 -65
- package/lib/module/network/overrides/resolveOverride.js +1 -152
- package/lib/module/network/overrides/types.js +1 -86
- package/lib/module/network/sync/networkBodyResolver.js +1 -34
- package/lib/module/network/sync/networkSyncAdapter.js +1 -880
- package/lib/module/network/sync/overrideHonesty.release.test.js +1 -35
- package/lib/module/network/types/index.js +1 -3
- package/lib/module/network/utils/extractOperationName.js +1 -76
- package/lib/module/network/utils/filterNetworkEvents.js +1 -92
- package/lib/module/network/utils/formatGraphQLVariables.js +1 -213
- package/lib/module/network/utils/formatting.js +1 -9
- package/lib/module/network/utils/generateCurl.js +2 -67
- package/lib/module/network/utils/generateNetworkCopyText.js +37 -162
- package/lib/module/network/utils/httpCompletion.js +1 -32
- package/lib/module/network/utils/networkEventStore.js +1 -409
- package/lib/module/network/utils/networkListener.js +4 -1341
- package/lib/module/network/utils/networkSavedStore.js +3 -572
- package/lib/module/network/utils/networkSelectionStore.js +1 -188
- package/lib/module/network/utils/realNow.js +1 -0
- package/lib/module/network/utils/requestId.js +1 -12
- package/lib/module/network/utils/resolveRequestUrl.js +1 -11
- package/lib/module/network/utils/selectSavedEvents.js +1 -35
- package/lib/module/network/utils/startNetworkCapture.js +1 -21
- package/lib/module/network/utils/withPinnedFirst.js +1 -28
- package/lib/module/preset.js +1 -91
- package/lib/typescript/network/overrides/engine.d.ts +1 -1
- package/lib/typescript/network/overrides/matchRule.d.ts +1 -1
- package/lib/typescript/network/overrides/resolveOverride.d.ts +2 -2
- package/lib/typescript/network/overrides/types.d.ts +9 -0
- package/lib/typescript/network/utils/networkListener.d.ts +11 -0
- package/lib/typescript/network/utils/realNow.d.ts +18 -0
- package/lib/web/index.mjs +73 -74
- package/package.json +3 -6
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/index.web.d.ts.map +0 -1
- package/lib/typescript/network/components/DataViewer.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkCopyScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkCopySettingsView.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkCopySettingsView.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkDetailScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkDetailStepper.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkDetailStepper.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventDetailView.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventDetailView.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventItemCompact.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventItemCompact.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkFilterScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkFilterViewV3.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkFilterViewV3.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkHeaderLive.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkHeaderLive.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkHeaderMenu.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkListScreen.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkListScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkModal.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkNumberPrompt.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkNumberPrompt.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideEditor.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideEditor.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideHeaderButton.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideHeaderButton.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesButton.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesButton.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesScreen.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkSavedScreen.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkSavedScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkUpgradeBanner.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/Explorer.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/Explorer.web.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/deleteNestedDataByPath.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/editorContext.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/updateNestedDataByPath.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkConditionsControl.test.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkConditionsIcon.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkFloatingTool.test.d.ts.map +0 -1
- package/lib/typescript/network/conditions/store.d.ts.map +0 -1
- package/lib/typescript/network/conditions/wait.d.ts.map +0 -1
- package/lib/typescript/network/conditions/xhr.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useLiveNetworkEvent.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkBadgeCounts.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkEventList.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkEvents.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkHasMatches.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkSaved.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkSelection.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useOverrideRules.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useTickEveryMinute.d.ts.map +0 -1
- package/lib/typescript/network/overrides/applyToFetch.d.ts.map +0 -1
- package/lib/typescript/network/overrides/applyToXhr.d.ts.map +0 -1
- package/lib/typescript/network/overrides/engine.d.ts.map +0 -1
- package/lib/typescript/network/overrides/matchRule.d.ts.map +0 -1
- package/lib/typescript/network/overrides/overriddenRows.d.ts.map +0 -1
- package/lib/typescript/network/overrides/overrideRulesStore.d.ts.map +0 -1
- package/lib/typescript/network/overrides/presets.d.ts.map +0 -1
- package/lib/typescript/network/overrides/resolveOverride.d.ts.map +0 -1
- package/lib/typescript/network/overrides/types.d.ts.map +0 -1
- package/lib/typescript/network/sync/networkBodyResolver.d.ts.map +0 -1
- package/lib/typescript/network/sync/networkSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/network/sync/overrideHonesty.release.test.d.ts.map +0 -1
- package/lib/typescript/network/types/index.d.ts.map +0 -1
- package/lib/typescript/network/utils/extractOperationName.d.ts.map +0 -1
- package/lib/typescript/network/utils/filterNetworkEvents.d.ts.map +0 -1
- package/lib/typescript/network/utils/formatGraphQLVariables.d.ts.map +0 -1
- package/lib/typescript/network/utils/formatting.d.ts.map +0 -1
- package/lib/typescript/network/utils/generateCurl.d.ts.map +0 -1
- package/lib/typescript/network/utils/generateNetworkCopyText.d.ts.map +0 -1
- package/lib/typescript/network/utils/httpCompletion.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkEventStore.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkListener.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkSavedStore.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkSelectionStore.d.ts.map +0 -1
- package/lib/typescript/network/utils/requestId.d.ts.map +0 -1
- package/lib/typescript/network/utils/resolveRequestUrl.d.ts.map +0 -1
- package/lib/typescript/network/utils/selectSavedEvents.d.ts.map +0 -1
- package/lib/typescript/network/utils/startNetworkCapture.d.ts.map +0 -1
- package/lib/typescript/network/utils/withPinnedFirst.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
|
@@ -1,70 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.draftFromEvent = draftFromEvent;
|
|
7
|
-
exports.patternForUrl = patternForUrl;
|
|
8
|
-
/**
|
|
9
|
-
* Turning a captured request into a rule draft.
|
|
10
|
-
*
|
|
11
|
-
* Chrome's flow assumes a keyboard, a file tree and a second monitor. On a
|
|
12
|
-
* phone the equivalent has to start from the request you're already looking at,
|
|
13
|
-
* which is what this file is for — the editor never opens on a blank field.
|
|
14
|
-
*
|
|
15
|
-
* There used to be a list of one-tap presets here (Force 500, Empty list,
|
|
16
|
-
* Offline…) rendered as chips. They're gone: the editor's outcome grid says the
|
|
17
|
-
* same things in the same words, so keeping both meant two lists to maintain
|
|
18
|
-
* and two places to look for the same choice.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Turn a captured URL into a pattern that will match the request AGAIN.
|
|
23
|
-
*
|
|
24
|
-
* The query string is dropped and replaced with `*`, which is not a
|
|
25
|
-
* simplification — it's the difference between a rule that works and one that
|
|
26
|
-
* silently never fires. Plenty of clients cache-bust
|
|
27
|
-
* (`?timestamp=1785783081234`), carry a request id, or page; pinning the exact
|
|
28
|
-
* URL means the next call to the same endpoint doesn't match. Found exactly
|
|
29
|
-
* that way: an "Offline" preset on a Pokémon request sat at 0 hits because the
|
|
30
|
-
* app appends a timestamp to every call.
|
|
31
|
-
*
|
|
32
|
-
* The path stays exact, so this still means "this endpoint" and not "this
|
|
33
|
-
* host" — and the editor shows the pattern, so narrowing it back down is one
|
|
34
|
-
* edit away.
|
|
35
|
-
*/
|
|
36
|
-
function patternForUrl(url) {
|
|
37
|
-
const query = url.indexOf("?");
|
|
38
|
-
return query === -1 ? url : `${url.slice(0, query)}*`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Render a captured body as editable text. */
|
|
42
|
-
function bodyToText(data) {
|
|
43
|
-
if (data == null) return "";
|
|
44
|
-
if (typeof data === "string") return data;
|
|
45
|
-
try {
|
|
46
|
-
return JSON.stringify(data, null, 2);
|
|
47
|
-
} catch {
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Prefill the rule editor from a captured request.
|
|
54
|
-
*
|
|
55
|
-
* Seeds the REAL response as the body so the common edit — change two fields of
|
|
56
|
-
* a payload you just saw — starts from something true rather than from nothing.
|
|
57
|
-
*/
|
|
58
|
-
function draftFromEvent(event) {
|
|
59
|
-
return {
|
|
60
|
-
enabled: true,
|
|
61
|
-
name: undefined,
|
|
62
|
-
urlPattern: patternForUrl(event.url),
|
|
63
|
-
methods: [String(event.method || "GET").toUpperCase()],
|
|
64
|
-
kind: "respond",
|
|
65
|
-
status: event.status && event.status >= 200 ? event.status : 200,
|
|
66
|
-
statusText: event.statusText,
|
|
67
|
-
body: bodyToText(event.responseData),
|
|
68
|
-
times: null
|
|
69
|
-
};
|
|
70
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.draftFromEvent=draftFromEvent;exports.patternForUrl=patternForUrl;function patternForUrl(t){const r=t.indexOf("?");return r===-1?t:`${t.slice(0,r)}*`}function bodyToText(t){if(t==null)return"";if(typeof t==="string")return t;try{return JSON.stringify(t,null,2)}catch{return""}}function draftFromEvent(t){return{enabled:true,name:void 0,urlPattern:patternForUrl(t.url),methods:[String(t.method||"GET").toUpperCase()],kind:"respond",status:t.status&&t.status>=200?t.status:200,statusText:t.statusText,body:bodyToText(t.responseData),times:null}}
|
|
@@ -1,158 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findMatchingRule = findMatchingRule;
|
|
7
|
-
exports.isSpent = isSpent;
|
|
8
|
-
exports.resolveOverride = resolveOverride;
|
|
9
|
-
exports.shouldApply = shouldApply;
|
|
10
|
-
exports.toOutcome = toOutcome;
|
|
11
|
-
var _matchRule = require("./matchRule");
|
|
12
|
-
var _types = require("./types");
|
|
13
|
-
/**
|
|
14
|
-
* Decide whether a request is overridden — the whole decision, in one pure
|
|
15
|
-
* function.
|
|
16
|
-
*
|
|
17
|
-
* Pure on purpose: this is the piece worth unit-testing, and it runs inside the
|
|
18
|
-
* app's own `XMLHttpRequest.send()`, so it must be cheap, total, and incapable
|
|
19
|
-
* of throwing. Everything that could surprise (defaults, clamping, content-type
|
|
20
|
-
* inference) is resolved HERE, so `applyToXhr` never makes a decision — it just
|
|
21
|
-
* performs the outcome.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Traffic that must never be overridden, whatever the user's rules say.
|
|
26
|
-
*
|
|
27
|
-
* A `*` pattern is a completely reasonable thing for a developer to write
|
|
28
|
-
* ("break everything and see what the app does"), and without this it would
|
|
29
|
-
* also break Buoy's own licence checks — turning "I tested an error state" into
|
|
30
|
-
* "the dev tools stopped working and I don't know why". Metro/debugger traffic
|
|
31
|
-
* is already excluded upstream by `networkListener.shouldIgnoreUrl`.
|
|
32
|
-
*/
|
|
33
|
-
const NEVER_OVERRIDE = [/(^|\.)keygen\.sh/i, /^https?:\/\/(www\.)?buoy\.gg\/api\/license(\/|$)/i];
|
|
34
|
-
function isProtectedUrl(url) {
|
|
35
|
-
return NEVER_OVERRIDE.some(pattern => pattern.test(url));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Guess a `content-type` when the rule didn't set one.
|
|
40
|
-
*
|
|
41
|
-
* Getting this wrong is not cosmetic: a client that trusts the header (axios's
|
|
42
|
-
* default transform, any `response.json()` wrapper) will hand the app a string
|
|
43
|
-
* where it expected an object, and the override looks broken rather than the
|
|
44
|
-
* header looking wrong.
|
|
45
|
-
*/
|
|
46
|
-
function inferContentType(body) {
|
|
47
|
-
const trimmed = body.trim();
|
|
48
|
-
if (trimmed === "") return "text/plain; charset=utf-8";
|
|
49
|
-
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
50
|
-
try {
|
|
51
|
-
JSON.parse(trimmed);
|
|
52
|
-
return "application/json";
|
|
53
|
-
} catch {
|
|
54
|
-
// Looks like JSON, isn't. Fall through — mislabelling it would be worse.
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return "text/plain; charset=utf-8";
|
|
58
|
-
}
|
|
59
|
-
function hasHeader(headers, name) {
|
|
60
|
-
const wanted = name.toLowerCase();
|
|
61
|
-
return Object.keys(headers).some(key => key.toLowerCase() === wanted);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Normalize a matched rule into the exact instructions the interceptor needs. */
|
|
65
|
-
function toOutcome(rule) {
|
|
66
|
-
const delayMs = Math.max(0, rule.delayMs ?? 0);
|
|
67
|
-
if (rule.kind === "delay") {
|
|
68
|
-
return {
|
|
69
|
-
kind: "delay",
|
|
70
|
-
rule,
|
|
71
|
-
delayMs
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (rule.kind === "fail") {
|
|
75
|
-
return {
|
|
76
|
-
kind: "fail",
|
|
77
|
-
rule,
|
|
78
|
-
delayMs,
|
|
79
|
-
failKind: rule.failKind ?? "network"
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const body = rule.body ?? "";
|
|
83
|
-
const headers = {
|
|
84
|
-
...(rule.headers ?? {})
|
|
85
|
-
};
|
|
86
|
-
if (!hasHeader(headers, "content-type")) {
|
|
87
|
-
headers["content-type"] = inferContentType(body);
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
kind: "respond",
|
|
91
|
-
rule,
|
|
92
|
-
delayMs,
|
|
93
|
-
// Clamped, not rejected: whatwg-fetch's Response constructor THROWS outside
|
|
94
|
-
// [200, 599], which would crash the app's own fetch instead of overriding
|
|
95
|
-
// it. The editor constrains the input; this guarantees it.
|
|
96
|
-
status: Math.min(_types.STATUS_MAX, Math.max(_types.STATUS_MIN, rule.status ?? 200)),
|
|
97
|
-
statusText: rule.statusText ?? "",
|
|
98
|
-
headers,
|
|
99
|
-
body
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** A rule that has burned through its `times` budget no longer applies. */
|
|
104
|
-
function isSpent(rule) {
|
|
105
|
-
return typeof rule.times === "number" && rule.hits >= rule.times;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Is this rule in a phase where it should actually fire?
|
|
110
|
-
*
|
|
111
|
-
* Only `alternate` can answer no. It reads the CURRENT `seen` count, before
|
|
112
|
-
* this match is recorded, so an untouched rule (`seen === 0`) lets the first
|
|
113
|
-
* request through and overrides the second.
|
|
114
|
-
*/
|
|
115
|
-
function shouldApply(rule) {
|
|
116
|
-
if (!rule.alternate) return true;
|
|
117
|
-
return rule.seen % 2 === 1;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The first enabled rule whose pattern covers this request, phase ignored.
|
|
122
|
-
*
|
|
123
|
-
* Separate from `resolveOverride` because an alternating rule has to advance
|
|
124
|
-
* its phase on the requests it deliberately skips — the caller needs the rule
|
|
125
|
-
* back even when the answer is "not this time".
|
|
126
|
-
*/
|
|
127
|
-
function findMatchingRule(url, method, rules) {
|
|
128
|
-
if (rules.length === 0) return null;
|
|
129
|
-
// Chrome skips OPTIONS too (`NetworkPersistenceManager.ts:953`). A faked
|
|
130
|
-
// preflight fails CORS in a way that looks nothing like the rule you wrote.
|
|
131
|
-
if (method.toUpperCase() === "OPTIONS") return null;
|
|
132
|
-
if (isProtectedUrl(url)) return null;
|
|
133
|
-
for (const rule of rules) {
|
|
134
|
-
if (!rule.enabled) continue;
|
|
135
|
-
if (isSpent(rule)) continue;
|
|
136
|
-
if (!(0, _matchRule.ruleMatches)(rule, url, method)) continue;
|
|
137
|
-
return rule;
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* First ENABLED matching rule wins outright — no merging across rules.
|
|
144
|
-
*
|
|
145
|
-
* Chrome cascades header overrides from the most general path segment to the
|
|
146
|
-
* most specific, but that only exists because its rules are directory-nested
|
|
147
|
-
* files. A flat list with a cascade would be a rule whose effect you cannot see
|
|
148
|
-
* by reading it, which is exactly the wrong trade on a phone screen.
|
|
149
|
-
*
|
|
150
|
-
* @param url Full request URL, query string included.
|
|
151
|
-
* @param method HTTP method as the caller sent it (case-insensitive).
|
|
152
|
-
* @param rules Ordered rule list; earlier entries win.
|
|
153
|
-
*/
|
|
154
|
-
function resolveOverride(url, method, rules) {
|
|
155
|
-
const rule = findMatchingRule(url, method, rules);
|
|
156
|
-
if (!rule || !shouldApply(rule)) return null;
|
|
157
|
-
return toOutcome(rule);
|
|
158
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.findMatchingRule=findMatchingRule;exports.isSpent=isSpent;exports.resolveOverride=resolveOverride;exports.shouldApply=shouldApply;exports.toOutcome=toOutcome;var _matchRule=require("./matchRule");var _types=require("./types");const NEVER_OVERRIDE=[/(^|\.)keygen\.sh/i,/^https?:\/\/(www\.)?buoy\.gg\/api\/license(\/|$)/i];function isProtectedUrl(t){return NEVER_OVERRIDE.some(e=>e.test(t))}function inferContentType(t){const e=t.trim();if(e==="")return"text/plain; charset=utf-8";if(e.startsWith("{")||e.startsWith("[")){try{JSON.parse(e);return"application/json"}catch{}}return"text/plain; charset=utf-8"}function hasHeader(t,e){const n=e.toLowerCase();return Object.keys(t).some(r=>r.toLowerCase()===n)}function toOutcome(t){const e=Math.max(0,t.delayMs??0);if(t.kind==="delay"){return{kind:"delay",rule:t,delayMs:e}}if(t.kind==="fail"){return{kind:"fail",rule:t,delayMs:e,failKind:t.failKind??"network"}}const n=t.body??"";const r={...t.headers??{}};if(!hasHeader(r,"content-type")){r["content-type"]=inferContentType(n)}return{kind:"respond",rule:t,delayMs:e,status:Math.min(_types.STATUS_MAX,Math.max(_types.STATUS_MIN,t.status??200)),statusText:t.statusText??"",headers:r,body:n}}function isSpent(t){return typeof t.times==="number"&&t.hits>=t.times}function shouldApply(t){if(!t.alternate)return true;return t.seen%2===1}function findMatchingRule(t,e,n,r){if(n.length===0)return null;if(e.toUpperCase()==="OPTIONS")return null;if(isProtectedUrl(t))return null;for(const i of n){if(!i.enabled)continue;if(isSpent(i))continue;if(!(0,_matchRule.ruleMatches)(i,t,e,r))continue;return i}return null}function resolveOverride(t,e,n,r){const i=findMatchingRule(t,e,n,r);if(!i||!shouldApply(i))return null;return toOutcome(i)}
|
|
@@ -1,90 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.STATUS_MIN = exports.STATUS_MAX = exports.MAX_RULES = exports.FREE_TIER_RULE_LIMIT = void 0;
|
|
7
|
-
exports.markForOutcome = markForOutcome;
|
|
8
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
9
|
-
/**
|
|
10
|
-
* Network response overrides — the rule model.
|
|
11
|
-
*
|
|
12
|
-
* This is Buoy's answer to Chrome DevTools' "Local Overrides", reshaped for
|
|
13
|
-
* mobile. Two deliberate differences from Chrome are worth knowing, because
|
|
14
|
-
* they explain the whole shape of this file:
|
|
15
|
-
*
|
|
16
|
-
* 1. Chrome's rules ARE a directory tree — a body override is a file at
|
|
17
|
-
* `<host>/<path>`, header overrides live in per-directory `.headers` files,
|
|
18
|
-
* and its general→specific header cascade exists only to hang off that
|
|
19
|
-
* nesting. We have no filesystem, so rules are a flat ordered list and the
|
|
20
|
-
* FIRST enabled match wins outright. That's what Charles/Proxyman/MSW do,
|
|
21
|
-
* and it's what a developer can reason about on a phone screen.
|
|
22
|
-
*
|
|
23
|
-
* 2. Chrome CANNOT change a status code. `NetworkManager.ts` computes
|
|
24
|
-
* `responseCode = isBodyOverridden ? 200 : (responseStatusCode || 200)`, so
|
|
25
|
-
* overriding a body forces 200, and there is no latency or failure
|
|
26
|
-
* simulation at all. Chrome's feature is "serve different bytes". Forcing a
|
|
27
|
-
* 500, a timeout or a 3s stall is the entire mobile use case, so `status`,
|
|
28
|
-
* `delayMs` and `kind: "fail"` below are the point of the exercise.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* What a rule does when it matches.
|
|
33
|
-
*
|
|
34
|
-
* - `respond` — synthesize a response. The request never leaves the device.
|
|
35
|
-
* - `fail` — synthesize a transport failure (offline / timeout). Also never
|
|
36
|
-
* leaves the device.
|
|
37
|
-
* - `delay` — let the real request run, just late. Pure latency injection.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Which transport failure to fake.
|
|
42
|
-
*
|
|
43
|
-
* `network` surfaces the way a real offline request does — `fetch` rejects with
|
|
44
|
-
* `TypeError: Network request failed`. This is also how you simulate "status 0":
|
|
45
|
-
* you can't, via `respond`, because whatwg-fetch's `Response` constructor throws
|
|
46
|
-
* a RangeError outside 200–599 (see STATUS_MIN/STATUS_MAX).
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Status codes a synthesized response may use.
|
|
51
|
-
*
|
|
52
|
-
* NOT an arbitrary product decision: React Native's `fetch` is the whatwg-fetch
|
|
53
|
-
* polyfill, whose `Response` constructor throws
|
|
54
|
-
* `RangeError: The status provided is outside the range [200, 599]`. A rule set
|
|
55
|
-
* to 0 would therefore crash the app's own fetch call rather than override it.
|
|
56
|
-
* Use `kind: "fail"` for connection-level failures.
|
|
57
|
-
*/
|
|
58
|
-
const STATUS_MIN = exports.STATUS_MIN = 200;
|
|
59
|
-
const STATUS_MAX = exports.STATUS_MAX = 599;
|
|
60
|
-
|
|
61
|
-
/** Bounds the persisted list so a runaway UI can't fill storage. */
|
|
62
|
-
const MAX_RULES = exports.MAX_RULES = 50;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Read the live limit with `useLimit("network.overrideRules")` —
|
|
66
|
-
* this only reports the FREE tier's value. Kept because it is part of the
|
|
67
|
-
* package's public exports.
|
|
68
|
-
*/
|
|
69
|
-
const FREE_TIER_RULE_LIMIT = exports.FREE_TIER_RULE_LIMIT = _sharedUi.TIER_LIMITS["network.overrideRules"].free;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Stamped onto the `NetworkEvent` a rule affected, so the list can badge the
|
|
73
|
-
* row and the detail view can offer "edit / disable the rule that did this".
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A matched rule, normalized into exactly what the interceptor needs — defaults
|
|
78
|
-
* resolved, status clamped, content-type inferred. Keeping normalization in the
|
|
79
|
-
* resolver means `applyToXhr` never has to make a decision.
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
/** The marker recorded for an outcome. */
|
|
83
|
-
function markForOutcome(outcome) {
|
|
84
|
-
return {
|
|
85
|
-
ruleId: outcome.rule.id,
|
|
86
|
-
ruleName: outcome.rule.name,
|
|
87
|
-
kind: outcome.kind,
|
|
88
|
-
delayMs: outcome.delayMs || undefined
|
|
89
|
-
};
|
|
90
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.STATUS_MIN=exports.STATUS_MAX=exports.MAX_RULES=exports.FREE_TIER_RULE_LIMIT=void 0;exports.markForOutcome=markForOutcome;var _sharedUi=require("@buoy-gg/shared-ui");const STATUS_MIN=exports.STATUS_MIN=200;const STATUS_MAX=exports.STATUS_MAX=599;const MAX_RULES=exports.MAX_RULES=50;const FREE_TIER_RULE_LIMIT=exports.FREE_TIER_RULE_LIMIT=_sharedUi.TIER_LIMITS["network.overrideRules"].free;function markForOutcome(e){return{ruleId:e.rule.id,ruleName:e.rule.name,kind:e.kind,delayMs:e.delayMs||void 0}}
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NetworkBodyResolverProvider = NetworkBodyResolverProvider;
|
|
7
|
-
exports.useNetworkBodyResolver = useNetworkBodyResolver;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
/**
|
|
11
|
-
* The full request/response bodies for a single network event, fetched on
|
|
12
|
-
* demand. Either field may be `null` when the event genuinely has no body.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Resolves request/response bodies that were omitted from a synced snapshot.
|
|
17
|
-
*
|
|
18
|
-
* Large bodies (see `networkSyncAdapter`) are stripped from the list snapshot
|
|
19
|
-
* so they aren't re-streamed every ~200ms; the detail view fetches them lazily
|
|
20
|
-
* through this resolver when a request is opened.
|
|
21
|
-
*
|
|
22
|
-
* On the device this is never provided — bodies are always inline — so the
|
|
23
|
-
* detail view simply falls back to the inline data. The desktop dashboard
|
|
24
|
-
* provides a resolver that fetches the body over the devtool protocol.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const NetworkBodyResolverContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
28
|
-
function NetworkBodyResolverProvider({
|
|
29
|
-
resolver,
|
|
30
|
-
children
|
|
31
|
-
}) {
|
|
32
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NetworkBodyResolverContext.Provider, {
|
|
33
|
-
value: resolver,
|
|
34
|
-
children: children
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function useNetworkBodyResolver() {
|
|
38
|
-
return (0, _react.useContext)(NetworkBodyResolverContext);
|
|
39
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NetworkBodyResolverProvider=NetworkBodyResolverProvider;exports.useNetworkBodyResolver=useNetworkBodyResolver;var _react=require("react");var _jsxRuntime=require("react/jsx-runtime");const NetworkBodyResolverContext=(0,_react.createContext)(null);function NetworkBodyResolverProvider({resolver:e,children:r}){return(0,_jsxRuntime.jsx)(NetworkBodyResolverContext.Provider,{value:e,children:r})}function useNetworkBodyResolver(){return(0,_react.useContext)(NetworkBodyResolverContext)}
|