@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.
- package/dist/cjs/MatterError.d.ts +12 -0
- package/dist/cjs/MatterError.d.ts.map +1 -1
- package/dist/cjs/MatterError.js +12 -0
- package/dist/cjs/MatterError.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/log/Logger.d.ts.map +1 -1
- package/dist/cjs/log/Logger.js +2 -0
- package/dist/cjs/log/Logger.js.map +1 -1
- package/dist/cjs/time/Time.d.ts +1 -1
- package/dist/cjs/time/Time.d.ts.map +1 -1
- package/dist/cjs/time/Time.js +2 -2
- package/dist/cjs/time/Time.js.map +1 -1
- package/dist/cjs/transaction/Participant.d.ts +47 -0
- package/dist/cjs/transaction/Participant.d.ts.map +1 -0
- package/dist/cjs/transaction/Participant.js +22 -0
- package/dist/cjs/transaction/Participant.js.map +6 -0
- package/dist/cjs/transaction/Resource.d.ts +29 -0
- package/dist/cjs/transaction/Resource.d.ts.map +1 -0
- package/dist/cjs/transaction/Resource.js +40 -0
- package/dist/cjs/transaction/Resource.js.map +6 -0
- package/dist/cjs/transaction/ResourceSet.d.ts +36 -0
- package/dist/cjs/transaction/ResourceSet.d.ts.map +1 -0
- package/dist/cjs/transaction/ResourceSet.js +155 -0
- package/dist/cjs/transaction/ResourceSet.js.map +6 -0
- package/dist/cjs/transaction/Status.d.ts +49 -0
- package/dist/cjs/transaction/Status.d.ts.map +1 -0
- package/dist/cjs/transaction/Status.js +55 -0
- package/dist/cjs/transaction/Status.js.map +6 -0
- package/dist/cjs/transaction/Transaction.d.ts +197 -0
- package/dist/cjs/transaction/Transaction.d.ts.map +1 -0
- package/dist/cjs/transaction/Transaction.js +50 -0
- package/dist/cjs/transaction/Transaction.js.map +6 -0
- package/dist/cjs/transaction/Tx.d.ts +47 -0
- package/dist/cjs/transaction/Tx.d.ts.map +1 -0
- package/dist/cjs/transaction/Tx.js +586 -0
- package/dist/cjs/transaction/Tx.js.map +6 -0
- package/dist/cjs/transaction/errors.d.ts +52 -0
- package/dist/cjs/transaction/errors.d.ts.map +1 -0
- package/dist/cjs/transaction/errors.js +47 -0
- package/dist/cjs/transaction/errors.js.map +6 -0
- package/dist/cjs/transaction/index.d.ts +8 -0
- package/dist/cjs/transaction/index.d.ts.map +1 -0
- package/dist/cjs/transaction/index.js +25 -0
- package/dist/cjs/transaction/index.js.map +6 -0
- package/dist/cjs/util/Cancelable.d.ts +101 -0
- package/dist/cjs/util/Cancelable.d.ts.map +1 -0
- package/dist/cjs/util/Cancelable.js +279 -0
- package/dist/cjs/util/Cancelable.js.map +6 -0
- package/dist/cjs/util/Observable.js +1 -1
- package/dist/cjs/util/Observable.js.map +1 -1
- package/dist/cjs/util/Promises.d.ts +0 -15
- package/dist/cjs/util/Promises.d.ts.map +1 -1
- package/dist/cjs/util/Promises.js +0 -33
- package/dist/cjs/util/Promises.js.map +1 -1
- package/dist/cjs/util/index.d.ts +1 -0
- package/dist/cjs/util/index.d.ts.map +1 -1
- package/dist/cjs/util/index.js +1 -0
- package/dist/cjs/util/index.js.map +1 -1
- package/dist/esm/MatterError.d.ts +12 -0
- package/dist/esm/MatterError.d.ts.map +1 -1
- package/dist/esm/MatterError.js +12 -0
- package/dist/esm/MatterError.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/log/Logger.d.ts.map +1 -1
- package/dist/esm/log/Logger.js +2 -0
- package/dist/esm/log/Logger.js.map +1 -1
- package/dist/esm/time/Time.d.ts +1 -1
- package/dist/esm/time/Time.d.ts.map +1 -1
- package/dist/esm/time/Time.js +1 -1
- package/dist/esm/transaction/Participant.d.ts +47 -0
- package/dist/esm/transaction/Participant.d.ts.map +1 -0
- package/dist/esm/transaction/Participant.js +6 -0
- package/dist/esm/transaction/Participant.js.map +6 -0
- package/dist/esm/transaction/Resource.d.ts +29 -0
- package/dist/esm/transaction/Resource.d.ts.map +1 -0
- package/dist/esm/transaction/Resource.js +20 -0
- package/dist/esm/transaction/Resource.js.map +6 -0
- package/dist/esm/transaction/ResourceSet.d.ts +36 -0
- package/dist/esm/transaction/ResourceSet.d.ts.map +1 -0
- package/dist/esm/transaction/ResourceSet.js +135 -0
- package/dist/esm/transaction/ResourceSet.js.map +6 -0
- package/dist/esm/transaction/Status.d.ts +49 -0
- package/dist/esm/transaction/Status.d.ts.map +1 -0
- package/dist/esm/transaction/Status.js +35 -0
- package/dist/esm/transaction/Status.js.map +6 -0
- package/dist/esm/transaction/Transaction.d.ts +197 -0
- package/dist/esm/transaction/Transaction.d.ts.map +1 -0
- package/dist/esm/transaction/Transaction.js +30 -0
- package/dist/esm/transaction/Transaction.js.map +6 -0
- package/dist/esm/transaction/Tx.d.ts +47 -0
- package/dist/esm/transaction/Tx.d.ts.map +1 -0
- package/dist/esm/transaction/Tx.js +566 -0
- package/dist/esm/transaction/Tx.js.map +6 -0
- package/dist/esm/transaction/errors.d.ts +52 -0
- package/dist/esm/transaction/errors.d.ts.map +1 -0
- package/dist/esm/transaction/errors.js +27 -0
- package/dist/esm/transaction/errors.js.map +6 -0
- package/dist/esm/transaction/index.d.ts +8 -0
- package/dist/esm/transaction/index.d.ts.map +1 -0
- package/dist/esm/transaction/index.js +8 -0
- package/dist/esm/transaction/index.js.map +6 -0
- package/dist/esm/util/Cancelable.d.ts +101 -0
- package/dist/esm/util/Cancelable.d.ts.map +1 -0
- package/dist/esm/util/Cancelable.js +259 -0
- package/dist/esm/util/Cancelable.js.map +6 -0
- package/dist/esm/util/Observable.js +1 -1
- package/dist/esm/util/Observable.js.map +1 -1
- package/dist/esm/util/Promises.d.ts +0 -15
- package/dist/esm/util/Promises.d.ts.map +1 -1
- package/dist/esm/util/Promises.js +0 -33
- package/dist/esm/util/Promises.js.map +1 -1
- package/dist/esm/util/index.d.ts +1 -0
- package/dist/esm/util/index.d.ts.map +1 -1
- package/dist/esm/util/index.js +1 -0
- package/dist/esm/util/index.js.map +1 -1
- package/package.json +2 -2
- package/src/MatterError.ts +18 -0
- package/src/index.ts +1 -0
- package/src/log/Logger.ts +3 -0
- package/src/time/Time.ts +1 -1
- package/src/transaction/Participant.ts +54 -0
- package/src/transaction/Resource.ts +39 -0
- package/src/transaction/ResourceSet.ts +160 -0
- package/src/transaction/Status.ts +68 -0
- package/src/transaction/Transaction.ts +190 -0
- package/src/transaction/Tx.ts +734 -0
- package/src/transaction/errors.ts +53 -0
- package/src/transaction/index.ts +8 -0
- package/src/util/Cancelable.ts +380 -0
- package/src/util/Observable.ts +1 -1
- package/src/util/Promises.ts +0 -52
- package/src/util/index.ts +1 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Transaction } from "./Transaction.js";
|
|
7
|
+
/**
|
|
8
|
+
* The lifecycle of a transaction adheres to the following discrete stages.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum Status {
|
|
11
|
+
/**
|
|
12
|
+
* Transaction may be used only for read operations.
|
|
13
|
+
*/
|
|
14
|
+
ReadOnly = "read only",
|
|
15
|
+
/**
|
|
16
|
+
* Transaction is registered but there are no ACID guarantees.
|
|
17
|
+
*/
|
|
18
|
+
Shared = "shared",
|
|
19
|
+
/**
|
|
20
|
+
* Transaction is waiting to obtain exclusive access to resources.
|
|
21
|
+
*/
|
|
22
|
+
Waiting = "waiting",
|
|
23
|
+
/**
|
|
24
|
+
* Transaction has exclusive access. Reads will maintain consistency
|
|
25
|
+
* and writes are allowed.
|
|
26
|
+
*/
|
|
27
|
+
Exclusive = "exclusive",
|
|
28
|
+
/**
|
|
29
|
+
* Transaction is in the process of committing, phase one.
|
|
30
|
+
*/
|
|
31
|
+
CommittingPhaseOne = "committing phase one",
|
|
32
|
+
/**
|
|
33
|
+
* Transaction is in the process of committing, phase two.
|
|
34
|
+
*/
|
|
35
|
+
CommittingPhaseTwo = "committing phase two",
|
|
36
|
+
/**
|
|
37
|
+
* Transaction is in the process of rolling back.
|
|
38
|
+
*/
|
|
39
|
+
RollingBack = "rolling back",
|
|
40
|
+
/**
|
|
41
|
+
* Transaction is destroyed, no further operations permitted.
|
|
42
|
+
*/
|
|
43
|
+
Destroyed = "destroyed"
|
|
44
|
+
}
|
|
45
|
+
export declare namespace Status {
|
|
46
|
+
function assert(transaction: Transaction, acceptable: Status[], target: Status): void;
|
|
47
|
+
function formatStatus(status: Status): string;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=Status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../src/transaction/Status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,oBAAY,MAAM;IACd;;OAEG;IACH,QAAQ,cAAc;IAEtB;;OAEG;IACH,MAAM,WAAW;IAEjB;;OAEG;IACH,OAAO,YAAY;IAEnB;;;OAGG;IACH,SAAS,cAAc;IAEvB;;OAEG;IACH,kBAAkB,yBAAyB;IAE3C;;OAEG;IACH,kBAAkB,yBAAyB;IAE3C;;OAEG;IACH,WAAW,iBAAiB;IAE5B;;OAEG;IACH,SAAS,cAAc;CAC1B;AAED,yBAAiB,MAAM,CAAC;IACpB,SAAgB,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,QAMpF;IAED,SAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,UAE1C;CACJ"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Status_exports = {};
|
|
20
|
+
__export(Status_exports, {
|
|
21
|
+
Status: () => Status
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Status_exports);
|
|
24
|
+
var import_errors = require("./errors.js");
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
28
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
29
|
+
*/
|
|
30
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
|
31
|
+
Status2["ReadOnly"] = "read only";
|
|
32
|
+
Status2["Shared"] = "shared";
|
|
33
|
+
Status2["Waiting"] = "waiting";
|
|
34
|
+
Status2["Exclusive"] = "exclusive";
|
|
35
|
+
Status2["CommittingPhaseOne"] = "committing phase one";
|
|
36
|
+
Status2["CommittingPhaseTwo"] = "committing phase two";
|
|
37
|
+
Status2["RollingBack"] = "rolling back";
|
|
38
|
+
Status2["Destroyed"] = "destroyed";
|
|
39
|
+
return Status2;
|
|
40
|
+
})(Status || {});
|
|
41
|
+
((Status2) => {
|
|
42
|
+
function assert(transaction, acceptable, target) {
|
|
43
|
+
if (!acceptable.includes(transaction.status)) {
|
|
44
|
+
throw new import_errors.TransactionFlowError(
|
|
45
|
+
`Cannot transition transaction from ${formatStatus(transaction.status)} to ${formatStatus(target)}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Status2.assert = assert;
|
|
50
|
+
function formatStatus(status) {
|
|
51
|
+
return `<${status}>`;
|
|
52
|
+
}
|
|
53
|
+
Status2.formatStatus = formatStatus;
|
|
54
|
+
})(Status || (Status = {}));
|
|
55
|
+
//# 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,oBAAqC;AANrC;AAAA;AAAA;AAAA;AAAA;AAYO,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,CAAC,WAAW,CAAC,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAElD;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEjC;;;;;OAKG;IACH,YAAY,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,SAAS,IAAI,IAAI,CAAC;IAElB;;OAEG;IACH,eAAe,CAAC,GAAG,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAEtD;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,WAAW,GAAG,SAAS,CAAC;IAElD;;;;;;;OAOG;IACH,MAAM,IAAI,YAAY,CAAC;IAEvB;;;;;;;OAOG;IACH,QAAQ,IAAI,YAAY,CAAC;IAEzB;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,QAAQ,CAAC;AAC7B,KAAK,eAAe,GAAG,WAAW,CAAC;AACnC,KAAK,eAAe,GAAG,WAAW,CAAC;AAEnC,eAAO,MAAM,WAAW;IACpB;;;;;;;OAOG;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,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Transaction_exports = {};
|
|
20
|
+
__export(Transaction_exports, {
|
|
21
|
+
Transaction: () => Transaction
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Transaction_exports);
|
|
24
|
+
var import_Resource = require("./Resource.js");
|
|
25
|
+
var import_Status = require("./Status.js");
|
|
26
|
+
var import_Tx = require("./Tx.js");
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
30
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
*/
|
|
32
|
+
const Transaction = {
|
|
33
|
+
/**
|
|
34
|
+
* Perform a transactional operation. This is the only way to obtain a read/write transaction.
|
|
35
|
+
*
|
|
36
|
+
* The transaction will commit automatically if it is exclusive (write mode) after the actor returns.
|
|
37
|
+
*
|
|
38
|
+
* The transaction is destroyed when {@link act} returns. You will receive an error if you access it after it is
|
|
39
|
+
* destroyed.
|
|
40
|
+
*/
|
|
41
|
+
act(via, actor) {
|
|
42
|
+
return (0, import_Tx.act)(via, actor);
|
|
43
|
+
},
|
|
44
|
+
ReadOnly: import_Tx.ReadOnlyTransaction,
|
|
45
|
+
Status: import_Status.Status,
|
|
46
|
+
Resource: import_Resource.Resource,
|
|
47
|
+
[Symbol.toStringTag]: "Transaction"
|
|
48
|
+
};
|
|
49
|
+
Transaction.act = import_Tx.act;
|
|
50
|
+
//# 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,sBAAyB;AAEzB,oBAAuB;AACvB,gBAAyC;AAXzC;AAAA;AAAA;AAAA;AAAA;AA2JO,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASvB,IAAO,KAAa,OAAuE;AAEvF,eAAO,eAAI,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":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAU/C;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,CAAC,GAAG,CAAC,CA8F7E;AAED;;GAEG;AACH,cAAM,EAAG,YAAW,WAAW;;gBAWf,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAQ;IASzC,KAAK;IAQL,IAAI,GAAG,WAEN;IAED,IAAI,MAAM,WAET;IAED,IAAI,YAAY,qBAEf;IAED,IAAI,SAAS,kBAEZ;IAED,IAAI,SAAS,sCAEZ;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,IAAI,EAOxB;IAED,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO;IAW7C,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI;IAatB,YAAY,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE;IAY3C,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE;IAgBnC,KAAK;IAsBX,SAAS;IAqBT,eAAe,CAAC,GAAG,YAAY,EAAE,WAAW,EAAE;IAyB9C,cAAc,CAAC,IAAI,EAAE,EAAE;IAMvB,MAAM;IAyBN,QAAQ;IAMR,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IAuBhC,QAAQ;CAyVX;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,IAA2B,CAAC"}
|