@rotorsoft/act 0.23.2 → 0.24.1
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/dist/.tsbuildinfo +1 -1
- package/dist/@types/act-builder.d.ts +2 -2
- package/dist/@types/act-builder.d.ts.map +1 -1
- package/dist/@types/act.d.ts +2 -2
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/merge.d.ts.map +1 -1
- package/dist/@types/projection-builder.d.ts +1 -1
- package/dist/@types/slice-builder.d.ts +3 -3
- package/dist/@types/slice-builder.d.ts.map +1 -1
- package/dist/@types/state-builder.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +19 -9
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +2 -2
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/index.cjs +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1483,15 +1483,35 @@ function registerState(state2, states, actions, events) {
|
|
|
1483
1483
|
}
|
|
1484
1484
|
for (const name of Object.keys(state2.events)) {
|
|
1485
1485
|
if (existing.events[name] === state2.events[name]) continue;
|
|
1486
|
+
if (existing.events[name]) continue;
|
|
1486
1487
|
if (events[name]) throw new Error(`Duplicate event "${name}"`);
|
|
1487
1488
|
}
|
|
1489
|
+
const mergedPatch = { ...existing.patch };
|
|
1490
|
+
for (const name of Object.keys(state2.patch)) {
|
|
1491
|
+
const existingP = existing.patch[name];
|
|
1492
|
+
const incomingP = state2.patch[name];
|
|
1493
|
+
if (!existingP) {
|
|
1494
|
+
mergedPatch[name] = incomingP;
|
|
1495
|
+
} else {
|
|
1496
|
+
const existingIsDefault = existingP._passthrough;
|
|
1497
|
+
const incomingIsDefault = incomingP._passthrough;
|
|
1498
|
+
if (!existingIsDefault && !incomingIsDefault && existingP !== incomingP) {
|
|
1499
|
+
throw new Error(
|
|
1500
|
+
`Duplicate custom patch for event "${name}" in state "${state2.name}"`
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
if (existingIsDefault && !incomingIsDefault) {
|
|
1504
|
+
mergedPatch[name] = incomingP;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1488
1508
|
const merged = {
|
|
1489
1509
|
...existing,
|
|
1490
1510
|
state: mergeSchemas(existing.state, state2.state, state2.name),
|
|
1491
1511
|
init: mergeInits(existing.init, state2.init),
|
|
1492
1512
|
events: { ...existing.events, ...state2.events },
|
|
1493
1513
|
actions: { ...existing.actions, ...state2.actions },
|
|
1494
|
-
patch:
|
|
1514
|
+
patch: mergedPatch,
|
|
1495
1515
|
on: { ...existing.on, ...state2.on },
|
|
1496
1516
|
given: { ...existing.given, ...state2.given },
|
|
1497
1517
|
snap: state2.snap || existing.snap
|
|
@@ -1772,10 +1792,11 @@ function state(entry) {
|
|
|
1772
1792
|
return {
|
|
1773
1793
|
emits(events) {
|
|
1774
1794
|
const defaultPatch = Object.fromEntries(
|
|
1775
|
-
Object.keys(events).map((k) =>
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1795
|
+
Object.keys(events).map((k) => {
|
|
1796
|
+
const fn = ({ data }) => data;
|
|
1797
|
+
fn._passthrough = true;
|
|
1798
|
+
return [k, fn];
|
|
1799
|
+
})
|
|
1779
1800
|
);
|
|
1780
1801
|
const builder = action_builder({
|
|
1781
1802
|
events,
|