@cascateer/core 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/multicast.ts +30 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascateer/core",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
package/src/multicast.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { tap } from "lodash";
2
1
  import {
3
2
  combineLatest,
4
3
  groupBy,
@@ -7,6 +6,7 @@ import {
7
6
  mergeMap,
8
7
  Observable,
9
8
  partition,
9
+ tap,
10
10
  } from "rxjs";
11
11
  import { v4 } from "uuid";
12
12
  import { nonNullable } from "./lib";
@@ -71,31 +71,37 @@ const actions = proxyReplaySubject<
71
71
 
72
72
  self.addEventListener("connect", ({ ports }) => {
73
73
  for (const port of ports) {
74
- actions
75
- .pipe(
76
- flatMap(({ ports, action: { origin, ...message } }) =>
77
- ports.includes(port) && (!message.sameOrigin || origin === port)
78
- ? message
79
- : [],
80
- ),
81
- sequence(([action, previousAction]) =>
82
- action.type === "seedAction"
83
- ? action
84
- : {
85
- ...action,
86
- previousId: nonNullable(previousAction).id,
87
- },
88
- ),
89
- exchangeWith<MulticastClientMessage, MulticastActionMessage<any>>(port),
90
- map((event) => ({ ...event, origin: port })),
91
- (messages) =>
92
- tap(
74
+ actions.next(
75
+ proxyReplaySubject<
76
+ [MulticastConnectMessage<any>, MulticastActionMessage<any>]
77
+ >((sliceActions) =>
78
+ actions.pipe(
79
+ flatMap(({ ports, action: { origin, ...message } }) =>
80
+ ports.includes(port) && (!message.sameOrigin || origin === port)
81
+ ? message
82
+ : [],
83
+ ),
84
+ sequence(([action, previousAction]) =>
85
+ action.type === "seedAction"
86
+ ? action
87
+ : {
88
+ ...action,
89
+ previousId: nonNullable(previousAction).id,
90
+ },
91
+ ),
92
+ exchangeWith<MulticastClientMessage, MulticastActionMessage<any>>(
93
+ port,
94
+ ),
95
+ map((event) => ({ ...event, origin: port })),
96
+ (messages) =>
93
97
  combineLatest(
94
98
  partition(messages, (message) => message.type === "connect"),
95
99
  ),
96
- (sliceActions) => actions.next(sliceActions),
97
- ),
98
- )
99
- .subscribe();
100
+ tap(sliceActions),
101
+ ),
102
+ ),
103
+ );
100
104
  }
101
105
  });
106
+
107
+ actions.subscribe();