@cascateer/core 2.4.25 → 2.4.26

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.4.25",
3
+ "version": "2.4.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cascateer/core.git"
@@ -19,6 +19,7 @@
19
19
  "devDependencies": {
20
20
  "@eslint/js": "^10.0.1",
21
21
  "@types/lodash": "^4.17.24",
22
+ "@types/node": "^26.0.0",
22
23
  "@types/object-hash": "^3.0.6",
23
24
  "@types/react": "^19.2.17",
24
25
  "globals": "^17.7.0",
@@ -28,7 +29,7 @@
28
29
  "vitest": "^4.1.9"
29
30
  },
30
31
  "dependencies": {
31
- "@cascateer/lib": "^1.0.36",
32
+ "@cascateer/lib": "^1.0.40",
32
33
  "lodash": "^4.18.1",
33
34
  "object-hash": "^3.0.0",
34
35
  "rxjs": "^7.8.2",
package/src/multicast.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { property } from "@cascateer/lib";
2
- import { chain, flatMap } from "@cascateer/lib/observables";
2
+ import { flatMap, reduce } from "@cascateer/lib/observables";
3
+ import assert from "assert";
3
4
  import { partition, thru, uniq, uniqBy } from "lodash";
4
5
  import {
5
6
  distinct,
@@ -84,10 +85,10 @@ self.addEventListener("connect", ({ ports }) => {
84
85
  flatMap(({ ports, actions }) => (ports.includes(port) ? actions : [])),
85
86
  distinct(property("id")),
86
87
  filter((message) => !message.sameOrigin || message.origin === port),
87
- chain(([action, previousAction]) =>
88
- action.type === "seedAction"
89
- ? action
90
- : { ...action, previousId: previousAction!.id },
88
+ reduce(
89
+ ({ id: previousId }, action) =>
90
+ action.type === "seedAction" ? action : { ...action, previousId },
91
+ (action) => (assert(action.type === "seedAction"), action),
91
92
  ),
92
93
  map(({ origin, ...message }) => message),
93
94
  exchangeWith<MulticastClientMessage, MulticastActionMessage<any>>(port),
package/src/store.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { EndoFunction, ExtendableDictionary } from "@cascateer/lib";
2
- import { chain, flatMap } from "@cascateer/lib/observables";
2
+ import { flatMap, reduce } from "@cascateer/lib/observables";
3
+ import assert from "assert";
3
4
  import { constant, Dictionary, mapValues, tap } from "lodash";
4
5
  import {
5
6
  merge,
@@ -221,25 +222,24 @@ export class StoreProvider<Data> extends ExtendableStoreAdapter<
221
222
  new ExtendableDictionary({
222
223
  data: new ComputedSignal({
223
224
  value: merge(seedActions, transformActions).pipe(
224
- chain<MulticastAction<Data>, Data>(
225
- ([action, previousAction], previousStates) => {
225
+ reduce<MulticastAction<Data>, Data>(
226
+ (previousState, action, previousAction) => {
226
227
  console.log(action);
227
228
 
228
229
  if (action.type === "seedAction") {
229
230
  return action.predicate();
230
231
  }
231
232
 
232
- if (
233
- action.previousId !== previousAction?.id ||
234
- !(0 in previousStates)
235
- ) {
236
- throw new Error();
237
- }
233
+ assert(action.previousId !== previousAction?.id);
238
234
 
239
- return tap(action.predicate(previousStates[0]), (state) =>
235
+ return tap(action.predicate(previousState), (state) =>
240
236
  action.callback?.call(null, state),
241
237
  );
242
238
  },
239
+ (action) => (
240
+ assert(action.type === "seedAction"),
241
+ action.predicate()
242
+ ),
243
243
  ),
244
244
  shareReplay(1),
245
245
  ),
package/tsconfig.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "skipLibCheck": true,
15
15
  "strict": true,
16
16
  "target": "ES2022",
17
- "types": ["vite/client"],
17
+ "types": ["node"],
18
18
  "useDefineForClassFields": true
19
19
  },
20
20
  "include": ["src"]