@buoy-gg/network 7.0.41 → 7.0.42
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 +2 -2
- 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,56 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deleteNestedDataByPath = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Deletes nested data by path
|
|
9
|
-
*
|
|
10
|
-
* @param {unknown} oldData Data to be updated
|
|
11
|
-
* @param {Array<string>} deletePath Path to the data to be deleted
|
|
12
|
-
* @returns newData without the deleted items by path
|
|
13
|
-
*/
|
|
14
|
-
const deleteNestedDataByPath = (oldData, deletePath) => {
|
|
15
|
-
if (oldData instanceof Map) {
|
|
16
|
-
const newData = new Map(oldData);
|
|
17
|
-
if (deletePath.length === 1) {
|
|
18
|
-
newData.delete(deletePath[0]);
|
|
19
|
-
return newData;
|
|
20
|
-
}
|
|
21
|
-
const [head, ...tail] = deletePath;
|
|
22
|
-
newData.set(head, deleteNestedDataByPath(newData.get(head), tail));
|
|
23
|
-
return newData;
|
|
24
|
-
}
|
|
25
|
-
if (oldData instanceof Set) {
|
|
26
|
-
const setAsArray = deleteNestedDataByPath(Array.from(oldData), deletePath);
|
|
27
|
-
return new Set(setAsArray);
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(oldData)) {
|
|
30
|
-
const newData = [...oldData];
|
|
31
|
-
if (deletePath.length === 1) {
|
|
32
|
-
return newData.filter((_, idx) => idx.toString() !== deletePath[0]);
|
|
33
|
-
}
|
|
34
|
-
const [head, ...tail] = deletePath;
|
|
35
|
-
|
|
36
|
-
// @ts-expect-error NAS
|
|
37
|
-
newData[head] = deleteNestedDataByPath(newData[head], tail);
|
|
38
|
-
return newData;
|
|
39
|
-
}
|
|
40
|
-
if (oldData instanceof Object) {
|
|
41
|
-
const newData = {
|
|
42
|
-
...oldData
|
|
43
|
-
};
|
|
44
|
-
if (deletePath.length === 1) {
|
|
45
|
-
// @ts-expect-error NAS
|
|
46
|
-
delete newData[deletePath[0]];
|
|
47
|
-
return newData;
|
|
48
|
-
}
|
|
49
|
-
const [head, ...tail] = deletePath;
|
|
50
|
-
// @ts-expect-error NAS
|
|
51
|
-
newData[head] = deleteNestedDataByPath(newData[head], tail);
|
|
52
|
-
return newData;
|
|
53
|
-
}
|
|
54
|
-
return oldData;
|
|
55
|
-
};
|
|
56
|
-
exports.deleteNestedDataByPath = deleteNestedDataByPath;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.deleteNestedDataByPath=void 0;const deleteNestedDataByPath=(t,r)=>{if(t instanceof Map){const e=new Map(t);if(r.length===1){e.delete(r[0]);return e}const[n,...s]=r;e.set(n,deleteNestedDataByPath(e.get(n),s));return e}if(t instanceof Set){const e=deleteNestedDataByPath(Array.from(t),r);return new Set(e)}if(Array.isArray(t)){const e=[...t];if(r.length===1){return e.filter((c,i)=>i.toString()!==r[0])}const[n,...s]=r;e[n]=deleteNestedDataByPath(e[n],s);return e}if(t instanceof Object){const e={...t};if(r.length===1){delete e[r[0]];return e}const[n,...s]=r;e[n]=deleteNestedDataByPath(e[n],s);return e}return t};exports.deleteNestedDataByPath=deleteNestedDataByPath;
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ResponseEditorContext = void 0;
|
|
7
|
-
exports.useResponseEditor = useResponseEditor;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
/**
|
|
10
|
-
* What the ported Explorer needs in place of React Query's cache.
|
|
11
|
-
*
|
|
12
|
-
* In the original, every edit ends at
|
|
13
|
-
* `queryClient.setQueryData(activeQuery.queryKey, newData)` and `activeQuery`
|
|
14
|
-
* doubles as the "is this editable" gate — so the whole tree is wired to one
|
|
15
|
-
* specific store. Here that becomes two values in context: the ROOT document
|
|
16
|
-
* (every op rebuilds the whole thing from the root, so each row needs it) and a
|
|
17
|
-
* single `onChange`.
|
|
18
|
-
*
|
|
19
|
-
* Context rather than props because Explorer recurses per node and already
|
|
20
|
-
* threads `activeQuery` down every level; swapping one drilled prop for another
|
|
21
|
-
* would have meant the same plumbing at every call site, and a row deep in a
|
|
22
|
-
* response is exactly where you don't want a missed prop.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const ResponseEditorContext = exports.ResponseEditorContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Null outside a provider, which is how the tree stays READ-ONLY by default —
|
|
29
|
-
* the same role `activeQuery === undefined` played in the original.
|
|
30
|
-
*/
|
|
31
|
-
function useResponseEditor() {
|
|
32
|
-
return (0, _react.useContext)(ResponseEditorContext);
|
|
33
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ResponseEditorContext=void 0;exports.useResponseEditor=useResponseEditor;var _react=require("react");const ResponseEditorContext=exports.ResponseEditorContext=(0,_react.createContext)(null);function useResponseEditor(){return(0,_react.useContext)(ResponseEditorContext)}
|
|
@@ -1,61 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.updateNestedDataByPath = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* updates nested data by path
|
|
9
|
-
*
|
|
10
|
-
* @param {JsonValue} oldData Data to be updated
|
|
11
|
-
* @param {Array<string>} updatePath Path to the data to be updated
|
|
12
|
-
* @param {JsonValue} value New value
|
|
13
|
-
*/
|
|
14
|
-
const updateNestedDataByPath = (oldData, updatePath, value) => {
|
|
15
|
-
if (updatePath.length === 0) {
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
if (oldData instanceof Map) {
|
|
19
|
-
const newData = new Map(oldData);
|
|
20
|
-
if (updatePath.length === 1) {
|
|
21
|
-
newData.set(updatePath[0], value);
|
|
22
|
-
return newData;
|
|
23
|
-
}
|
|
24
|
-
const [head, ...tail] = updatePath;
|
|
25
|
-
const currentValue = newData.get(head);
|
|
26
|
-
newData.set(head, updateNestedDataByPath(currentValue ?? null, tail, value));
|
|
27
|
-
return newData;
|
|
28
|
-
}
|
|
29
|
-
if (oldData instanceof Set) {
|
|
30
|
-
const setAsArray = updateNestedDataByPath(Array.from(oldData), updatePath, value);
|
|
31
|
-
return new Set(Array.isArray(setAsArray) ? setAsArray : []);
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(oldData)) {
|
|
34
|
-
const newData = [...oldData];
|
|
35
|
-
if (updatePath.length === 1) {
|
|
36
|
-
// @ts-expect-error NAS
|
|
37
|
-
newData[updatePath[0]] = value;
|
|
38
|
-
return newData;
|
|
39
|
-
}
|
|
40
|
-
const [head, ...tail] = updatePath;
|
|
41
|
-
// @ts-expect-error NAS
|
|
42
|
-
newData[head] = updateNestedDataByPath(newData[head], tail, value);
|
|
43
|
-
return newData;
|
|
44
|
-
}
|
|
45
|
-
if (oldData instanceof Object) {
|
|
46
|
-
const newData = {
|
|
47
|
-
...oldData
|
|
48
|
-
};
|
|
49
|
-
if (updatePath.length === 1) {
|
|
50
|
-
// @ts-expect-error NAS
|
|
51
|
-
newData[updatePath[0]] = value;
|
|
52
|
-
return newData;
|
|
53
|
-
}
|
|
54
|
-
const [head, ...tail] = updatePath;
|
|
55
|
-
// @ts-expect-error NAS
|
|
56
|
-
newData[head] = updateNestedDataByPath(newData[head], tail, value);
|
|
57
|
-
return newData;
|
|
58
|
-
}
|
|
59
|
-
return oldData;
|
|
60
|
-
};
|
|
61
|
-
exports.updateNestedDataByPath = updateNestedDataByPath;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.updateNestedDataByPath=void 0;const updateNestedDataByPath=(n,e,t)=>{if(e.length===0){return t}if(n instanceof Map){const r=new Map(n);if(e.length===1){r.set(e[0],t);return r}const[s,...i]=e;const c=r.get(s);r.set(s,updateNestedDataByPath(c??null,i,t));return r}if(n instanceof Set){const r=updateNestedDataByPath(Array.from(n),e,t);return new Set(Array.isArray(r)?r:[])}if(Array.isArray(n)){const r=[...n];if(e.length===1){r[e[0]]=t;return r}const[s,...i]=e;r[s]=updateNestedDataByPath(r[s],i,t);return r}if(n instanceof Object){const r={...n};if(e.length===1){r[e[0]]=t;return r}const[s,...i]=e;r[s]=updateNestedDataByPath(r[s],i,t);return r}return n};exports.updateNestedDataByPath=updateNestedDataByPath;
|
|
@@ -1,235 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NetworkConditionsControl = NetworkConditionsControl;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _store = require("./store");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
const options = [{
|
|
13
|
-
profile: "normal",
|
|
14
|
-
label: "No throttling"
|
|
15
|
-
}, {
|
|
16
|
-
profile: "slow",
|
|
17
|
-
label: "Slow"
|
|
18
|
-
}, {
|
|
19
|
-
profile: "verySlow",
|
|
20
|
-
label: "Very slow"
|
|
21
|
-
}, {
|
|
22
|
-
profile: "offline",
|
|
23
|
-
label: "Offline"
|
|
24
|
-
}];
|
|
25
|
-
const summaries = {
|
|
26
|
-
normal: "No added delay",
|
|
27
|
-
slow: "+500 ms before each new request",
|
|
28
|
-
verySlow: "+2 seconds before each new request",
|
|
29
|
-
offline: "New requests fail before sending"
|
|
30
|
-
};
|
|
31
|
-
function NetworkConditionsControl({
|
|
32
|
-
remote
|
|
33
|
-
}) {
|
|
34
|
-
const local = (0, _react.useSyncExternalStore)(_store.subscribeNetworkConditions, _store.getNetworkCondition, _store.getNetworkCondition);
|
|
35
|
-
const localAvailable = (0, _react.useSyncExternalStore)(_store.subscribeNetworkConditions, _store.conditionsCanApply, _store.conditionsCanApply);
|
|
36
|
-
const [expanded, setExpanded] = (0, _react.useState)(false);
|
|
37
|
-
const [error, setError] = (0, _react.useState)();
|
|
38
|
-
const [pending, setPending] = (0, _react.useState)(false);
|
|
39
|
-
const busy = (0, _react.useRef)(false);
|
|
40
|
-
const mounted = (0, _react.useRef)(true);
|
|
41
|
-
(0, _react.useEffect)(() => {
|
|
42
|
-
mounted.current = true;
|
|
43
|
-
return () => {
|
|
44
|
-
mounted.current = false;
|
|
45
|
-
};
|
|
46
|
-
}, []);
|
|
47
|
-
const profile = remote ? remote.profile : local;
|
|
48
|
-
const available = remote ? remote.available : localAvailable;
|
|
49
|
-
const active = profile !== null && profile !== "normal";
|
|
50
|
-
const tint = profile === "offline" ? _sharedUi.night.color.danger : active ? _sharedUi.night.color.warning : _sharedUi.night.color.accent;
|
|
51
|
-
async function select(value) {
|
|
52
|
-
if (!available || busy.current) return;
|
|
53
|
-
if (value === profile) {
|
|
54
|
-
setExpanded(false);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
busy.current = true;
|
|
58
|
-
setPending(true);
|
|
59
|
-
setError(undefined);
|
|
60
|
-
try {
|
|
61
|
-
if (remote) await remote.onChange(value);else (0, _store.setNetworkCondition)(value);
|
|
62
|
-
if (mounted.current) setExpanded(false);
|
|
63
|
-
} catch (failure) {
|
|
64
|
-
if (mounted.current) setError(failure instanceof Error ? failure.message : String(failure));
|
|
65
|
-
} finally {
|
|
66
|
-
busy.current = false;
|
|
67
|
-
if (mounted.current) setPending(false);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const label = options.find(option => option.profile === profile)?.label ?? "Unavailable";
|
|
71
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
72
|
-
style: styles.container,
|
|
73
|
-
testID: "buoy-network-throttling-screen",
|
|
74
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
75
|
-
style: styles.heading,
|
|
76
|
-
children: "Connection profile"
|
|
77
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
78
|
-
testID: "buoy-network-conditions",
|
|
79
|
-
accessibilityRole: "button",
|
|
80
|
-
accessibilityLabel: `Network throttling: ${label}`,
|
|
81
|
-
accessibilityState: {
|
|
82
|
-
expanded,
|
|
83
|
-
disabled: !available || pending
|
|
84
|
-
},
|
|
85
|
-
disabled: !available || pending,
|
|
86
|
-
onPress: () => setExpanded(value => !value),
|
|
87
|
-
style: [styles.dropdown, expanded && styles.dropdownOpen, !available && styles.disabled],
|
|
88
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
89
|
-
style: [styles.value, active && {
|
|
90
|
-
color: tint
|
|
91
|
-
}],
|
|
92
|
-
children: label
|
|
93
|
-
}), pending ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
94
|
-
size: "small",
|
|
95
|
-
color: _sharedUi.night.color.textSecondary
|
|
96
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ChevronDown, {
|
|
97
|
-
size: 16,
|
|
98
|
-
color: _sharedUi.night.color.textSecondary
|
|
99
|
-
})]
|
|
100
|
-
}), expanded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
101
|
-
accessibilityRole: "radiogroup",
|
|
102
|
-
accessibilityLabel: "Connection profile",
|
|
103
|
-
style: styles.options,
|
|
104
|
-
children: options.map(option => {
|
|
105
|
-
const selected = profile === option.profile;
|
|
106
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
107
|
-
testID: `buoy-network-condition-${option.profile}`,
|
|
108
|
-
accessibilityRole: "radio",
|
|
109
|
-
accessibilityLabel: option.label,
|
|
110
|
-
accessibilityState: {
|
|
111
|
-
checked: selected,
|
|
112
|
-
disabled: !available || pending
|
|
113
|
-
},
|
|
114
|
-
disabled: !available || pending,
|
|
115
|
-
onPress: () => void select(option.profile),
|
|
116
|
-
style: [styles.option, selected && styles.selected],
|
|
117
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
118
|
-
style: styles.optionBody,
|
|
119
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
120
|
-
style: [styles.optionTitle, selected && {
|
|
121
|
-
color: tint
|
|
122
|
-
}],
|
|
123
|
-
children: option.label
|
|
124
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
125
|
-
style: styles.caption,
|
|
126
|
-
children: summaries[option.profile]
|
|
127
|
-
})]
|
|
128
|
-
}), selected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Check, {
|
|
129
|
-
size: 16,
|
|
130
|
-
color: tint
|
|
131
|
-
})]
|
|
132
|
-
}, option.profile);
|
|
133
|
-
})
|
|
134
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
135
|
-
style: styles.caption,
|
|
136
|
-
accessibilityLiveRegion: "polite",
|
|
137
|
-
children: pending ? "Applying to device…" : !available ? remote ? "Conditions unavailable on this device" : "Requires a signed-in account and a development build" : profile ? summaries[profile] : "Waiting for device status"
|
|
138
|
-
}), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
139
|
-
accessibilityRole: "alert",
|
|
140
|
-
style: styles.error,
|
|
141
|
-
children: error
|
|
142
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
143
|
-
style: styles.help,
|
|
144
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
145
|
-
style: styles.heading,
|
|
146
|
-
children: "How it works"
|
|
147
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
148
|
-
style: styles.caption,
|
|
149
|
-
children: "Affects new HTTP requests through global fetch and XHR. Slow adds a wait before sending; download speed stays unchanged."
|
|
150
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
151
|
-
style: styles.caption,
|
|
152
|
-
children: "Stays active when you close this tool or pause capture. Choose No throttling to stop. Reloading the app resets it."
|
|
153
|
-
})]
|
|
154
|
-
})]
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
const styles = _reactNative.StyleSheet.create({
|
|
158
|
-
container: {
|
|
159
|
-
padding: _sharedUi.night.gutter,
|
|
160
|
-
gap: 10
|
|
161
|
-
},
|
|
162
|
-
heading: {
|
|
163
|
-
fontSize: _sharedUi.night.font.caption,
|
|
164
|
-
fontWeight: "600",
|
|
165
|
-
color: _sharedUi.night.color.textSecondary
|
|
166
|
-
},
|
|
167
|
-
dropdown: {
|
|
168
|
-
flexDirection: "row",
|
|
169
|
-
alignItems: "center",
|
|
170
|
-
justifyContent: "space-between",
|
|
171
|
-
gap: 12,
|
|
172
|
-
minHeight: 44,
|
|
173
|
-
paddingHorizontal: 12,
|
|
174
|
-
paddingVertical: 10,
|
|
175
|
-
borderRadius: _sharedUi.night.radius.segment,
|
|
176
|
-
borderWidth: 1,
|
|
177
|
-
borderColor: _sharedUi.night.color.separator,
|
|
178
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated
|
|
179
|
-
},
|
|
180
|
-
dropdownOpen: {
|
|
181
|
-
borderColor: _sharedUi.night.color.accentBorderStrong
|
|
182
|
-
},
|
|
183
|
-
value: {
|
|
184
|
-
flex: 1,
|
|
185
|
-
fontSize: _sharedUi.night.font.body,
|
|
186
|
-
color: _sharedUi.night.color.text
|
|
187
|
-
},
|
|
188
|
-
options: {
|
|
189
|
-
padding: 4,
|
|
190
|
-
borderRadius: _sharedUi.night.radius.row,
|
|
191
|
-
borderWidth: 1,
|
|
192
|
-
borderColor: _sharedUi.night.color.border,
|
|
193
|
-
backgroundColor: _sharedUi.night.color.surface
|
|
194
|
-
},
|
|
195
|
-
option: {
|
|
196
|
-
flexDirection: "row",
|
|
197
|
-
alignItems: "center",
|
|
198
|
-
gap: 12,
|
|
199
|
-
minHeight: 54,
|
|
200
|
-
padding: 10,
|
|
201
|
-
borderRadius: _sharedUi.night.radius.segment
|
|
202
|
-
},
|
|
203
|
-
optionBody: {
|
|
204
|
-
flex: 1,
|
|
205
|
-
gap: 4
|
|
206
|
-
},
|
|
207
|
-
optionTitle: {
|
|
208
|
-
fontSize: _sharedUi.night.font.caption,
|
|
209
|
-
fontWeight: "600",
|
|
210
|
-
color: _sharedUi.night.color.text
|
|
211
|
-
},
|
|
212
|
-
selected: {
|
|
213
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated
|
|
214
|
-
},
|
|
215
|
-
disabled: {
|
|
216
|
-
opacity: 0.45
|
|
217
|
-
},
|
|
218
|
-
caption: {
|
|
219
|
-
fontSize: _sharedUi.night.font.caption,
|
|
220
|
-
lineHeight: 19,
|
|
221
|
-
color: _sharedUi.night.color.textSecondary
|
|
222
|
-
},
|
|
223
|
-
help: {
|
|
224
|
-
marginTop: 14,
|
|
225
|
-
paddingTop: 16,
|
|
226
|
-
gap: 10,
|
|
227
|
-
borderTopWidth: 1,
|
|
228
|
-
borderTopColor: _sharedUi.night.color.separator
|
|
229
|
-
},
|
|
230
|
-
error: {
|
|
231
|
-
fontSize: _sharedUi.night.font.caption,
|
|
232
|
-
lineHeight: 18,
|
|
233
|
-
color: _sharedUi.night.color.danger
|
|
234
|
-
}
|
|
235
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NetworkConditionsControl=NetworkConditionsControl;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _store=require("./store");var _jsxRuntime=require("react/jsx-runtime");const options=[{profile:"normal",label:"No throttling"},{profile:"slow",label:"Slow"},{profile:"verySlow",label:"Very slow"},{profile:"offline",label:"Offline"}];const summaries={normal:"No added delay",slow:"+500 ms before each new request",verySlow:"+2 seconds before each new request",offline:"New requests fail before sending"};function NetworkConditionsControl({remote:i}){const b=(0,_react.useSyncExternalStore)(_store.subscribeNetworkConditions,_store.getNetworkCondition,_store.getNetworkCondition);const y=(0,_react.useSyncExternalStore)(_store.subscribeNetworkConditions,_store.conditionsCanApply,_store.conditionsCanApply);const[s,a]=(0,_react.useState)(false);const[g,u]=(0,_react.useState)();const[r,h]=(0,_react.useState)(false);const c=(0,_react.useRef)(false);const l=(0,_react.useRef)(true);(0,_react.useEffect)(()=>{l.current=true;return()=>{l.current=false}},[]);const t=i?i.profile:b;const n=i?i.available:y;const f=t!==null&&t!=="normal";const d=t==="offline"?_sharedUi.night.color.danger:f?_sharedUi.night.color.warning:_sharedUi.night.color.accent;async function x(e){if(!n||c.current)return;if(e===t){a(false);return}c.current=true;h(true);u(void 0);try{if(i)await i.onChange(e);else(0,_store.setNetworkCondition)(e);if(l.current)a(false)}catch(o){if(l.current)u(o instanceof Error?o.message:String(o))}finally{c.current=false;if(l.current)h(false)}}const p=options.find(e=>e.profile===t)?.label??"Unavailable";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,testID:"buoy-network-throttling-screen",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.heading,children:"Connection profile"}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-network-conditions",accessibilityRole:"button",accessibilityLabel:`Network throttling: ${p}`,accessibilityState:{expanded:s,disabled:!n||r},disabled:!n||r,onPress:()=>a(e=>!e),style:[styles.dropdown,s&&styles.dropdownOpen,!n&&styles.disabled],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.value,f&&{color:d}],children:p}),r?(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.textSecondary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textSecondary})]}),s&&(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"radiogroup",accessibilityLabel:"Connection profile",style:styles.options,children:options.map(e=>{const o=t===e.profile;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`buoy-network-condition-${e.profile}`,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:o,disabled:!n||r},disabled:!n||r,onPress:()=>void x(e.profile),style:[styles.option,o&&styles.selected],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.optionBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.optionTitle,o&&{color:d}],children:e.label}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,children:summaries[e.profile]})]}),o&&(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:16,color:d})]},e.profile)})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,accessibilityLiveRegion:"polite",children:r?"Applying to device\u2026":!n?i?"Conditions unavailable on this device":"Requires a signed-in account and a development build":t?summaries[t]:"Waiting for device status"}),!!g&&(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"alert",style:styles.error,children:g}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.help,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.heading,children:"How it works"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,children:"Affects new HTTP requests through global fetch and XHR. Slow adds a wait before sending; download speed stays unchanged."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,children:"Stays active when you close this tool or pause capture. Choose No throttling to stop. Reloading the app resets it."})]})]})}const styles=_reactNative.StyleSheet.create({container:{padding:_sharedUi.night.gutter,gap:10},heading:{fontSize:_sharedUi.night.font.caption,fontWeight:"600",color:_sharedUi.night.color.textSecondary},dropdown:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingHorizontal:12,paddingVertical:10,borderRadius:_sharedUi.night.radius.segment,borderWidth:1,borderColor:_sharedUi.night.color.separator,backgroundColor:_sharedUi.night.color.surfaceElevated},dropdownOpen:{borderColor:_sharedUi.night.color.accentBorderStrong},value:{flex:1,fontSize:_sharedUi.night.font.body,color:_sharedUi.night.color.text},options:{padding:4,borderRadius:_sharedUi.night.radius.row,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},option:{flexDirection:"row",alignItems:"center",gap:12,minHeight:54,padding:10,borderRadius:_sharedUi.night.radius.segment},optionBody:{flex:1,gap:4},optionTitle:{fontSize:_sharedUi.night.font.caption,fontWeight:"600",color:_sharedUi.night.color.text},selected:{backgroundColor:_sharedUi.night.color.surfaceElevated},disabled:{opacity:.45},caption:{fontSize:_sharedUi.night.font.caption,lineHeight:19,color:_sharedUi.night.color.textSecondary},help:{marginTop:14,paddingTop:16,gap:10,borderTopWidth:1,borderTopColor:_sharedUi.night.color.separator},error:{fontSize:_sharedUi.night.font.caption,lineHeight:18,color:_sharedUi.night.color.danger}});
|
|
@@ -1,136 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("react");
|
|
4
|
-
var _client = require("react-dom/client");
|
|
5
|
-
var _vitest = require("vitest");
|
|
6
|
-
var _NetworkConditionsControl = require("./NetworkConditionsControl");
|
|
7
|
-
// @vitest-environment jsdom
|
|
8
|
-
|
|
9
|
-
_vitest.vi.mock("@buoy-gg/shared-ui", async () => ({
|
|
10
|
-
ChevronDown: () => null,
|
|
11
|
-
Check: () => null,
|
|
12
|
-
night: (await _vitest.vi.importActual("../../../../shared/src/ui/night/nightTheme")).night
|
|
13
|
-
}));
|
|
14
|
-
_vitest.vi.mock("react-native", () => ({
|
|
15
|
-
StyleSheet: {
|
|
16
|
-
create: value => value
|
|
17
|
-
},
|
|
18
|
-
View: ({
|
|
19
|
-
children
|
|
20
|
-
}) => /*#__PURE__*/(0, _react.createElement)("div", null, children),
|
|
21
|
-
Text: ({
|
|
22
|
-
children
|
|
23
|
-
}) => /*#__PURE__*/(0, _react.createElement)("span", null, children),
|
|
24
|
-
ActivityIndicator: () => /*#__PURE__*/(0, _react.createElement)("span", null, "pending"),
|
|
25
|
-
TouchableOpacity: ({
|
|
26
|
-
children,
|
|
27
|
-
onPress,
|
|
28
|
-
disabled,
|
|
29
|
-
accessibilityLabel,
|
|
30
|
-
accessibilityState,
|
|
31
|
-
testID
|
|
32
|
-
}) => /*#__PURE__*/(0, _react.createElement)("button", {
|
|
33
|
-
onClick: onPress,
|
|
34
|
-
disabled,
|
|
35
|
-
"aria-label": accessibilityLabel,
|
|
36
|
-
"aria-checked": accessibilityState?.checked,
|
|
37
|
-
"data-testid": testID
|
|
38
|
-
}, children)
|
|
39
|
-
}));
|
|
40
|
-
_vitest.vi.mock("./store", () => ({
|
|
41
|
-
NETWORK_CONDITIONS: {
|
|
42
|
-
normal: {
|
|
43
|
-
label: "Normal"
|
|
44
|
-
},
|
|
45
|
-
slow: {
|
|
46
|
-
label: "Slow"
|
|
47
|
-
},
|
|
48
|
-
verySlow: {
|
|
49
|
-
label: "Very slow"
|
|
50
|
-
},
|
|
51
|
-
offline: {
|
|
52
|
-
label: "Offline"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
getNetworkCondition: () => "normal",
|
|
56
|
-
conditionsCanApply: () => true,
|
|
57
|
-
subscribeNetworkConditions: () => () => {},
|
|
58
|
-
setNetworkCondition: _vitest.vi.fn()
|
|
59
|
-
}));
|
|
60
|
-
let root;
|
|
61
|
-
let container;
|
|
62
|
-
(0, _vitest.beforeEach)(() => {
|
|
63
|
-
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
64
|
-
container = document.createElement("div");
|
|
65
|
-
root = (0, _client.createRoot)(container);
|
|
66
|
-
});
|
|
67
|
-
(0, _vitest.afterEach)(() => (0, _react.act)(() => root.unmount()));
|
|
68
|
-
const button = profile => container.querySelector(`[data-testid="buoy-network-condition-${profile}"]`);
|
|
69
|
-
function render(remote) {
|
|
70
|
-
(0, _react.act)(() => root.render(/*#__PURE__*/(0, _react.createElement)(_NetworkConditionsControl.NetworkConditionsControl, {
|
|
71
|
-
remote
|
|
72
|
-
})));
|
|
73
|
-
}
|
|
74
|
-
const dropdown = () => container.querySelector('[data-testid="buoy-network-conditions"]');
|
|
75
|
-
const open = () => (0, _react.act)(() => dropdown().click());
|
|
76
|
-
(0, _vitest.it)("defaults to a closed No throttling dropdown and closes when the current option is chosen", () => {
|
|
77
|
-
const onChange = _vitest.vi.fn();
|
|
78
|
-
render({
|
|
79
|
-
profile: "normal",
|
|
80
|
-
available: true,
|
|
81
|
-
onChange
|
|
82
|
-
});
|
|
83
|
-
(0, _vitest.expect)(dropdown().textContent).toBe("No throttling");
|
|
84
|
-
(0, _vitest.expect)(button("normal")).toBeNull();
|
|
85
|
-
open();
|
|
86
|
-
(0, _vitest.expect)(["normal", "slow", "verySlow", "offline"].every(value => !!button(value))).toBe(true);
|
|
87
|
-
(0, _react.act)(() => button("normal").click());
|
|
88
|
-
(0, _vitest.expect)(button("normal")).toBeNull();
|
|
89
|
-
(0, _vitest.expect)(onChange).not.toHaveBeenCalled();
|
|
90
|
-
});
|
|
91
|
-
(0, _vitest.it)("blocks duplicate remote changes and waits for the device profile before selecting it", async () => {
|
|
92
|
-
let finish;
|
|
93
|
-
const onChange = _vitest.vi.fn(() => new Promise(resolve => {
|
|
94
|
-
finish = resolve;
|
|
95
|
-
}));
|
|
96
|
-
render({
|
|
97
|
-
profile: "normal",
|
|
98
|
-
available: true,
|
|
99
|
-
onChange
|
|
100
|
-
});
|
|
101
|
-
open();
|
|
102
|
-
(0, _react.act)(() => button("slow").click());
|
|
103
|
-
(0, _vitest.expect)(button("offline").disabled).toBe(true);
|
|
104
|
-
(0, _vitest.expect)(button("normal").getAttribute("aria-checked")).toBe("true");
|
|
105
|
-
(0, _react.act)(() => button("offline").click());
|
|
106
|
-
(0, _vitest.expect)(onChange).toHaveBeenCalledExactlyOnceWith("slow");
|
|
107
|
-
await (0, _react.act)(async () => finish());
|
|
108
|
-
render({
|
|
109
|
-
profile: "slow",
|
|
110
|
-
available: true,
|
|
111
|
-
onChange
|
|
112
|
-
});
|
|
113
|
-
(0, _vitest.expect)(dropdown().textContent).toBe("Slow");
|
|
114
|
-
(0, _vitest.expect)(button("slow")).toBeNull();
|
|
115
|
-
open();
|
|
116
|
-
(0, _vitest.expect)(button("slow").getAttribute("aria-checked")).toBe("true");
|
|
117
|
-
});
|
|
118
|
-
(0, _vitest.it)("reports a remote error, permits retry, and disables unavailable devices", async () => {
|
|
119
|
-
const onChange = _vitest.vi.fn().mockRejectedValue(new Error("Device disconnected"));
|
|
120
|
-
render({
|
|
121
|
-
profile: "normal",
|
|
122
|
-
available: true,
|
|
123
|
-
onChange
|
|
124
|
-
});
|
|
125
|
-
open();
|
|
126
|
-
await (0, _react.act)(async () => button("offline").click());
|
|
127
|
-
(0, _vitest.expect)(container.textContent).toContain("Device disconnected");
|
|
128
|
-
(0, _vitest.expect)(button("offline").disabled).toBe(false);
|
|
129
|
-
render({
|
|
130
|
-
profile: null,
|
|
131
|
-
available: false,
|
|
132
|
-
onChange
|
|
133
|
-
});
|
|
134
|
-
(0, _vitest.expect)(button("normal").disabled).toBe(true);
|
|
135
|
-
(0, _vitest.expect)(container.textContent).toContain("Conditions unavailable on this device");
|
|
136
|
-
});
|
|
1
|
+
"use strict";var _react=require("react");var _client=require("react-dom/client");var _vitest=require("vitest");var _NetworkConditionsControl=require("./NetworkConditionsControl");_vitest.vi.mock("@buoy-gg/shared-ui",async()=>({ChevronDown:()=>null,Check:()=>null,night:(await _vitest.vi.importActual("../../../../shared/src/ui/night/nightTheme")).night}));_vitest.vi.mock("react-native",()=>({StyleSheet:{create:e=>e},View:({children:e})=>(0,_react.createElement)("div",null,e),Text:({children:e})=>(0,_react.createElement)("span",null,e),ActivityIndicator:()=>(0,_react.createElement)("span",null,"pending"),TouchableOpacity:({children:e,onPress:t,disabled:o,accessibilityLabel:n,accessibilityState:a,testID:l})=>(0,_react.createElement)("button",{onClick:t,disabled:o,"aria-label":n,"aria-checked":a?.checked,"data-testid":l},e)}));_vitest.vi.mock("./store",()=>({NETWORK_CONDITIONS:{normal:{label:"Normal"},slow:{label:"Slow"},verySlow:{label:"Very slow"},offline:{label:"Offline"}},getNetworkCondition:()=>"normal",conditionsCanApply:()=>true,subscribeNetworkConditions:()=>()=>{},setNetworkCondition:_vitest.vi.fn()}));let root;let container;(0,_vitest.beforeEach)(()=>{globalThis.IS_REACT_ACT_ENVIRONMENT=true;container=document.createElement("div");root=(0,_client.createRoot)(container)});(0,_vitest.afterEach)(()=>(0,_react.act)(()=>root.unmount()));const button=e=>container.querySelector(`[data-testid="buoy-network-condition-${e}"]`);function render(e){(0,_react.act)(()=>root.render((0,_react.createElement)(_NetworkConditionsControl.NetworkConditionsControl,{remote:e})))}const dropdown=()=>container.querySelector('[data-testid="buoy-network-conditions"]');const open=()=>(0,_react.act)(()=>dropdown().click());(0,_vitest.it)("defaults to a closed No throttling dropdown and closes when the current option is chosen",()=>{const e=_vitest.vi.fn();render({profile:"normal",available:true,onChange:e});(0,_vitest.expect)(dropdown().textContent).toBe("No throttling");(0,_vitest.expect)(button("normal")).toBeNull();open();(0,_vitest.expect)(["normal","slow","verySlow","offline"].every(t=>!!button(t))).toBe(true);(0,_react.act)(()=>button("normal").click());(0,_vitest.expect)(button("normal")).toBeNull();(0,_vitest.expect)(e).not.toHaveBeenCalled()});(0,_vitest.it)("blocks duplicate remote changes and waits for the device profile before selecting it",async()=>{let e;const t=_vitest.vi.fn(()=>new Promise(o=>{e=o}));render({profile:"normal",available:true,onChange:t});open();(0,_react.act)(()=>button("slow").click());(0,_vitest.expect)(button("offline").disabled).toBe(true);(0,_vitest.expect)(button("normal").getAttribute("aria-checked")).toBe("true");(0,_react.act)(()=>button("offline").click());(0,_vitest.expect)(t).toHaveBeenCalledExactlyOnceWith("slow");await(0,_react.act)(async()=>e());render({profile:"slow",available:true,onChange:t});(0,_vitest.expect)(dropdown().textContent).toBe("Slow");(0,_vitest.expect)(button("slow")).toBeNull();open();(0,_vitest.expect)(button("slow").getAttribute("aria-checked")).toBe("true")});(0,_vitest.it)("reports a remote error, permits retry, and disables unavailable devices",async()=>{const e=_vitest.vi.fn().mockRejectedValue(new Error("Device disconnected"));render({profile:"normal",available:true,onChange:e});open();await(0,_react.act)(async()=>button("offline").click());(0,_vitest.expect)(container.textContent).toContain("Device disconnected");(0,_vitest.expect)(button("offline").disabled).toBe(false);render({profile:null,available:false,onChange:e});(0,_vitest.expect)(button("normal").disabled).toBe(true);(0,_vitest.expect)(container.textContent).toContain("Conditions unavailable on this device")});
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NetworkConditionsIcon = NetworkConditionsIcon;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _store = require("./store");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function NetworkConditionsIcon({
|
|
13
|
-
size
|
|
14
|
-
}) {
|
|
15
|
-
const profile = (0, _react.useSyncExternalStore)(_store.subscribeNetworkConditions, _store.getNetworkCondition, _store.getNetworkCondition);
|
|
16
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
17
|
-
accessibilityLabel: profile === "normal" ? "Network" : `Network: ${_store.NETWORK_CONDITIONS[profile].label}`,
|
|
18
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.NetworkIcon, {
|
|
19
|
-
size: size
|
|
20
|
-
}), profile !== "normal" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
21
|
-
testID: "buoy-network-condition-indicator",
|
|
22
|
-
style: {
|
|
23
|
-
position: "absolute",
|
|
24
|
-
top: -6,
|
|
25
|
-
right: -8,
|
|
26
|
-
color: "#FFCC66",
|
|
27
|
-
fontSize: 10,
|
|
28
|
-
fontWeight: "700"
|
|
29
|
-
},
|
|
30
|
-
children: profile === "offline" ? "OFF" : `+${_store.NETWORK_CONDITIONS[profile].delayMs}`
|
|
31
|
-
})]
|
|
32
|
-
});
|
|
33
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NetworkConditionsIcon=NetworkConditionsIcon;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _store=require("./store");var _jsxRuntime=require("react/jsx-runtime");function NetworkConditionsIcon({size:r}){const e=(0,_react.useSyncExternalStore)(_store.subscribeNetworkConditions,_store.getNetworkCondition,_store.getNetworkCondition);return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:e==="normal"?"Network":`Network: ${_store.NETWORK_CONDITIONS[e].label}`,children:[(0,_jsxRuntime.jsx)(_sharedUi.NetworkIcon,{size:r}),e!=="normal"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-network-condition-indicator",style:{position:"absolute",top:-6,right:-8,color:"#FFCC66",fontSize:10,fontWeight:"700"},children:e==="offline"?"OFF":`+${_store.NETWORK_CONDITIONS[e].delayMs}`})]})}
|