valdres 0.2.0-alpha.45 → 0.2.0-alpha.47

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/index.js CHANGED
@@ -628,24 +628,30 @@ var transaction = (callback, data, autoCommit = true) => {
628
628
  }
629
629
  }
630
630
  };
631
- const result = callback(txnSet, txnGet, txnReset, commit, (scopeId, callback2) => {
632
- if (scopeId in data.scopes) {
633
- const scopedData = data.scopes[scopeId];
634
- if (scopedTransactions?.[scopeId] === undefined) {
635
- scopedTransactions ||= {};
636
- transaction((set, get, reset, commit2, scope) => {
637
- scopedTransactions[scopeId] = [
638
- set,
639
- get,
640
- reset,
641
- commit2,
642
- scope
643
- ];
644
- }, scopedData, false);
631
+ const result = callback({
632
+ set: txnSet,
633
+ get: txnGet,
634
+ reset: txnReset,
635
+ commit,
636
+ scope: (scopeId, callback2) => {
637
+ if (scopeId in data.scopes) {
638
+ const scopedData = data.scopes[scopeId];
639
+ if (scopedTransactions?.[scopeId] === undefined) {
640
+ scopedTransactions ||= {};
641
+ transaction(({ set, get, reset, commit: commit2, scope }) => {
642
+ scopedTransactions[scopeId] = [
643
+ set,
644
+ get,
645
+ reset,
646
+ commit2,
647
+ scope
648
+ ];
649
+ }, scopedData, false);
650
+ }
651
+ callback2(...scopedTransactions[scopeId]);
652
+ } else {
653
+ throw new Error(`Scope '${scopeId}' not found. Registered scopes: ${Object.keys(data.scopes).join(", ")}`);
645
654
  }
646
- callback2(...scopedTransactions[scopeId]);
647
- } else {
648
- throw new Error("Scope not found");
649
655
  }
650
656
  });
651
657
  if (autoCommit)
@@ -721,7 +727,7 @@ var store = (id) => {
721
727
  return storeFromStoreData(data);
722
728
  };
723
729
  // package.json
724
- var version = "0.2.0-alpha.44";
730
+ var version = "0.2.0-alpha.46";
725
731
 
726
732
  // src/globalStore.ts
727
733
  if (globalThis.__valdres__) {
@@ -27,3 +27,5 @@ export type { SetAtomValue } from "./src/types/SetAtomValue";
27
27
  export type { State } from "./src/types/State";
28
28
  export type { Store } from "./src/types/Store";
29
29
  export type { StoreData } from "./src/types/StoreData";
30
+ export type { TransactionFn } from "./src/types/TransactionFn";
31
+ export type { TransactionInterface } from "./src/types/TransactionInterface";
@@ -1,4 +1,2 @@
1
- import type { GetValue } from "./GetValue";
2
- import type { ResetAtom } from "./ResetAtom";
3
- import type { SetAtom } from "./SetAtom";
4
- export type TransactionFn = (set: SetAtom, get: GetValue, reset: ResetAtom, commit: () => void, scope: (scopeId: string, callback: TransactionFn) => void) => void;
1
+ import type { TransactionInterface } from "./TransactionInterface";
2
+ export type TransactionFn = (args: TransactionInterface) => void;
@@ -0,0 +1,11 @@
1
+ import type { GetValue } from "./GetValue";
2
+ import type { ResetAtom } from "./ResetAtom";
3
+ import type { SetAtom } from "./SetAtom";
4
+ import type { TransactionFn } from "./TransactionFn";
5
+ export type TransactionInterface = {
6
+ set: SetAtom;
7
+ get: GetValue;
8
+ reset: ResetAtom;
9
+ commit: () => void;
10
+ scope: (scopeId: string, callback: TransactionFn) => void;
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valdres",
3
- "version": "0.2.0-alpha.45",
3
+ "version": "0.2.0-alpha.47",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Eigil Sagafos"
@@ -36,5 +36,5 @@
36
36
  "access": "public",
37
37
  "registry": "https://registry.npmjs.org/"
38
38
  },
39
- "gitHead": "8d9c1d1c9108b11ae9201a2bcd139f384d3884c5"
39
+ "gitHead": "c26d007ebb65bdcfb7fd81122cc51b4bcc8f4d22"
40
40
  }