@cascateer/core 2.2.16 → 2.2.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascateer/core",
3
- "version": "2.2.16",
3
+ "version": "2.2.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
package/src/multicast.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { partition, thru, uniq } from "lodash";
1
+ import { partition, thru, uniq, uniqBy } from "lodash";
2
2
  import {
3
+ distinct,
3
4
  filter,
4
5
  groupBy,
5
6
  map,
@@ -10,6 +11,7 @@ import {
10
11
  share,
11
12
  } from "rxjs";
12
13
  import { v4 } from "uuid";
14
+ import { property } from "./lib";
13
15
  import {
14
16
  concat,
15
17
  exchangeWith,
@@ -48,15 +50,18 @@ const actions = proxyReplaySubject<Observable<InMessages>, OutMessages>(
48
50
  group.pipe(
49
51
  scan<InMessages, OutMessages>(
50
52
  (outMessages, inMessages, index) => ({
51
- actions: outMessages.actions.concat(
52
- index === 0
53
- ? {
54
- id: v4(),
55
- type: "seedAction" as const,
56
- data: inMessages.connect.data,
57
- }
58
- : [],
59
- ...inMessages.actions,
53
+ actions: uniqBy(
54
+ outMessages.actions.concat(
55
+ index === 0
56
+ ? {
57
+ id: v4(),
58
+ type: "seedAction" as const,
59
+ data: inMessages.connect.data,
60
+ }
61
+ : [],
62
+ ...inMessages.actions,
63
+ ),
64
+ property("id"),
60
65
  ),
61
66
  ports: uniq(
62
67
  outMessages.ports.concat(inMessages.connect.origin ?? []),
@@ -78,7 +83,7 @@ self.addEventListener("connect", ({ ports }) => {
78
83
  actions.next(
79
84
  actions.pipe(
80
85
  flatMap(({ ports, actions }) => (ports.includes(port) ? actions : [])),
81
- // distinct(property("id")),
86
+ distinct(property("id")),
82
87
  filter((message) => !message.sameOrigin || message.origin === port),
83
88
  sequence(([action, previousAction]) =>
84
89
  action.type === "seedAction"
@@ -1,3 +1,4 @@
1
+ import { tap } from "lodash";
1
2
  import { concatMap, shareReplay, startWith, UnaryFunction } from "rxjs";
2
3
  import { v4 } from "uuid";
3
4
  import { ComputedSignal, ProxySubject } from "../observable";
@@ -90,7 +91,9 @@ export const multicast = <Seed>(
90
91
  data: { key, seed },
91
92
  }),
92
93
  ),
93
- concatMap((message) => key.then((key) => message({ key, id: v4() }))),
94
+ concatMap((message) =>
95
+ key.then((key) => tap(message({ key, id: v4() }), console.log)),
96
+ ),
94
97
  exchangeWith<MulticastHostMessage, MulticastClientMessage>(
95
98
  new SharedWorker(new URL("../multicast.ts", import.meta.url), {
96
99
  type: "module",
package/src/store.ts CHANGED
@@ -204,6 +204,7 @@ export class StoreProvider<Data> extends ExtendableStoreAdapter<
204
204
  actions
205
205
  .pipe(
206
206
  mergeMap(async (event) => {
207
+ console.log(event);
207
208
  if (
208
209
  event.type === "transformAction" &&
209
210
  event.data.key === (await key)