@vforsh/argus-watcher 0.5.28 → 0.5.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cdp/protocol.d.ts +7 -0
  3. package/dist/cdp/protocol.d.ts.map +1 -1
  4. package/dist/cdp/throttle.d.ts +13 -0
  5. package/dist/cdp/throttle.d.ts.map +1 -1
  6. package/dist/cdp/throttle.js +32 -0
  7. package/dist/cdp/throttle.js.map +1 -1
  8. package/dist/http/endpoints.d.ts +1 -1
  9. package/dist/http/endpoints.d.ts.map +1 -1
  10. package/dist/http/endpoints.js +2 -0
  11. package/dist/http/endpoints.js.map +1 -1
  12. package/dist/http/routes/getThrottle.d.ts.map +1 -1
  13. package/dist/http/routes/getThrottle.js +4 -1
  14. package/dist/http/routes/getThrottle.js.map +1 -1
  15. package/dist/http/routes/index.d.ts.map +1 -1
  16. package/dist/http/routes/index.js +4 -0
  17. package/dist/http/routes/index.js.map +1 -1
  18. package/dist/http/routes/postNetCacheClear.d.ts +2 -0
  19. package/dist/http/routes/postNetCacheClear.d.ts.map +1 -0
  20. package/dist/http/routes/postNetCacheClear.js +13 -0
  21. package/dist/http/routes/postNetCacheClear.js.map +1 -0
  22. package/dist/http/routes/postThrottleNet.d.ts +2 -0
  23. package/dist/http/routes/postThrottleNet.d.ts.map +1 -0
  24. package/dist/http/routes/postThrottleNet.js +17 -0
  25. package/dist/http/routes/postThrottleNet.js.map +1 -0
  26. package/dist/http/server.d.ts +3 -0
  27. package/dist/http/server.d.ts.map +1 -1
  28. package/dist/http/server.js.map +1 -1
  29. package/dist/runtime/watcherSetup.d.ts +2 -0
  30. package/dist/runtime/watcherSetup.d.ts.map +1 -1
  31. package/dist/runtime/watcherSetup.js +2 -0
  32. package/dist/runtime/watcherSetup.js.map +1 -1
  33. package/dist/startWatcherRuntime.d.ts.map +1 -1
  34. package/dist/startWatcherRuntime.js +3 -1
  35. package/dist/startWatcherRuntime.js.map +1 -1
  36. package/dist/throttle/NetworkThrottleController.d.ts +22 -0
  37. package/dist/throttle/NetworkThrottleController.d.ts.map +1 -0
  38. package/dist/throttle/NetworkThrottleController.js +46 -0
  39. package/dist/throttle/NetworkThrottleController.js.map +1 -0
  40. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkThrottleController.d.ts","sourceRoot":"","sources":["../../src/throttle/NetworkThrottleController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,MAAM,MAAM,yBAAyB,GAAG;IACvC,SAAS,EAAE,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,WAAW,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAA;IACzF,UAAU,EAAE,CAAC,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;IAClH,YAAY,EAAE,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAA;IACzF,QAAQ,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtD,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,QAAO,yBAoClD,CAAA"}
@@ -0,0 +1,46 @@
1
+ import { applyNetworkThrottle, clearNetworkThrottle } from '../cdp/throttle.js';
2
+ import { createStickyController } from '../stickyController.js';
3
+ /**
4
+ * Desired network conditions, re-applied on every attach until cleared.
5
+ *
6
+ * Chrome drops the conditions with the CDP session that set them, which is why the watcher has
7
+ * to own them: a one-shot script loses the throttle as soon as it disconnects. Within a session
8
+ * they survive reloads and cross-site navigations on their own.
9
+ *
10
+ * Always driven with the page session. Conditions cover the requests of that one target, so
11
+ * out-of-process iframes and workers of the page keep their normal network.
12
+ */
13
+ export const createNetworkThrottleController = () => {
14
+ const sticky = createStickyController({
15
+ label: 'Network throttle',
16
+ apply: applyNetworkThrottle,
17
+ clear: clearNetworkThrottle,
18
+ });
19
+ /**
20
+ * Applying takes two CDP round trips, so an overlapping clear could land between them and be
21
+ * undone by the second: Chrome throttled, status reporting `none`. Mutations run one at a time.
22
+ */
23
+ let tail = Promise.resolve();
24
+ const serialize = (operation) => {
25
+ const result = tail.then(operation);
26
+ tail = result.catch(() => undefined);
27
+ return result;
28
+ };
29
+ return {
30
+ getStatus: (ctx) => {
31
+ const { applied, state, lastError } = sticky.getState();
32
+ // The sticky flag is only refreshed by the next set or attach, so it outlives the session it describes.
33
+ return { applied: applied && ctx.attached, state, lastError };
34
+ },
35
+ setDesired: (desired, session) => serialize(async () => {
36
+ const { attached, applied, state, lastError } = await sticky.setDesired(desired, session);
37
+ return { ok: true, attached, applied, state, ...(lastError ? { error: lastError } : {}) };
38
+ }),
39
+ clearDesired: (session) => serialize(async () => {
40
+ const { attached, applied, lastError } = await sticky.clearDesired(session);
41
+ return { ok: true, attached, applied, state: null, ...(lastError ? { error: lastError } : {}) };
42
+ }),
43
+ onAttach: (session) => serialize(() => sticky.onAttach(session)),
44
+ };
45
+ };
46
+ //# sourceMappingURL=NetworkThrottleController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkThrottleController.js","sourceRoot":"","sources":["../../src/throttle/NetworkThrottleController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAS/D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAA8B,EAAE;IAC9E,MAAM,M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EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;YAC3E,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;QAChG,CAAC,CAAC;QACH,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KAChE,CAAA;AACF,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vforsh/argus-watcher",
3
- "version": "0.5.28",
3
+ "version": "0.5.29",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vforsh/argus.git",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@jridgewell/trace-mapping": "^0.3.31",
30
- "@vforsh/argus-core": "^0.5.21",
30
+ "@vforsh/argus-core": "^0.5.22",
31
31
  "emittery": "^1.2.0"
32
32
  },
33
33
  "scripts": {