@matter/general 0.12.4-alpha.0-20250211-56b2c53a0 → 0.12.4-alpha.0-20250213-1187f81eb

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.
Files changed (138) hide show
  1. package/dist/cjs/MatterError.d.ts +12 -0
  2. package/dist/cjs/MatterError.d.ts.map +1 -1
  3. package/dist/cjs/MatterError.js +12 -0
  4. package/dist/cjs/MatterError.js.map +1 -1
  5. package/dist/cjs/index.d.ts +1 -0
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/index.js +1 -0
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/log/Logger.d.ts.map +1 -1
  10. package/dist/cjs/log/Logger.js +2 -0
  11. package/dist/cjs/log/Logger.js.map +1 -1
  12. package/dist/cjs/time/Time.d.ts +1 -1
  13. package/dist/cjs/time/Time.d.ts.map +1 -1
  14. package/dist/cjs/time/Time.js +2 -2
  15. package/dist/cjs/time/Time.js.map +1 -1
  16. package/dist/cjs/transaction/Participant.d.ts +47 -0
  17. package/dist/cjs/transaction/Participant.d.ts.map +1 -0
  18. package/dist/cjs/transaction/Participant.js +22 -0
  19. package/dist/cjs/transaction/Participant.js.map +6 -0
  20. package/dist/cjs/transaction/Resource.d.ts +29 -0
  21. package/dist/cjs/transaction/Resource.d.ts.map +1 -0
  22. package/dist/cjs/transaction/Resource.js +40 -0
  23. package/dist/cjs/transaction/Resource.js.map +6 -0
  24. package/dist/cjs/transaction/ResourceSet.d.ts +36 -0
  25. package/dist/cjs/transaction/ResourceSet.d.ts.map +1 -0
  26. package/dist/cjs/transaction/ResourceSet.js +155 -0
  27. package/dist/cjs/transaction/ResourceSet.js.map +6 -0
  28. package/dist/cjs/transaction/Status.d.ts +49 -0
  29. package/dist/cjs/transaction/Status.d.ts.map +1 -0
  30. package/dist/cjs/transaction/Status.js +55 -0
  31. package/dist/cjs/transaction/Status.js.map +6 -0
  32. package/dist/cjs/transaction/Transaction.d.ts +197 -0
  33. package/dist/cjs/transaction/Transaction.d.ts.map +1 -0
  34. package/dist/cjs/transaction/Transaction.js +50 -0
  35. package/dist/cjs/transaction/Transaction.js.map +6 -0
  36. package/dist/cjs/transaction/Tx.d.ts +47 -0
  37. package/dist/cjs/transaction/Tx.d.ts.map +1 -0
  38. package/dist/cjs/transaction/Tx.js +586 -0
  39. package/dist/cjs/transaction/Tx.js.map +6 -0
  40. package/dist/cjs/transaction/errors.d.ts +52 -0
  41. package/dist/cjs/transaction/errors.d.ts.map +1 -0
  42. package/dist/cjs/transaction/errors.js +47 -0
  43. package/dist/cjs/transaction/errors.js.map +6 -0
  44. package/dist/cjs/transaction/index.d.ts +8 -0
  45. package/dist/cjs/transaction/index.d.ts.map +1 -0
  46. package/dist/cjs/transaction/index.js +25 -0
  47. package/dist/cjs/transaction/index.js.map +6 -0
  48. package/dist/cjs/util/Cancelable.d.ts +101 -0
  49. package/dist/cjs/util/Cancelable.d.ts.map +1 -0
  50. package/dist/cjs/util/Cancelable.js +279 -0
  51. package/dist/cjs/util/Cancelable.js.map +6 -0
  52. package/dist/cjs/util/Observable.js +1 -1
  53. package/dist/cjs/util/Observable.js.map +1 -1
  54. package/dist/cjs/util/Promises.d.ts +0 -15
  55. package/dist/cjs/util/Promises.d.ts.map +1 -1
  56. package/dist/cjs/util/Promises.js +0 -33
  57. package/dist/cjs/util/Promises.js.map +1 -1
  58. package/dist/cjs/util/index.d.ts +1 -0
  59. package/dist/cjs/util/index.d.ts.map +1 -1
  60. package/dist/cjs/util/index.js +1 -0
  61. package/dist/cjs/util/index.js.map +1 -1
  62. package/dist/esm/MatterError.d.ts +12 -0
  63. package/dist/esm/MatterError.d.ts.map +1 -1
  64. package/dist/esm/MatterError.js +12 -0
  65. package/dist/esm/MatterError.js.map +1 -1
  66. package/dist/esm/index.d.ts +1 -0
  67. package/dist/esm/index.d.ts.map +1 -1
  68. package/dist/esm/index.js +1 -0
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/log/Logger.d.ts.map +1 -1
  71. package/dist/esm/log/Logger.js +2 -0
  72. package/dist/esm/log/Logger.js.map +1 -1
  73. package/dist/esm/time/Time.d.ts +1 -1
  74. package/dist/esm/time/Time.d.ts.map +1 -1
  75. package/dist/esm/time/Time.js +1 -1
  76. package/dist/esm/transaction/Participant.d.ts +47 -0
  77. package/dist/esm/transaction/Participant.d.ts.map +1 -0
  78. package/dist/esm/transaction/Participant.js +6 -0
  79. package/dist/esm/transaction/Participant.js.map +6 -0
  80. package/dist/esm/transaction/Resource.d.ts +29 -0
  81. package/dist/esm/transaction/Resource.d.ts.map +1 -0
  82. package/dist/esm/transaction/Resource.js +20 -0
  83. package/dist/esm/transaction/Resource.js.map +6 -0
  84. package/dist/esm/transaction/ResourceSet.d.ts +36 -0
  85. package/dist/esm/transaction/ResourceSet.d.ts.map +1 -0
  86. package/dist/esm/transaction/ResourceSet.js +135 -0
  87. package/dist/esm/transaction/ResourceSet.js.map +6 -0
  88. package/dist/esm/transaction/Status.d.ts +49 -0
  89. package/dist/esm/transaction/Status.d.ts.map +1 -0
  90. package/dist/esm/transaction/Status.js +35 -0
  91. package/dist/esm/transaction/Status.js.map +6 -0
  92. package/dist/esm/transaction/Transaction.d.ts +197 -0
  93. package/dist/esm/transaction/Transaction.d.ts.map +1 -0
  94. package/dist/esm/transaction/Transaction.js +30 -0
  95. package/dist/esm/transaction/Transaction.js.map +6 -0
  96. package/dist/esm/transaction/Tx.d.ts +47 -0
  97. package/dist/esm/transaction/Tx.d.ts.map +1 -0
  98. package/dist/esm/transaction/Tx.js +566 -0
  99. package/dist/esm/transaction/Tx.js.map +6 -0
  100. package/dist/esm/transaction/errors.d.ts +52 -0
  101. package/dist/esm/transaction/errors.d.ts.map +1 -0
  102. package/dist/esm/transaction/errors.js +27 -0
  103. package/dist/esm/transaction/errors.js.map +6 -0
  104. package/dist/esm/transaction/index.d.ts +8 -0
  105. package/dist/esm/transaction/index.d.ts.map +1 -0
  106. package/dist/esm/transaction/index.js +8 -0
  107. package/dist/esm/transaction/index.js.map +6 -0
  108. package/dist/esm/util/Cancelable.d.ts +101 -0
  109. package/dist/esm/util/Cancelable.d.ts.map +1 -0
  110. package/dist/esm/util/Cancelable.js +259 -0
  111. package/dist/esm/util/Cancelable.js.map +6 -0
  112. package/dist/esm/util/Observable.js +1 -1
  113. package/dist/esm/util/Observable.js.map +1 -1
  114. package/dist/esm/util/Promises.d.ts +0 -15
  115. package/dist/esm/util/Promises.d.ts.map +1 -1
  116. package/dist/esm/util/Promises.js +0 -33
  117. package/dist/esm/util/Promises.js.map +1 -1
  118. package/dist/esm/util/index.d.ts +1 -0
  119. package/dist/esm/util/index.d.ts.map +1 -1
  120. package/dist/esm/util/index.js +1 -0
  121. package/dist/esm/util/index.js.map +1 -1
  122. package/package.json +2 -2
  123. package/src/MatterError.ts +18 -0
  124. package/src/index.ts +1 -0
  125. package/src/log/Logger.ts +3 -0
  126. package/src/time/Time.ts +1 -1
  127. package/src/transaction/Participant.ts +54 -0
  128. package/src/transaction/Resource.ts +39 -0
  129. package/src/transaction/ResourceSet.ts +160 -0
  130. package/src/transaction/Status.ts +68 -0
  131. package/src/transaction/Transaction.ts +190 -0
  132. package/src/transaction/Tx.ts +734 -0
  133. package/src/transaction/errors.ts +53 -0
  134. package/src/transaction/index.ts +8 -0
  135. package/src/util/Cancelable.ts +380 -0
  136. package/src/util/Observable.ts +1 -1
  137. package/src/util/Promises.ts +0 -52
  138. package/src/util/index.ts +1 -0
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { TransactionFlowError } from "./errors.js";
7
+ var Status = /* @__PURE__ */ ((Status2) => {
8
+ Status2["ReadOnly"] = "read only";
9
+ Status2["Shared"] = "shared";
10
+ Status2["Waiting"] = "waiting";
11
+ Status2["Exclusive"] = "exclusive";
12
+ Status2["CommittingPhaseOne"] = "committing phase one";
13
+ Status2["CommittingPhaseTwo"] = "committing phase two";
14
+ Status2["RollingBack"] = "rolling back";
15
+ Status2["Destroyed"] = "destroyed";
16
+ return Status2;
17
+ })(Status || {});
18
+ ((Status2) => {
19
+ function assert(transaction, acceptable, target) {
20
+ if (!acceptable.includes(transaction.status)) {
21
+ throw new TransactionFlowError(
22
+ `Cannot transition transaction from ${formatStatus(transaction.status)} to ${formatStatus(target)}`
23
+ );
24
+ }
25
+ }
26
+ Status2.assert = assert;
27
+ function formatStatus(status) {
28
+ return `<${status}>`;
29
+ }
30
+ Status2.formatStatus = formatStatus;
31
+ })(Status || (Status = {}));
32
+ export {
33
+ Status
34
+ };
35
+ //# sourceMappingURL=Status.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/transaction/Status.ts"],
4
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,4BAA4B;AAM9B,IAAK,SAAL,kBAAKA,YAAL;AAIH,EAAAA,QAAA,cAAW;AAKX,EAAAA,QAAA,YAAS;AAKT,EAAAA,QAAA,aAAU;AAMV,EAAAA,QAAA,eAAY;AAKZ,EAAAA,QAAA,wBAAqB;AAKrB,EAAAA,QAAA,wBAAqB;AAKrB,EAAAA,QAAA,iBAAc;AAKd,EAAAA,QAAA,eAAY;AAxCJ,SAAAA;AAAA,GAAA;AAAA,CA2CL,CAAUA,YAAV;AACI,WAAS,OAAO,aAA0B,YAAsB,QAAgB;AACnF,QAAI,CAAC,WAAW,SAAS,YAAY,MAAM,GAAG;AAC1C,YAAM,IAAI;AAAA,QACN,sCAAsC,aAAa,YAAY,MAAM,CAAC,OAAO,aAAa,MAAM,CAAC;AAAA,MACrG;AAAA,IACJ;AAAA,EACJ;AANO,EAAAA,QAAS;AAQT,WAAS,aAAa,QAAgB;AACzC,WAAO,IAAI,MAAM;AAAA,EACrB;AAFO,EAAAA,QAAS;AAAA,GATH;",
5
+ "names": ["Status"]
6
+ }
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { MaybePromise } from "#util/Promises.js";
7
+ import { Participant } from "./Participant.js";
8
+ import { Resource } from "./Resource.js";
9
+ import { ResourceSet } from "./ResourceSet.js";
10
+ import { Status } from "./Status.js";
11
+ /**
12
+ * .
13
+ *
14
+ * Transactions are either shared (for reads) or exclusive (for writes). Exclusive transactions do not block shared
15
+ * transactions but state updates will not be visible until the transaction completes.
16
+ *
17
+ * Writes do block other writes. Transactions start automatically when a write occurs. Since this usually happens
18
+ * synchronously, the best Matter.js can do is throw an error if two write transactions would conflict. However, you
19
+ * can avoid this by using {@link begin} which will wait for other transactions to complete before acquiring resource
20
+ * locks.
21
+ *
22
+ * Persistence is implemented by a list of participants. Commits are two phase. If an error throws in phase one all
23
+ * participants roll back. An error in phase 2 could result in data inconsistency as we don't have any form of retry as
24
+ * of yet.
25
+ *
26
+ * TODO - does prevent deadlock but we should probably add a timeout for resource locking
27
+ */
28
+ export interface Transaction {
29
+ /**
30
+ * Diagnostic description of the transaction's source.
31
+ */
32
+ readonly via: string;
33
+ /**
34
+ * The status of the transaction.
35
+ */
36
+ readonly status: Status;
37
+ /**
38
+ * Transaction participants.
39
+ */
40
+ readonly participants: Set<Participant>;
41
+ /**
42
+ * Resources addressed by the participants.
43
+ */
44
+ readonly resources: Set<Resource>;
45
+ /**
46
+ * The transactions currently blocking this transaction, if any.
47
+ */
48
+ readonly waitingOn: Iterable<Transaction> | undefined;
49
+ /**
50
+ * Listen for transaction commit or roll back. This may occur more than once for a given.
51
+ */
52
+ onShared(actor: () => void, once?: boolean): void;
53
+ /**
54
+ * Listen for {@link Transaction.status} close.
55
+ */
56
+ onClose(actor: () => void): void;
57
+ /**
58
+ * Add {@link Resources} to the transaction.
59
+ *
60
+ * If the transaction is exclusive (writing) the transaction will acquire the lock on each {@link ResourceType},
61
+ * waiting for other writers to finish if necessary.
62
+ */
63
+ addResources(...resources: Resource[]): Promise<void>;
64
+ /**
65
+ * Add {@link ResourceType}s to the transaction synchronously.
66
+ *
67
+ * Unlike {@link addResources}, this method will throw an error if the
68
+ * transaction is exclusive and the resources cannot be locked.
69
+ */
70
+ addResourcesSync(...resources: Resource[]): void;
71
+ /**
72
+ * Begin an exclusive transaction.
73
+ *
74
+ * Transactions begin automatically on write but there are a few reasons you may want to use this method to start an
75
+ * exclusive transaction explicitly:
76
+ *
77
+ * 1. Automatic transactions are started in a synchronous context so conflicting transactions will throw an error.
78
+ * If you start a transaction, your code will await any transaction that would otherwise throw an error.
79
+ *
80
+ * 2. Transaction isolation means your view of data may become stale if a write occurs in another transaction.
81
+ * Once you start a transaction you block other writers so can be assured you're dealing with newest state.
82
+ *
83
+ * 3. Say transaction A has an exclusive lock on resource 1 and awaits resource 2. Transaction B has an exclusive
84
+ * lock on resource 2. Transaction B cannot then await resource 1 without causing a deadlock. Matter.js will
85
+ * detect the deadlock and throw an error. One way to prevent this is to begin a transaction and acquire locks
86
+ * in a specific order.
87
+ *
88
+ * None of the issues above are likely and are probably not a concern for your application. If you do encounter
89
+ * these issues the error message will suggest solutions.
90
+ */
91
+ begin(): Promise<void>;
92
+ /**
93
+ * Begin an exclusive transaction in a synchronous context.
94
+ *
95
+ * Unlike {@link begin}, this method will throw an error if any participant has already joined an exclusive
96
+ * transaction.
97
+ */
98
+ beginSync(): void;
99
+ /**
100
+ * Add {@link ParticipantType}s to the transaction.
101
+ */
102
+ addParticipants(...participants: Participant[]): void;
103
+ /**
104
+ * Retrieve a participant with a specific role.
105
+ */
106
+ getParticipant(role: {}): Participant | undefined;
107
+ /**
108
+ * Commit the transaction.
109
+ *
110
+ * Matter.js commits automatically when an interaction completes. You may commit manually to publish your changes
111
+ * mid-interaction.
112
+ *
113
+ * After commit an exclusive transaction becomes shared and data references refresh to the most recent value.
114
+ */
115
+ commit(): MaybePromise;
116
+ /**
117
+ * Roll back the transaction.
118
+ *
119
+ * Matter.js rolls back automatically when an interaction fails. You may roll back manually to undo your changes
120
+ * mid-interaction.
121
+ *
122
+ * After rollback an exclusive transaction becomes shared and data references refresh to the most recent value.
123
+ */
124
+ rollback(): MaybePromise;
125
+ /**
126
+ * Wait for a set of transactions to complete.
127
+ *
128
+ * @param others the set of transactions to await; cleared on return
129
+ */
130
+ waitFor(others: Set<Transaction>): Promise<void>;
131
+ }
132
+ type StatusType = Status;
133
+ type ResourceType = Resource;
134
+ type ResourceSetType = ResourceSet;
135
+ type ParticipantType = Participant;
136
+ export declare const Transaction: {
137
+ /**
138
+ * Perform a transactional operation. This is the only way to obtain a read/write transaction.
139
+ *
140
+ * The transaction will commit automatically if it is exclusive (write mode) after the actor returns.
141
+ *
142
+ * The transaction is destroyed when {@link act} returns. You will receive an error if you access it after it is
143
+ * destroyed.
144
+ */
145
+ act<T>(via: string, actor: (transaction: Transaction) => MaybePromise<T>): MaybePromise<T>;
146
+ ReadOnly: {
147
+ "__#14458@#participants": Set<Participant>;
148
+ "__#14458@#roles": Map<{}, Participant>;
149
+ "__#14458@#resources": Set<Resource>;
150
+ "__#14458@#status": Status;
151
+ "__#14458@#waitingOn"?: Iterable<Transaction>;
152
+ "__#14458@#via": string;
153
+ "__#14458@#shared"?: import("../index.js").Observable<[]>;
154
+ "__#14458@#closed"?: import("../index.js").Observable<[]>;
155
+ "__#14458@#isAsync": boolean;
156
+ close(): void;
157
+ readonly via: string;
158
+ readonly status: Status;
159
+ readonly participants: Set<Participant>;
160
+ readonly resources: Set<Resource>;
161
+ readonly waitingOn: Iterable<Transaction> | undefined;
162
+ get isAsync(): boolean;
163
+ set isAsync(isAsync: true);
164
+ onShared(listener: () => void, once?: boolean): void;
165
+ onClose(listener: () => void): void;
166
+ addResources(...resources: Resource[]): Promise<void>;
167
+ addResourcesSync(...resources: Resource[]): void;
168
+ begin(): Promise<void>;
169
+ beginSync(): void;
170
+ addParticipants(...participants: Participant[]): void;
171
+ getParticipant(role: {}): Participant | undefined;
172
+ commit(): MaybePromise;
173
+ rollback(): Promise<void> | undefined;
174
+ waitFor(others: Set<Transaction>): Promise<void>;
175
+ toString(): string;
176
+ "__#14458@#finalize"(status: Status, why: string, finalizer: () => MaybePromise): Promise<void> | undefined;
177
+ "__#14458@#executePreCommit"(): MaybePromise<void>;
178
+ "__#14458@#executeCommit"(): MaybePromise;
179
+ "__#14458@#executeCommit1"(): MaybePromise;
180
+ "__#14458@#executeCommit2"(): Promise<void> | undefined;
181
+ "__#14458@#executePostCommit"(participants: Participant[]): MaybePromise;
182
+ "__#14458@#executeRollback"(): Promise<void> | undefined;
183
+ "__#14458@#locksChanged"(resources: Set<Resource>, how?: string): void;
184
+ "__#14458@#assertAvailable"(): void;
185
+ };
186
+ Status: typeof Status;
187
+ Resource: typeof Resource;
188
+ [Symbol.toStringTag]: string;
189
+ };
190
+ export declare namespace Transaction {
191
+ type Status = StatusType;
192
+ type Resource = ResourceType;
193
+ type ResourceSet = ResourceSetType;
194
+ type Participant = ParticipantType;
195
+ }
196
+ export {};
197
+ //# sourceMappingURL=Transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/Transaction.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,GAAG,CA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AOG;QACC,CAAC,OAAO,MAAM,SAAS,CAAC,WAAW,EAAE,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAY7F,CAAC;AAKF,yBAAiB,WAAW,CAAC;IACzB,KAAY,MAAM,GAAG,UAAU,CAAC;IAEhC,KAAY,QAAQ,GAAG,YAAY,CAAC;IAEpC,KAAY,WAAW,GAAG,eAAe,CAAC;IAE1C,KAAY,WAAW,GAAG,eAAe,CAAC;CAC7C"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Resource } from "./Resource.js";
7
+ import { Status } from "./Status.js";
8
+ import { ReadOnlyTransaction, act } from "./Tx.js";
9
+ const Transaction = {
10
+ /**
11
+ * Perform a transactional operation. This is the only way to obtain a read/write transaction.
12
+ *
13
+ * The transaction will commit automatically if it is exclusive (write mode) after the actor returns.
14
+ *
15
+ * The transaction is destroyed when {@link act} returns. You will receive an error if you access it after it is
16
+ * destroyed.
17
+ */
18
+ act(via, actor) {
19
+ return act(via, actor);
20
+ },
21
+ ReadOnly: ReadOnlyTransaction,
22
+ Status,
23
+ Resource,
24
+ [Symbol.toStringTag]: "Transaction"
25
+ };
26
+ Transaction.act = act;
27
+ export {
28
+ Transaction
29
+ };
30
+ //# sourceMappingURL=Transaction.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/transaction/Transaction.ts"],
4
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AACvB,SAAS,qBAAqB,WAAW;AAgJlC,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASvB,IAAO,KAAa,OAAuE;AAEvF,WAAO,IAAI,KAAK,KAAK;AAAA,EACzB;AAAA,EAEA,UAAU;AAAA,EAEV;AAAA,EAEA;AAAA,EAEA,CAAC,OAAO,WAAW,GAAG;AAC1B;AAGA,YAAY,MAAM;",
5
+ "names": []
6
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { MaybePromise } from "#util/Promises.js";
7
+ import type { Participant } from "./Participant.js";
8
+ import type { Resource } from "./Resource.js";
9
+ import { Status } from "./Status.js";
10
+ import { Transaction } from "./Transaction.js";
11
+ /**
12
+ * This is the only public interface to this file.
13
+ */
14
+ export declare function act<T>(via: string, actor: (transaction: Transaction) => T): T;
15
+ /**
16
+ * The concrete implementation of the Transaction interface.
17
+ */
18
+ declare class Tx implements Transaction {
19
+ #private;
20
+ constructor(via: string, readonly?: boolean);
21
+ close(): void;
22
+ get via(): string;
23
+ get status(): Status;
24
+ get participants(): Set<Participant>;
25
+ get resources(): Set<Resource>;
26
+ get waitingOn(): Iterable<Transaction> | undefined;
27
+ get isAsync(): boolean;
28
+ set isAsync(isAsync: true);
29
+ onShared(listener: () => void, once?: boolean): void;
30
+ onClose(listener: () => void): void;
31
+ addResources(...resources: Resource[]): Promise<void>;
32
+ addResourcesSync(...resources: Resource[]): void;
33
+ begin(): Promise<void>;
34
+ beginSync(): void;
35
+ addParticipants(...participants: Participant[]): void;
36
+ getParticipant(role: {}): Participant | undefined;
37
+ commit(): MaybePromise;
38
+ rollback(): Promise<void> | undefined;
39
+ waitFor(others: Set<Transaction>): Promise<void>;
40
+ toString(): string;
41
+ }
42
+ /**
43
+ * A read-only offline transaction you may use without context.
44
+ */
45
+ export declare const ReadOnlyTransaction: Tx;
46
+ export {};
47
+ //# sourceMappingURL=Tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tx.d.ts","sourceRoot":"","sources":["../../../src/transaction/Tx.ts"],"names":[],"mappings":"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