@sovereignbase/sequencer 1.1.1 → 1.2.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 +92 -36
- package/dist/index.cjs +41 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -13
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +22 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -33
- package/dist/index.js.map +1 -1
- package/package.json +22 -15
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/typescript/types/type.d.ts
|
|
3
2
|
/** Unsigned 32-bit structural words, accepted as a typed view or JSON numeric array. */
|
|
4
3
|
type U32List = Uint32Array | ReadonlyArray<number>;
|
|
5
4
|
/**
|
|
@@ -9,6 +8,7 @@ type U32List = Uint32Array | ReadonlyArray<number>;
|
|
|
9
8
|
* The anchor triple names a logical point in an existing Insertion; the Session
|
|
10
9
|
* and start pair identifies the authored Insertion. A positive diff adds Frames;
|
|
11
10
|
* a negative diff masks original Frames. Signed values use uint32 bit patterns.
|
|
11
|
+
* In tuple mode, `anchorDiff` is the stable index and diff is `1` or `-1`.
|
|
12
12
|
*/
|
|
13
13
|
type InsertionWords = U32List;
|
|
14
14
|
/**
|
|
@@ -45,13 +45,19 @@ type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
|
|
|
45
45
|
* It uses one UTF-16 code unit per Frame. Missing slots use
|
|
46
46
|
* NUL (`\u0000`); hydration splits the string with `split('')`.
|
|
47
47
|
* `[[], []]` is an empty Sequence. Both numeric arrays and typed views are accepted.
|
|
48
|
+
* Tuple metadata prefixes the payload with `[0xffffffff, 1, maxLength, length]`;
|
|
49
|
+
* `maxLength = 0xffffffff` denotes dynamic growth. Tuple indices are never translated.
|
|
48
50
|
*/
|
|
49
51
|
type Sequence<T, StringEncoded extends boolean = false> = Readonly<[
|
|
50
52
|
/** Acknowledgements followed by canonical Insertions in Structural Order. */
|
|
51
53
|
words: U32List,
|
|
52
54
|
/** Consecutive positive Insertion spans, including missing Footage slots. */
|
|
53
55
|
footage: StringEncoded extends true ? string : ReadonlyArray<T | undefined>]>;
|
|
54
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Visible mutation: insertion uses `[at, at, values]`; removal ends exclusively.
|
|
58
|
+
* Tuple changes assign one stable index using `[index, index + 1, [value]]`;
|
|
59
|
+
* an empty register supplies `undefined`, without shifting other indices.
|
|
60
|
+
*/
|
|
55
61
|
type Splice<T> = Readonly<[
|
|
56
62
|
/** First affected position in the Projection after preceding Splices. */
|
|
57
63
|
startAt: number,
|
|
@@ -63,8 +69,13 @@ values?: ReadonlyArray<T | undefined>]>;
|
|
|
63
69
|
type Change<T> = ReadonlyArray<Splice<T>>;
|
|
64
70
|
/** Visible changes and optional Gossip returned by `apply()` or `merge()`. */
|
|
65
71
|
type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
/** Stable-index register configuration; omitting maxLength permits dynamic growth. */
|
|
73
|
+
type TupleParams = {
|
|
74
|
+
/** Whether indices remain fixed when values are inserted or removed. */
|
|
75
|
+
enabled: boolean | 0 | 1;
|
|
76
|
+
/** Fixed number of registers, indices must be in `0..maxLength - 1`. */
|
|
77
|
+
maxLength?: number;
|
|
78
|
+
};
|
|
68
79
|
/** Semantic error codes reported by the Sequencer public API. */
|
|
69
80
|
type SequencerErrorCode = 'UNKNOWN_ERROR' | 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED' | 'STRING_ENCODING_FAILED';
|
|
70
81
|
/** Error reported by Sequencer with a stable code and package-prefixed message. */
|
|
@@ -80,8 +91,6 @@ export declare class SequencerError extends Error {
|
|
|
80
91
|
*/
|
|
81
92
|
constructor(code: SequencerErrorCode, message?: string, options?: ErrorOptions);
|
|
82
93
|
}
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/typescript/class.d.ts
|
|
85
94
|
/** Visible Projection of a replicated Sequence. */
|
|
86
95
|
export declare class Projection<T> {
|
|
87
96
|
readonly actorID: number;
|
|
@@ -92,9 +101,10 @@ export declare class Projection<T> {
|
|
|
92
101
|
*
|
|
93
102
|
* @param actorID Actor identifier used in acknowledgements.
|
|
94
103
|
* @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
|
|
104
|
+
* @param tupleParams Enables stable indices, optionally bounded by a fixed length. Tuple Sequences retain this configuration.
|
|
95
105
|
* @throws {@link SequencerError} if native initialization fails.
|
|
96
106
|
*/
|
|
97
|
-
constructor(actorID: number, trustedSequence?: unknown);
|
|
107
|
+
constructor(actorID: number, trustedSequence?: unknown, tupleParams?: TupleParams);
|
|
98
108
|
/**
|
|
99
109
|
* Applies gossiped Insertions and Acknowledgements.
|
|
100
110
|
*
|
|
@@ -108,7 +118,7 @@ export declare class Projection<T> {
|
|
|
108
118
|
* Inserts values at a Projection position.
|
|
109
119
|
*
|
|
110
120
|
* @param values Nonempty array of values to insert.
|
|
111
|
-
* @param at Insertion position in `0..length()`, inclusive.
|
|
121
|
+
* @param at Insertion position in `0..length()`, inclusive. In tuple mode, the first stable index to write; each value creates a competing version.
|
|
112
122
|
* @returns Gossip describing the insertion.
|
|
113
123
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
114
124
|
*/
|
|
@@ -116,7 +126,7 @@ export declare class Projection<T> {
|
|
|
116
126
|
/**
|
|
117
127
|
* Returns the length, A.K.A. amount of entries of this projection.
|
|
118
128
|
*
|
|
119
|
-
* @returns Current Projection length.
|
|
129
|
+
* @returns Current Projection length. Tuples retain their fixed length or highest written boundary, including empty registers.
|
|
120
130
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
121
131
|
*/
|
|
122
132
|
length(): number;
|
|
@@ -134,7 +144,7 @@ export declare class Projection<T> {
|
|
|
134
144
|
*
|
|
135
145
|
* @param startAt First position to remove; defaults to 0.
|
|
136
146
|
* @param endWith Last position to remove; defaults to `length() - 1`.
|
|
137
|
-
* @returns Reducing Insertions and their acknowledgement as Gossip.
|
|
147
|
+
* @returns Reducing Insertions and their acknowledgement as Gossip. Tuple removal targets all known active versions without shifting indices.
|
|
138
148
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
139
149
|
*/
|
|
140
150
|
remove(startAt?: number, endWith?: number): Gossip<T>;
|
|
@@ -144,7 +154,7 @@ export declare class Projection<T> {
|
|
|
144
154
|
* @param withValues Replacement values; an empty array only removes the range.
|
|
145
155
|
* @param startAt First position to replace; defaults to 0.
|
|
146
156
|
* @param endWith Last position to replace; defaults to `length() - 1`.
|
|
147
|
-
* @returns Removal and insertion Gossip, in that order.
|
|
157
|
+
* @returns Removal and insertion Gossip, in that order. Tuple replacement removes known versions and writes consecutive stable indices.
|
|
148
158
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
149
159
|
*/
|
|
150
160
|
replace(withValues: Array<T>, startAt?: number, endWith?: number): Gossip<T>;
|
|
@@ -193,6 +203,5 @@ export declare class Projection<T> {
|
|
|
193
203
|
/** Destroys the Projection. Repeated calls have no effect. */
|
|
194
204
|
destroy(): void;
|
|
195
205
|
}
|
|
196
|
-
|
|
197
|
-
export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, SequencerErrorCode, Splice, U32List };
|
|
206
|
+
export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, SequencerErrorCode, Splice, TupleParams, U32List };
|
|
198
207
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":";;KACY,UAAU,cAAc;;;;;;;;;;KAWxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;;;;;;;;KAmBtD,SAAS,GAAG,yCAAyC;;AAG7D,OAAO;;AAEP,SAAS,sCAAsC,cAAc;;;;;;KASrD,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;KAGzD;;EAEV;;EAEA;;;KC3FU;;qBAOC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;qBChBD,WAAW;WAaJ;;UAXV;;;;;;;;;EAWU,YAAA,iBAChB,2BACA,cAAc;;;;;;;;;EAuBhB,MAAM,kBAAkB,OAAO;;;;;;;;;EAoB/B,OAAO,QAAQ,MAAM,IAAI,aAAa,OAAO;;;;;;;EAkB7C;;;;;;;;;EAoBA,MAAM,oBAAoB,OAAO;;;;;;;;;EAoBjC,OAAO,kBAAkB,mBAAmB,OAAO;;;;;;;;;;EAqBnD,QAAQ,YAAY,MAAM,IAAI,kBAAkB,mBAAmB,OAAO;;;;;;;;;;;EA4B1E,OAAO;;;;;;;;;;;;;;EAyBP,SAAS,uCACP,eAAe,gBACd,SAAS,GAAG;;;;;;;;EAmBf,MAAM,aAAa;;;;;;;;;EAoBnB,OAAO,kBAAkB,mBAAmB,MAAM;;EAalD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/typescript/types/type.d.ts
|
|
3
2
|
/** Unsigned 32-bit structural words, accepted as a typed view or JSON numeric array. */
|
|
4
3
|
type U32List = Uint32Array | ReadonlyArray<number>;
|
|
5
4
|
/**
|
|
@@ -9,6 +8,7 @@ type U32List = Uint32Array | ReadonlyArray<number>;
|
|
|
9
8
|
* The anchor triple names a logical point in an existing Insertion; the Session
|
|
10
9
|
* and start pair identifies the authored Insertion. A positive diff adds Frames;
|
|
11
10
|
* a negative diff masks original Frames. Signed values use uint32 bit patterns.
|
|
11
|
+
* In tuple mode, `anchorDiff` is the stable index and diff is `1` or `-1`.
|
|
12
12
|
*/
|
|
13
13
|
type InsertionWords = U32List;
|
|
14
14
|
/**
|
|
@@ -45,13 +45,19 @@ type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
|
|
|
45
45
|
* It uses one UTF-16 code unit per Frame. Missing slots use
|
|
46
46
|
* NUL (`\u0000`); hydration splits the string with `split('')`.
|
|
47
47
|
* `[[], []]` is an empty Sequence. Both numeric arrays and typed views are accepted.
|
|
48
|
+
* Tuple metadata prefixes the payload with `[0xffffffff, 1, maxLength, length]`;
|
|
49
|
+
* `maxLength = 0xffffffff` denotes dynamic growth. Tuple indices are never translated.
|
|
48
50
|
*/
|
|
49
51
|
type Sequence<T, StringEncoded extends boolean = false> = Readonly<[
|
|
50
52
|
/** Acknowledgements followed by canonical Insertions in Structural Order. */
|
|
51
53
|
words: U32List,
|
|
52
54
|
/** Consecutive positive Insertion spans, including missing Footage slots. */
|
|
53
55
|
footage: StringEncoded extends true ? string : ReadonlyArray<T | undefined>]>;
|
|
54
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Visible mutation: insertion uses `[at, at, values]`; removal ends exclusively.
|
|
58
|
+
* Tuple changes assign one stable index using `[index, index + 1, [value]]`;
|
|
59
|
+
* an empty register supplies `undefined`, without shifting other indices.
|
|
60
|
+
*/
|
|
55
61
|
type Splice<T> = Readonly<[
|
|
56
62
|
/** First affected position in the Projection after preceding Splices. */
|
|
57
63
|
startAt: number,
|
|
@@ -63,8 +69,13 @@ values?: ReadonlyArray<T | undefined>]>;
|
|
|
63
69
|
type Change<T> = ReadonlyArray<Splice<T>>;
|
|
64
70
|
/** Visible changes and optional Gossip returned by `apply()` or `merge()`. */
|
|
65
71
|
type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
/** Stable-index register configuration; omitting maxLength permits dynamic growth. */
|
|
73
|
+
type TupleParams = {
|
|
74
|
+
/** Whether indices remain fixed when values are inserted or removed. */
|
|
75
|
+
enabled: boolean | 0 | 1;
|
|
76
|
+
/** Fixed number of registers, indices must be in `0..maxLength - 1`. */
|
|
77
|
+
maxLength?: number;
|
|
78
|
+
};
|
|
68
79
|
/** Semantic error codes reported by the Sequencer public API. */
|
|
69
80
|
type SequencerErrorCode = 'UNKNOWN_ERROR' | 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED' | 'STRING_ENCODING_FAILED';
|
|
70
81
|
/** Error reported by Sequencer with a stable code and package-prefixed message. */
|
|
@@ -80,8 +91,6 @@ export declare class SequencerError extends Error {
|
|
|
80
91
|
*/
|
|
81
92
|
constructor(code: SequencerErrorCode, message?: string, options?: ErrorOptions);
|
|
82
93
|
}
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/typescript/class.d.ts
|
|
85
94
|
/** Visible Projection of a replicated Sequence. */
|
|
86
95
|
export declare class Projection<T> {
|
|
87
96
|
readonly actorID: number;
|
|
@@ -92,9 +101,10 @@ export declare class Projection<T> {
|
|
|
92
101
|
*
|
|
93
102
|
* @param actorID Actor identifier used in acknowledgements.
|
|
94
103
|
* @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
|
|
104
|
+
* @param tupleParams Enables stable indices, optionally bounded by a fixed length. Tuple Sequences retain this configuration.
|
|
95
105
|
* @throws {@link SequencerError} if native initialization fails.
|
|
96
106
|
*/
|
|
97
|
-
constructor(actorID: number, trustedSequence?: unknown);
|
|
107
|
+
constructor(actorID: number, trustedSequence?: unknown, tupleParams?: TupleParams);
|
|
98
108
|
/**
|
|
99
109
|
* Applies gossiped Insertions and Acknowledgements.
|
|
100
110
|
*
|
|
@@ -108,7 +118,7 @@ export declare class Projection<T> {
|
|
|
108
118
|
* Inserts values at a Projection position.
|
|
109
119
|
*
|
|
110
120
|
* @param values Nonempty array of values to insert.
|
|
111
|
-
* @param at Insertion position in `0..length()`, inclusive.
|
|
121
|
+
* @param at Insertion position in `0..length()`, inclusive. In tuple mode, the first stable index to write; each value creates a competing version.
|
|
112
122
|
* @returns Gossip describing the insertion.
|
|
113
123
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
114
124
|
*/
|
|
@@ -116,7 +126,7 @@ export declare class Projection<T> {
|
|
|
116
126
|
/**
|
|
117
127
|
* Returns the length, A.K.A. amount of entries of this projection.
|
|
118
128
|
*
|
|
119
|
-
* @returns Current Projection length.
|
|
129
|
+
* @returns Current Projection length. Tuples retain their fixed length or highest written boundary, including empty registers.
|
|
120
130
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
121
131
|
*/
|
|
122
132
|
length(): number;
|
|
@@ -134,7 +144,7 @@ export declare class Projection<T> {
|
|
|
134
144
|
*
|
|
135
145
|
* @param startAt First position to remove; defaults to 0.
|
|
136
146
|
* @param endWith Last position to remove; defaults to `length() - 1`.
|
|
137
|
-
* @returns Reducing Insertions and their acknowledgement as Gossip.
|
|
147
|
+
* @returns Reducing Insertions and their acknowledgement as Gossip. Tuple removal targets all known active versions without shifting indices.
|
|
138
148
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
139
149
|
*/
|
|
140
150
|
remove(startAt?: number, endWith?: number): Gossip<T>;
|
|
@@ -144,7 +154,7 @@ export declare class Projection<T> {
|
|
|
144
154
|
* @param withValues Replacement values; an empty array only removes the range.
|
|
145
155
|
* @param startAt First position to replace; defaults to 0.
|
|
146
156
|
* @param endWith Last position to replace; defaults to `length() - 1`.
|
|
147
|
-
* @returns Removal and insertion Gossip, in that order.
|
|
157
|
+
* @returns Removal and insertion Gossip, in that order. Tuple replacement removes known versions and writes consecutive stable indices.
|
|
148
158
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
149
159
|
*/
|
|
150
160
|
replace(withValues: Array<T>, startAt?: number, endWith?: number): Gossip<T>;
|
|
@@ -193,6 +203,5 @@ export declare class Projection<T> {
|
|
|
193
203
|
/** Destroys the Projection. Repeated calls have no effect. */
|
|
194
204
|
destroy(): void;
|
|
195
205
|
}
|
|
196
|
-
|
|
197
|
-
export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, SequencerErrorCode, Splice, U32List };
|
|
206
|
+
export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, SequencerErrorCode, Splice, TupleParams, U32List };
|
|
198
207
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":";;KACY,UAAU,cAAc;;;;;;;;;;KAWxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;;;;;;;;KAmBtD,SAAS,GAAG,yCAAyC;;AAG7D,OAAO;;AAEP,SAAS,sCAAsC,cAAc;;;;;;KASrD,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;KAGzD;;EAEV;;EAEA;;;KC3FU;;qBAOC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;qBChBD,WAAW;WAaJ;;UAXV;;;;;;;;;EAWU,YAAA,iBAChB,2BACA,cAAc;;;;;;;;;EAuBhB,MAAM,kBAAkB,OAAO;;;;;;;;;EAoB/B,OAAO,QAAQ,MAAM,IAAI,aAAa,OAAO;;;;;;;EAkB7C;;;;;;;;;EAoBA,MAAM,oBAAoB,OAAO;;;;;;;;;EAoBjC,OAAO,kBAAkB,mBAAmB,OAAO;;;;;;;;;;EAqBnD,QAAQ,YAAY,MAAM,IAAI,kBAAkB,mBAAmB,OAAO;;;;;;;;;;;EA4B1E,OAAO;;;;;;;;;;;;;;EAyBP,SAAS,uCACP,eAAe,gBACd,SAAS,GAAG;;;;;;;;EAmBf,MAAM,aAAa;;;;;;;;;EAoBnB,OAAO,kBAAkB,mBAAmB,MAAM;;EAalD"}
|