@sovereignbase/sequencer 1.0.2 → 1.1.1
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/INTERNALS.md +3 -3
- package/README.md +69 -54
- package/dist/index.cjs +91 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -33,7 +33,7 @@ type Acknowledgement = U32List;
|
|
|
33
33
|
type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
|
|
34
34
|
/**
|
|
35
35
|
* Retained state required to hydrate the same visible Projection.
|
|
36
|
-
* One structural array and
|
|
36
|
+
* One structural array and JavaScript-owned Footage.
|
|
37
37
|
* Small snapshots use six-word insertion records after length-prefixed ACKs;
|
|
38
38
|
* `words[0]` locates those records. Large snapshots begin with
|
|
39
39
|
* `[0, frontiersEnd, insertionCount]` and omit predictable coordinate fields.
|
|
@@ -41,13 +41,16 @@ type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
|
|
|
41
41
|
* Eligible masks, deleted Footage and compacted Session claims are omitted;
|
|
42
42
|
* Actor membership remains. Compaction may translate retained coordinates.
|
|
43
43
|
* Positive insertion diffs consume successive spans of `footage`.
|
|
44
|
+
* String-encoded Footage preserves Insertion order, not visible text order.
|
|
45
|
+
* It uses one UTF-16 code unit per Frame. Missing slots use
|
|
46
|
+
* NUL (`\u0000`); hydration splits the string with `split('')`.
|
|
44
47
|
* `[[], []]` is an empty Sequence. Both numeric arrays and typed views are accepted.
|
|
45
48
|
*/
|
|
46
|
-
type Sequence<T> = Readonly<[
|
|
49
|
+
type Sequence<T, StringEncoded extends boolean = false> = Readonly<[
|
|
47
50
|
/** Acknowledgements followed by canonical Insertions in Structural Order. */
|
|
48
51
|
words: U32List,
|
|
49
52
|
/** Consecutive positive Insertion spans, including missing Footage slots. */
|
|
50
|
-
footage: ReadonlyArray<T | undefined>]>;
|
|
53
|
+
footage: StringEncoded extends true ? string : ReadonlyArray<T | undefined>]>;
|
|
51
54
|
/** Visible mutation: insertion uses `[at, at, values]`; removal ends exclusively. */
|
|
52
55
|
type Splice<T> = Readonly<[
|
|
53
56
|
/** First affected position in the Projection after preceding Splices. */
|
|
@@ -63,7 +66,7 @@ type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
|
|
|
63
66
|
//#endregion
|
|
64
67
|
//#region src/typescript/errors/class.d.ts
|
|
65
68
|
/** Semantic error codes reported by the Sequencer public API. */
|
|
66
|
-
type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED';
|
|
69
|
+
type SequencerErrorCode = 'UNKNOWN_ERROR' | 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED' | 'STRING_ENCODING_FAILED';
|
|
67
70
|
/** Error reported by Sequencer with a stable code and package-prefixed message. */
|
|
68
71
|
export declare class SequencerError extends Error {
|
|
69
72
|
/** Machine-readable code identifying the failure condition. */
|
|
@@ -88,7 +91,7 @@ export declare class Projection<T> {
|
|
|
88
91
|
* Prepares to sequence a projection, optionally hydrating from a trusted sequence stored by the application.
|
|
89
92
|
*
|
|
90
93
|
* @param actorID Actor identifier used in acknowledgements.
|
|
91
|
-
* @param trustedSequence Optional trusted Sequence in Structural Order
|
|
94
|
+
* @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
|
|
92
95
|
* @throws {@link SequencerError} if native initialization fails.
|
|
93
96
|
*/
|
|
94
97
|
constructor(actorID: number, trustedSequence?: unknown);
|
|
@@ -164,10 +167,12 @@ export declare class Projection<T> {
|
|
|
164
167
|
* permit masks and deleted Footage to be omitted from the retained checkpoint.
|
|
165
168
|
* Compaction may translate retained anchors without rewriting this instance.
|
|
166
169
|
*
|
|
170
|
+
* @param stringEncode Whether to concatenate Footage into a string; each text Frame must be one UTF-16 code unit. Defaults to `false`.
|
|
167
171
|
* @returns A Sequence with acknowledged removals compacted in the exported state.
|
|
168
172
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
173
|
+
* @throws {@link SequencerError} with code `STRING_ENCODING_FAILED` if Footage concatenation fails.
|
|
169
174
|
*/
|
|
170
|
-
sequence(): Sequence<T>;
|
|
175
|
+
sequence<StringEncoded extends boolean = false>(stringEncode?: StringEncoded): Sequence<T, StringEncoded>;
|
|
171
176
|
/**
|
|
172
177
|
* Returns the value at a Projection position.
|
|
173
178
|
*
|
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":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU
|
|
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;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;;;;;;KAiBtD,SAAS,GAAG,yCAAyC;;AAG7D,OAAO;;AAEP,SAAS,sCAAsC,cAAc;;KAKrD,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;;;KC7EzD;;qBAOC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;;;qBChBD,WAAW;WAYJ;;UAVV;;;;;;;;EAUU,YAAA,iBAChB;;;;;;;;;EAuBF,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
|
@@ -33,7 +33,7 @@ type Acknowledgement = U32List;
|
|
|
33
33
|
type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
|
|
34
34
|
/**
|
|
35
35
|
* Retained state required to hydrate the same visible Projection.
|
|
36
|
-
* One structural array and
|
|
36
|
+
* One structural array and JavaScript-owned Footage.
|
|
37
37
|
* Small snapshots use six-word insertion records after length-prefixed ACKs;
|
|
38
38
|
* `words[0]` locates those records. Large snapshots begin with
|
|
39
39
|
* `[0, frontiersEnd, insertionCount]` and omit predictable coordinate fields.
|
|
@@ -41,13 +41,16 @@ type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
|
|
|
41
41
|
* Eligible masks, deleted Footage and compacted Session claims are omitted;
|
|
42
42
|
* Actor membership remains. Compaction may translate retained coordinates.
|
|
43
43
|
* Positive insertion diffs consume successive spans of `footage`.
|
|
44
|
+
* String-encoded Footage preserves Insertion order, not visible text order.
|
|
45
|
+
* It uses one UTF-16 code unit per Frame. Missing slots use
|
|
46
|
+
* NUL (`\u0000`); hydration splits the string with `split('')`.
|
|
44
47
|
* `[[], []]` is an empty Sequence. Both numeric arrays and typed views are accepted.
|
|
45
48
|
*/
|
|
46
|
-
type Sequence<T> = Readonly<[
|
|
49
|
+
type Sequence<T, StringEncoded extends boolean = false> = Readonly<[
|
|
47
50
|
/** Acknowledgements followed by canonical Insertions in Structural Order. */
|
|
48
51
|
words: U32List,
|
|
49
52
|
/** Consecutive positive Insertion spans, including missing Footage slots. */
|
|
50
|
-
footage: ReadonlyArray<T | undefined>]>;
|
|
53
|
+
footage: StringEncoded extends true ? string : ReadonlyArray<T | undefined>]>;
|
|
51
54
|
/** Visible mutation: insertion uses `[at, at, values]`; removal ends exclusively. */
|
|
52
55
|
type Splice<T> = Readonly<[
|
|
53
56
|
/** First affected position in the Projection after preceding Splices. */
|
|
@@ -63,7 +66,7 @@ type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
|
|
|
63
66
|
//#endregion
|
|
64
67
|
//#region src/typescript/errors/class.d.ts
|
|
65
68
|
/** Semantic error codes reported by the Sequencer public API. */
|
|
66
|
-
type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED';
|
|
69
|
+
type SequencerErrorCode = 'UNKNOWN_ERROR' | 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED' | 'STRING_ENCODING_FAILED';
|
|
67
70
|
/** Error reported by Sequencer with a stable code and package-prefixed message. */
|
|
68
71
|
export declare class SequencerError extends Error {
|
|
69
72
|
/** Machine-readable code identifying the failure condition. */
|
|
@@ -88,7 +91,7 @@ export declare class Projection<T> {
|
|
|
88
91
|
* Prepares to sequence a projection, optionally hydrating from a trusted sequence stored by the application.
|
|
89
92
|
*
|
|
90
93
|
* @param actorID Actor identifier used in acknowledgements.
|
|
91
|
-
* @param trustedSequence Optional trusted Sequence in Structural Order
|
|
94
|
+
* @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
|
|
92
95
|
* @throws {@link SequencerError} if native initialization fails.
|
|
93
96
|
*/
|
|
94
97
|
constructor(actorID: number, trustedSequence?: unknown);
|
|
@@ -164,10 +167,12 @@ export declare class Projection<T> {
|
|
|
164
167
|
* permit masks and deleted Footage to be omitted from the retained checkpoint.
|
|
165
168
|
* Compaction may translate retained anchors without rewriting this instance.
|
|
166
169
|
*
|
|
170
|
+
* @param stringEncode Whether to concatenate Footage into a string; each text Frame must be one UTF-16 code unit. Defaults to `false`.
|
|
167
171
|
* @returns A Sequence with acknowledged removals compacted in the exported state.
|
|
168
172
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
173
|
+
* @throws {@link SequencerError} with code `STRING_ENCODING_FAILED` if Footage concatenation fails.
|
|
169
174
|
*/
|
|
170
|
-
sequence(): Sequence<T>;
|
|
175
|
+
sequence<StringEncoded extends boolean = false>(stringEncode?: StringEncoded): Sequence<T, StringEncoded>;
|
|
171
176
|
/**
|
|
172
177
|
* Returns the value at a Projection position.
|
|
173
178
|
*
|
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":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU
|
|
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;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;;;;;;KAiBtD,SAAS,GAAG,yCAAyC;;AAG7D,OAAO;;AAEP,SAAS,sCAAsC,cAAc;;KAKrD,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;;;KC7EzD;;qBAOC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;;;qBChBD,WAAW;WAYJ;;UAVV;;;;;;;;EAUU,YAAA,iBAChB;;;;;;;;;EAuBF,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.js
CHANGED
|
@@ -332,6 +332,11 @@ var Runtime = class {
|
|
|
332
332
|
const heap = module.HEAPU32;
|
|
333
333
|
return this.content[id][heap[pointer]]?.[heap[pointer + 1]];
|
|
334
334
|
}
|
|
335
|
+
/** Exports native spans directly, with optional string Footage assembled in JavaScript. */
|
|
336
|
+
sequence(id, stringEncode) {
|
|
337
|
+
if (id < 0) throw new SequencerError("PROJECTION_DESTROYED", "Projection has been destroyed.");
|
|
338
|
+
return this.result(Operation.Sequence, id, module._runtime_dispatch(Operation.Sequence, id, 0, 0, 0, 0, 0), stringEncode);
|
|
339
|
+
}
|
|
335
340
|
/** Authors trusted local Frames through the dedicated six-word result path. */
|
|
336
341
|
insert(id, values, at) {
|
|
337
342
|
if (id < 0) throw new SequencerError("PROJECTION_DESTROYED", "Projection has been destroyed.");
|
|
@@ -449,16 +454,16 @@ var Runtime = class {
|
|
|
449
454
|
a0 = value ?? absent;
|
|
450
455
|
a1 = at ?? absent;
|
|
451
456
|
} else if (operation === Operation.Retire) a0 = value;
|
|
452
|
-
else
|
|
457
|
+
else {
|
|
453
458
|
a0 = operation === Operation.Create ? value : 0;
|
|
454
459
|
const sequence = operation === Operation.Create ? at : value;
|
|
455
|
-
const valid = operation === Operation.Create && sequence === void 0 || Array.isArray(sequence) && sequence.length === 2 && (Array.isArray(sequence[0]) || sequence[0] instanceof Uint32Array) && Array.isArray(sequence[1]) && (operation === Operation.Create || sequence[0] instanceof Uint32Array || sequence[0].every((word) => Number.isInteger(word) && word >= 0 && word <= absent));
|
|
460
|
+
const valid = operation === Operation.Create && sequence === void 0 || Array.isArray(sequence) && sequence.length === 2 && (Array.isArray(sequence[0]) || sequence[0] instanceof Uint32Array) && (Array.isArray(sequence[1]) || typeof sequence[1] === "string") && (operation === Operation.Create || sequence[0] instanceof Uint32Array || sequence[0].every((word) => Number.isInteger(word) && word >= 0 && word <= absent));
|
|
456
461
|
a2 = valid ? 1 : 0;
|
|
457
462
|
if (valid && sequence !== void 0) {
|
|
458
463
|
const words = sequence[0];
|
|
459
464
|
heap.set(words, base);
|
|
460
465
|
a1 = contents.length;
|
|
461
|
-
footage = sequence[1];
|
|
466
|
+
footage = typeof sequence[1] === "string" ? sequence[1].split("") : sequence[1];
|
|
462
467
|
}
|
|
463
468
|
}
|
|
464
469
|
const resultPointer = module._runtime_dispatch(operation, id, a0, a1, a2, pointer, count);
|
|
@@ -472,7 +477,7 @@ var Runtime = class {
|
|
|
472
477
|
return this.result(operation, id, resultPointer);
|
|
473
478
|
}
|
|
474
479
|
/** Consumes borrowed native output before another call may overwrite its storage. */
|
|
475
|
-
result(operation, id, pointer) {
|
|
480
|
+
result(operation, id, pointer, stringEncode) {
|
|
476
481
|
const heap = module.HEAPU32, header = pointer >>> 2, content = this.content[id];
|
|
477
482
|
const kind = heap[header], p0 = heap[header + 3], n0 = heap[header + 4], p1 = heap[header + 5], n1 = heap[header + 6];
|
|
478
483
|
const mutable = this.mutable[id];
|
|
@@ -589,6 +594,22 @@ var Runtime = class {
|
|
|
589
594
|
metadata.length = n0;
|
|
590
595
|
for (let i = 0, at = p0 >>> 2; i < n0; ++i) metadata[i] = heap[at + i];
|
|
591
596
|
} else metadata = words(p0, n0);
|
|
597
|
+
if (stringEncode) {
|
|
598
|
+
let text = "";
|
|
599
|
+
try {
|
|
600
|
+
for (let at = p1 >>> 2, end = at + n1 * 3; at < end; at += 3) {
|
|
601
|
+
const source = content[heap[at]], start = heap[at + 1], count = heap[at + 2];
|
|
602
|
+
for (let i = 0; i < count; ++i) {
|
|
603
|
+
const value = source?.[start + i];
|
|
604
|
+
text += value === void 0 ? "\0" : value;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
} catch (cause) {
|
|
608
|
+
throw new SequencerError("STRING_ENCODING_FAILED", "Sequence Footage could not be encoded as a string.", { cause });
|
|
609
|
+
}
|
|
610
|
+
result = [metadata, text];
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
592
613
|
const span = p1 >>> 2, token = heap[span];
|
|
593
614
|
const shared = n1 === 1 && heap[span + 1] === 0 && content[token]?.length === heap[span + 2] && !!mutable[token];
|
|
594
615
|
if (shared && mutable[token] !== 3) {
|
|
@@ -657,12 +678,16 @@ var Projection = class {
|
|
|
657
678
|
* Prepares to sequence a projection, optionally hydrating from a trusted sequence stored by the application.
|
|
658
679
|
*
|
|
659
680
|
* @param actorID Actor identifier used in acknowledgements.
|
|
660
|
-
* @param trustedSequence Optional trusted Sequence in Structural Order
|
|
681
|
+
* @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
|
|
661
682
|
* @throws {@link SequencerError} if native initialization fails.
|
|
662
683
|
*/
|
|
663
684
|
constructor(actorID, trustedSequence) {
|
|
664
685
|
this.actorID = actorID;
|
|
665
|
-
|
|
686
|
+
try {
|
|
687
|
+
this.id = runtime.create(this, actorID, trustedSequence);
|
|
688
|
+
} catch (cause) {
|
|
689
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.constructor() failed.", { cause });
|
|
690
|
+
}
|
|
666
691
|
}
|
|
667
692
|
/**
|
|
668
693
|
* Applies gossiped Insertions and Acknowledgements.
|
|
@@ -673,7 +698,11 @@ var Projection = class {
|
|
|
673
698
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
674
699
|
*/
|
|
675
700
|
apply(gossip) {
|
|
676
|
-
|
|
701
|
+
try {
|
|
702
|
+
return runtime.apply(this.id, gossip);
|
|
703
|
+
} catch (cause) {
|
|
704
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.apply() failed.", { cause });
|
|
705
|
+
}
|
|
677
706
|
}
|
|
678
707
|
/**
|
|
679
708
|
* Inserts values at a Projection position.
|
|
@@ -684,7 +713,11 @@ var Projection = class {
|
|
|
684
713
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
685
714
|
*/
|
|
686
715
|
insert(values, at) {
|
|
687
|
-
|
|
716
|
+
try {
|
|
717
|
+
return runtime.insert(this.id, values, at);
|
|
718
|
+
} catch (cause) {
|
|
719
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.insert() failed.", { cause });
|
|
720
|
+
}
|
|
688
721
|
}
|
|
689
722
|
/**
|
|
690
723
|
* Returns the length, A.K.A. amount of entries of this projection.
|
|
@@ -693,7 +726,11 @@ var Projection = class {
|
|
|
693
726
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
694
727
|
*/
|
|
695
728
|
length() {
|
|
696
|
-
|
|
729
|
+
try {
|
|
730
|
+
return runtime.length(this.id);
|
|
731
|
+
} catch (cause) {
|
|
732
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.length() failed.", { cause });
|
|
733
|
+
}
|
|
697
734
|
}
|
|
698
735
|
/**
|
|
699
736
|
* Applies relevant acknowledgements and nonduplicate insertions from a replica of the sequence.
|
|
@@ -704,7 +741,11 @@ var Projection = class {
|
|
|
704
741
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
705
742
|
*/
|
|
706
743
|
merge(sequence) {
|
|
707
|
-
|
|
744
|
+
try {
|
|
745
|
+
return runtime.call(Operation.Merge, this.id, sequence);
|
|
746
|
+
} catch (cause) {
|
|
747
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.merge() failed.", { cause });
|
|
748
|
+
}
|
|
708
749
|
}
|
|
709
750
|
/**
|
|
710
751
|
* Removes an inclusive range of Projection positions.
|
|
@@ -715,7 +756,11 @@ var Projection = class {
|
|
|
715
756
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
716
757
|
*/
|
|
717
758
|
remove(startAt, endWith) {
|
|
718
|
-
|
|
759
|
+
try {
|
|
760
|
+
return runtime.call(Operation.Remove, this.id, startAt, endWith);
|
|
761
|
+
} catch (cause) {
|
|
762
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.remove() failed.", { cause });
|
|
763
|
+
}
|
|
719
764
|
}
|
|
720
765
|
/**
|
|
721
766
|
* Replaces an inclusive range of Projection positions.
|
|
@@ -727,7 +772,11 @@ var Projection = class {
|
|
|
727
772
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
728
773
|
*/
|
|
729
774
|
replace(withValues, startAt, endWith) {
|
|
730
|
-
|
|
775
|
+
try {
|
|
776
|
+
return runtime.call(Operation.Replace, this.id, withValues, startAt, endWith);
|
|
777
|
+
} catch (cause) {
|
|
778
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.replace() failed.", { cause });
|
|
779
|
+
}
|
|
731
780
|
}
|
|
732
781
|
/**
|
|
733
782
|
* Retires an Actor from future compaction requirements.
|
|
@@ -740,7 +789,11 @@ var Projection = class {
|
|
|
740
789
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
741
790
|
*/
|
|
742
791
|
retire(actorID) {
|
|
743
|
-
|
|
792
|
+
try {
|
|
793
|
+
return runtime.call(Operation.Retire, this.id, actorID);
|
|
794
|
+
} catch (cause) {
|
|
795
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.retire() failed.", { cause });
|
|
796
|
+
}
|
|
744
797
|
}
|
|
745
798
|
/**
|
|
746
799
|
* Sequences state into a compact serializable format.
|
|
@@ -750,11 +803,17 @@ var Projection = class {
|
|
|
750
803
|
* permit masks and deleted Footage to be omitted from the retained checkpoint.
|
|
751
804
|
* Compaction may translate retained anchors without rewriting this instance.
|
|
752
805
|
*
|
|
806
|
+
* @param stringEncode Whether to concatenate Footage into a string; each text Frame must be one UTF-16 code unit. Defaults to `false`.
|
|
753
807
|
* @returns A Sequence with acknowledged removals compacted in the exported state.
|
|
754
808
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
809
|
+
* @throws {@link SequencerError} with code `STRING_ENCODING_FAILED` if Footage concatenation fails.
|
|
755
810
|
*/
|
|
756
|
-
sequence() {
|
|
757
|
-
|
|
811
|
+
sequence(stringEncode) {
|
|
812
|
+
try {
|
|
813
|
+
return runtime.sequence(this.id, stringEncode);
|
|
814
|
+
} catch (cause) {
|
|
815
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.sequence() failed.", { cause });
|
|
816
|
+
}
|
|
758
817
|
}
|
|
759
818
|
/**
|
|
760
819
|
* Returns the value at a Projection position.
|
|
@@ -764,7 +823,11 @@ var Projection = class {
|
|
|
764
823
|
* @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
|
|
765
824
|
*/
|
|
766
825
|
value(at) {
|
|
767
|
-
|
|
826
|
+
try {
|
|
827
|
+
return runtime.value(this.id, at);
|
|
828
|
+
} catch (cause) {
|
|
829
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.value() failed.", { cause });
|
|
830
|
+
}
|
|
768
831
|
}
|
|
769
832
|
/**
|
|
770
833
|
* Returns values from an inclusive range of Projection positions.
|
|
@@ -775,13 +838,21 @@ var Projection = class {
|
|
|
775
838
|
* @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
|
|
776
839
|
*/
|
|
777
840
|
values(startAt, endWith) {
|
|
778
|
-
|
|
841
|
+
try {
|
|
842
|
+
return runtime.call(Operation.Values, this.id, startAt, endWith);
|
|
843
|
+
} catch (cause) {
|
|
844
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.values() failed.", { cause });
|
|
845
|
+
}
|
|
779
846
|
}
|
|
780
847
|
/** Destroys the Projection. Repeated calls have no effect. */
|
|
781
848
|
destroy() {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
849
|
+
try {
|
|
850
|
+
if (this.id < 0) return;
|
|
851
|
+
runtime.destroy(this, this.id);
|
|
852
|
+
this.id = -1;
|
|
853
|
+
} catch (cause) {
|
|
854
|
+
throw cause instanceof SequencerError ? cause : new SequencerError("UNKNOWN_ERROR", "Projection.destroy() failed.", { cause });
|
|
855
|
+
}
|
|
785
856
|
}
|
|
786
857
|
};
|
|
787
858
|
//#endregion
|