@rotorsoft/act 0.13.0 → 0.14.0
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/README.md +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/state-builder.d.ts +63 -48
- package/dist/@types/state-builder.d.ts.map +1 -1
- package/dist/index.cjs +25 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1585,19 +1585,34 @@ function state(entry) {
|
|
|
1585
1585
|
init(init) {
|
|
1586
1586
|
return {
|
|
1587
1587
|
emits(events) {
|
|
1588
|
-
|
|
1589
|
-
|
|
1588
|
+
const defaultPatch = Object.fromEntries(
|
|
1589
|
+
Object.keys(events).map((k) => [
|
|
1590
|
+
k,
|
|
1591
|
+
({ data }) => data
|
|
1592
|
+
])
|
|
1593
|
+
);
|
|
1594
|
+
const builder = action_builder({
|
|
1595
|
+
events,
|
|
1596
|
+
actions: {},
|
|
1597
|
+
state: stateSchema,
|
|
1598
|
+
name,
|
|
1599
|
+
init,
|
|
1600
|
+
patch: defaultPatch,
|
|
1601
|
+
on: {}
|
|
1602
|
+
});
|
|
1603
|
+
return Object.assign(builder, {
|
|
1604
|
+
patch(customPatch) {
|
|
1590
1605
|
return action_builder({
|
|
1591
1606
|
events,
|
|
1592
1607
|
actions: {},
|
|
1593
1608
|
state: stateSchema,
|
|
1594
1609
|
name,
|
|
1595
1610
|
init,
|
|
1596
|
-
patch:
|
|
1611
|
+
patch: { ...defaultPatch, ...customPatch },
|
|
1597
1612
|
on: {}
|
|
1598
1613
|
});
|
|
1599
1614
|
}
|
|
1600
|
-
};
|
|
1615
|
+
});
|
|
1601
1616
|
}
|
|
1602
1617
|
};
|
|
1603
1618
|
}
|
|
@@ -1620,7 +1635,12 @@ function action_builder(state2) {
|
|
|
1620
1635
|
return { emit };
|
|
1621
1636
|
}
|
|
1622
1637
|
function emit(handler) {
|
|
1623
|
-
|
|
1638
|
+
if (typeof handler === "string") {
|
|
1639
|
+
const eventName = handler;
|
|
1640
|
+
on[action2] = ((payload) => [eventName, payload]);
|
|
1641
|
+
} else {
|
|
1642
|
+
on[action2] = handler;
|
|
1643
|
+
}
|
|
1624
1644
|
return action_builder({
|
|
1625
1645
|
...state2,
|
|
1626
1646
|
actions,
|