reactronic 0.22.313 → 0.22.316
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 +6 -6
- package/build/dist/source/Buffer.d.ts +1 -1
- package/build/dist/source/Buffer.js +1 -1
- package/build/dist/source/Options.d.ts +3 -3
- package/build/dist/source/Rx.d.ts +2 -2
- package/build/dist/source/Rx.js +14 -14
- package/build/dist/source/api.d.ts +5 -2
- package/build/dist/source/api.js +5 -2
- package/build/dist/source/impl/Changeset.js +5 -5
- package/build/dist/source/impl/Data.d.ts +1 -1
- package/build/dist/source/impl/Journal.d.ts +1 -1
- package/build/dist/source/impl/Journal.js +4 -4
- package/build/dist/source/impl/Monitor.d.ts +1 -1
- package/build/dist/source/impl/Monitor.js +4 -4
- package/build/dist/source/impl/{Hooks.d.ts → Mvcc.d.ts} +14 -51
- package/build/dist/source/impl/{Hooks.js → Mvcc.js} +53 -100
- package/build/dist/source/impl/MvccArray.d.ts +60 -0
- package/build/dist/source/impl/MvccArray.js +58 -0
- package/build/dist/source/impl/MvccCollection.d.ts +25 -0
- package/build/dist/source/impl/MvccCollection.js +23 -0
- package/build/dist/source/impl/MvccMap.d.ts +25 -0
- package/build/dist/source/impl/MvccMap.js +35 -0
- package/build/dist/source/impl/Operation.d.ts +3 -3
- package/build/dist/source/impl/Operation.js +20 -20
- package/build/dist/source/impl/Transaction.d.ts +2 -2
- package/build/dist/source/impl/Transaction.js +9 -9
- package/build/dist/source/util/Collection.d.ts +63 -0
- package/build/dist/source/util/Collection.js +283 -0
- package/package.json +8 -8
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { UNDEF } from '../util/Utils';
|
|
2
|
-
import { Sealant } from '../util/Sealant';
|
|
3
2
|
import { Log, misuse } from '../util/Dbg';
|
|
4
3
|
import { Kind, Reentrance } from '../Options';
|
|
5
4
|
import { ObjectSnapshot, ObjectHandle, Subscription, Meta } from './Data';
|
|
6
5
|
import { Changeset, Dump, EMPTY_SNAPSHOT } from './Changeset';
|
|
7
|
-
export class
|
|
8
|
-
constructor() {
|
|
6
|
+
export class MvccObject {
|
|
7
|
+
constructor(reactive) {
|
|
9
8
|
const proto = new.target.prototype;
|
|
10
9
|
const initial = Meta.getFrom(proto, Meta.Initial);
|
|
11
|
-
const h =
|
|
10
|
+
const h = Mvcc.createHandleForMvccObject(proto, this, initial, new.target.name, reactive);
|
|
12
11
|
return h.proxy;
|
|
13
12
|
}
|
|
14
13
|
[Symbol.toStringTag]() {
|
|
@@ -16,71 +15,19 @@ export class ReactiveObject {
|
|
|
16
15
|
return Dump.obj(h);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
export class
|
|
18
|
+
export class TransactionalObject extends MvccObject {
|
|
20
19
|
constructor() {
|
|
21
|
-
super(
|
|
22
|
-
this.a = new Array();
|
|
23
|
-
}
|
|
24
|
-
get length() { return this.a.length; }
|
|
25
|
-
set length(n) { this.a.length = n; }
|
|
26
|
-
get(n) { return this.a[n]; }
|
|
27
|
-
set(n, item) { this.mutable[n] = item; }
|
|
28
|
-
toString() { return this.a.toString(); }
|
|
29
|
-
toLocaleString() { return this.a.toLocaleString(); }
|
|
30
|
-
pop() { return this.mutable.pop(); }
|
|
31
|
-
push(...items) { return this.mutable.push(...items); }
|
|
32
|
-
concat(...items) { return this.a.concat(...items); }
|
|
33
|
-
join(separator) { return this.a.join(separator); }
|
|
34
|
-
reverse() { return this.mutable.reverse(); }
|
|
35
|
-
shift() { return this.mutable.shift(); }
|
|
36
|
-
slice(start, end) { return this.a.slice(start, end); }
|
|
37
|
-
sort(compareFn) { this.mutable.sort(compareFn); return this; }
|
|
38
|
-
splice(start, deleteCount, ...items) { return this.mutable.splice(start, deleteCount, ...items); }
|
|
39
|
-
unshift(...items) { return this.mutable.unshift(...items); }
|
|
40
|
-
indexOf(searchElement, fromIndex) { return this.a.indexOf(searchElement, fromIndex); }
|
|
41
|
-
lastIndexOf(searchElement, fromIndex) { return this.a.lastIndexOf(searchElement, fromIndex); }
|
|
42
|
-
every(predicate, thisArg) { return this.a.every(predicate, thisArg); }
|
|
43
|
-
some(predicate, thisArg) { return this.a.some(predicate, thisArg); }
|
|
44
|
-
forEach(callbackfn, thisArg) { return this.a.forEach(callbackfn, thisArg); }
|
|
45
|
-
map(callbackfn, thisArg) { return this.a.map(callbackfn, thisArg); }
|
|
46
|
-
filter(predicate, thisArg) { return this.a.filter(predicate, thisArg); }
|
|
47
|
-
reduce(callbackfn, initialValue) { return this.a.reduce(callbackfn, initialValue); }
|
|
48
|
-
reduceRight(callbackfn, initialValue) { return this.a.reduceRight(callbackfn, initialValue); }
|
|
49
|
-
entries() { return this.a.entries(); }
|
|
50
|
-
keys() { return this.a.keys(); }
|
|
51
|
-
values() { return this.a.values(); }
|
|
52
|
-
get mutable() {
|
|
53
|
-
const createCopy = this.a[Sealant.CreateCopy];
|
|
54
|
-
if (createCopy)
|
|
55
|
-
return this.a = createCopy.call(this.a);
|
|
56
|
-
return this.a;
|
|
20
|
+
super(false);
|
|
57
21
|
}
|
|
58
22
|
}
|
|
59
|
-
export class
|
|
23
|
+
export class ReactiveObject extends MvccObject {
|
|
60
24
|
constructor() {
|
|
61
|
-
super(
|
|
62
|
-
this.m = new Map();
|
|
63
|
-
}
|
|
64
|
-
clear() { this.mutable.clear(); }
|
|
65
|
-
delete(key) { return this.mutable.delete(key); }
|
|
66
|
-
forEach(callbackfn, thisArg) { this.m.forEach(callbackfn, thisArg); }
|
|
67
|
-
get(key) { return this.m.get(key); }
|
|
68
|
-
has(key) { return this.m.has(key); }
|
|
69
|
-
set(key, value) { this.mutable.set(key, value); return this; }
|
|
70
|
-
get size() { return this.m.size; }
|
|
71
|
-
entries() { return this.m.entries(); }
|
|
72
|
-
keys() { return this.m.keys(); }
|
|
73
|
-
values() { return this.m.values(); }
|
|
74
|
-
get mutable() {
|
|
75
|
-
const createCopy = this.m[Sealant.CreateCopy];
|
|
76
|
-
if (createCopy)
|
|
77
|
-
return this.m = createCopy.call(this.m);
|
|
78
|
-
return this.m;
|
|
25
|
+
super(true);
|
|
79
26
|
}
|
|
80
27
|
}
|
|
81
28
|
const DEFAULT_OPTIONS = Object.freeze({
|
|
82
29
|
kind: Kind.Plain,
|
|
83
|
-
|
|
30
|
+
separation: false,
|
|
84
31
|
order: 0,
|
|
85
32
|
noSideEffects: false,
|
|
86
33
|
triggeringArgs: false,
|
|
@@ -95,7 +42,7 @@ export class OptionsImpl {
|
|
|
95
42
|
this.getter = getter !== undefined ? getter : existing.getter;
|
|
96
43
|
this.setter = setter !== undefined ? setter : existing.setter;
|
|
97
44
|
this.kind = merge(DEFAULT_OPTIONS.kind, existing.kind, patch.kind, implicit);
|
|
98
|
-
this.
|
|
45
|
+
this.separation = merge(DEFAULT_OPTIONS.separation, existing.separation, patch.separation, implicit);
|
|
99
46
|
this.order = merge(DEFAULT_OPTIONS.order, existing.order, patch.order, implicit);
|
|
100
47
|
this.noSideEffects = merge(DEFAULT_OPTIONS.noSideEffects, existing.noSideEffects, patch.noSideEffects, implicit);
|
|
101
48
|
this.triggeringArgs = merge(DEFAULT_OPTIONS.triggeringArgs, existing.triggeringArgs, patch.triggeringArgs, implicit);
|
|
@@ -112,7 +59,10 @@ OptionsImpl.INITIAL = Object.freeze(new OptionsImpl(UNDEF, UNDEF, Object.assign(
|
|
|
112
59
|
function merge(def, existing, patch, implicit) {
|
|
113
60
|
return patch !== undefined && (existing === def || !implicit) ? patch : existing;
|
|
114
61
|
}
|
|
115
|
-
export class
|
|
62
|
+
export class Mvcc {
|
|
63
|
+
constructor(isReactive) {
|
|
64
|
+
this.isReactive = isReactive;
|
|
65
|
+
}
|
|
116
66
|
getPrototypeOf(h) {
|
|
117
67
|
return Reflect.getPrototypeOf(h.data);
|
|
118
68
|
}
|
|
@@ -123,7 +73,8 @@ export class Hooks {
|
|
|
123
73
|
const os = cs.getObjectSnapshot(h, m);
|
|
124
74
|
result = os.data[m];
|
|
125
75
|
if (result instanceof Subscription && !result.isOperation) {
|
|
126
|
-
|
|
76
|
+
if (this.isReactive)
|
|
77
|
+
Changeset.markUsed(result, os, m, h, Kind.Plain, false);
|
|
127
78
|
result = result.content;
|
|
128
79
|
}
|
|
129
80
|
else
|
|
@@ -138,7 +89,7 @@ export class Hooks {
|
|
|
138
89
|
if (os !== EMPTY_SNAPSHOT) {
|
|
139
90
|
let curr = os.data[m];
|
|
140
91
|
if (curr !== undefined || (os.former.snapshot.changeset === EMPTY_SNAPSHOT.changeset && (m in h.data) === false)) {
|
|
141
|
-
if (curr === undefined || curr.content !== value ||
|
|
92
|
+
if (curr === undefined || curr.content !== value || Mvcc.sensitivity) {
|
|
142
93
|
const existing = curr === null || curr === void 0 ? void 0 : curr.content;
|
|
143
94
|
if (os.former.snapshot.data[m] === curr) {
|
|
144
95
|
curr = os.data[m] = new Subscription(value);
|
|
@@ -181,12 +132,12 @@ export class Hooks {
|
|
|
181
132
|
static decorateData(reactive, proto, m) {
|
|
182
133
|
if (reactive) {
|
|
183
134
|
const get = function () {
|
|
184
|
-
const h =
|
|
185
|
-
return
|
|
135
|
+
const h = Mvcc.acquireHandle(this);
|
|
136
|
+
return Mvcc.reactive.get(h, m, this);
|
|
186
137
|
};
|
|
187
138
|
const set = function (value) {
|
|
188
|
-
const h =
|
|
189
|
-
return
|
|
139
|
+
const h = Mvcc.acquireHandle(this);
|
|
140
|
+
return Mvcc.reactive.set(h, m, value, this);
|
|
190
141
|
};
|
|
191
142
|
const enumerable = true;
|
|
192
143
|
const configurable = false;
|
|
@@ -201,11 +152,11 @@ export class Hooks {
|
|
|
201
152
|
pd = EMPTY_PROP_DESCRIPTOR;
|
|
202
153
|
const enumerable = (_a = pd.enumerable) !== null && _a !== void 0 ? _a : true;
|
|
203
154
|
const configurable = (_b = pd.configurable) !== null && _b !== void 0 ? _b : true;
|
|
204
|
-
const opts =
|
|
155
|
+
const opts = Mvcc.rememberOperationOptions(proto, member, (_c = pd.value) !== null && _c !== void 0 ? _c : pd.get, (_d = pd.value) !== null && _d !== void 0 ? _d : pd.set, true, configurable, options, implicit);
|
|
205
156
|
if (opts.getter === opts.setter) {
|
|
206
157
|
const bootstrap = function () {
|
|
207
|
-
const h =
|
|
208
|
-
const operation =
|
|
158
|
+
const h = Mvcc.acquireHandle(this);
|
|
159
|
+
const operation = Mvcc.createOperation(h, member, opts);
|
|
209
160
|
Object.defineProperty(h.data, member, { value: operation, enumerable, configurable });
|
|
210
161
|
return operation;
|
|
211
162
|
};
|
|
@@ -213,8 +164,8 @@ export class Hooks {
|
|
|
213
164
|
}
|
|
214
165
|
else if (opts.setter === UNDEF) {
|
|
215
166
|
const bootstrap = function () {
|
|
216
|
-
const h =
|
|
217
|
-
const operation =
|
|
167
|
+
const h = Mvcc.acquireHandle(this);
|
|
168
|
+
const operation = Mvcc.createOperation(h, member, opts);
|
|
218
169
|
Object.defineProperty(h.data, member, { get: operation, enumerable, configurable });
|
|
219
170
|
return operation.call(this);
|
|
220
171
|
};
|
|
@@ -225,7 +176,7 @@ export class Hooks {
|
|
|
225
176
|
}
|
|
226
177
|
static decorateOperationParametrized(decorator, options) {
|
|
227
178
|
return function (proto, prop, pd) {
|
|
228
|
-
return
|
|
179
|
+
return Mvcc.decorateOperation(false, decorator, options, proto, prop, pd);
|
|
229
180
|
};
|
|
230
181
|
}
|
|
231
182
|
static acquireHandle(obj) {
|
|
@@ -235,69 +186,71 @@ export class Hooks {
|
|
|
235
186
|
throw misuse('only objects can be reactive');
|
|
236
187
|
const initial = Meta.getFrom(Object.getPrototypeOf(obj), Meta.Initial);
|
|
237
188
|
const os = new ObjectSnapshot(EMPTY_SNAPSHOT.changeset, EMPTY_SNAPSHOT, Object.assign({}, initial));
|
|
238
|
-
h = new ObjectHandle(obj, obj,
|
|
189
|
+
h = new ObjectHandle(obj, obj, Mvcc.reactive, os, obj.constructor.name);
|
|
239
190
|
Meta.set(os.data, Meta.Handle, h);
|
|
240
191
|
Meta.set(obj, Meta.Handle, h);
|
|
241
192
|
Meta.set(os.data, Meta.Revision, new Subscription(1));
|
|
242
193
|
}
|
|
243
194
|
return h;
|
|
244
195
|
}
|
|
245
|
-
static
|
|
196
|
+
static createHandleForMvccObject(proto, data, blank, hint, reactive) {
|
|
246
197
|
const ctx = Changeset.edit();
|
|
247
|
-
const
|
|
198
|
+
const mvcc = reactive ? Mvcc.reactive : Mvcc.transactional;
|
|
199
|
+
const h = new ObjectHandle(data, undefined, mvcc, EMPTY_SNAPSHOT, hint);
|
|
248
200
|
ctx.getEditableObjectSnapshot(h, Meta.Handle, blank);
|
|
249
|
-
if (!
|
|
201
|
+
if (!Mvcc.reactionsAutoStartDisabled)
|
|
250
202
|
for (const m in Meta.getFrom(proto, Meta.Reactions))
|
|
251
203
|
h.proxy[m][Meta.Controller].markObsolete();
|
|
252
204
|
return h;
|
|
253
205
|
}
|
|
254
206
|
static setProfilingMode(isOn, options) {
|
|
255
207
|
if (isOn) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
208
|
+
Mvcc.repetitiveUsageWarningThreshold = options && options.repetitiveUsageWarningThreshold !== undefined ? options.repetitiveUsageWarningThreshold : 10;
|
|
209
|
+
Mvcc.mainThreadBlockingWarningThreshold = options && options.mainThreadBlockingWarningThreshold !== undefined ? options.mainThreadBlockingWarningThreshold : 14;
|
|
210
|
+
Mvcc.asyncActionDurationWarningThreshold = options && options.asyncActionDurationWarningThreshold !== undefined ? options.asyncActionDurationWarningThreshold : 300;
|
|
259
211
|
Changeset.garbageCollectionSummaryInterval = options && options.garbageCollectionSummaryInterval !== undefined ? options.garbageCollectionSummaryInterval : 100;
|
|
260
212
|
}
|
|
261
213
|
else {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
214
|
+
Mvcc.repetitiveUsageWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
215
|
+
Mvcc.mainThreadBlockingWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
216
|
+
Mvcc.asyncActionDurationWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
265
217
|
Changeset.garbageCollectionSummaryInterval = Number.MAX_SAFE_INTEGER;
|
|
266
218
|
}
|
|
267
219
|
}
|
|
268
220
|
static sensitive(sensitivity, func, ...args) {
|
|
269
|
-
const restore =
|
|
270
|
-
|
|
221
|
+
const restore = Mvcc.sensitivity;
|
|
222
|
+
Mvcc.sensitivity = sensitivity;
|
|
271
223
|
try {
|
|
272
224
|
return func(...args);
|
|
273
225
|
}
|
|
274
226
|
finally {
|
|
275
|
-
|
|
227
|
+
Mvcc.sensitivity = restore;
|
|
276
228
|
}
|
|
277
229
|
}
|
|
278
230
|
static setHint(obj, hint) {
|
|
279
231
|
if (hint) {
|
|
280
|
-
const h =
|
|
232
|
+
const h = Mvcc.acquireHandle(obj);
|
|
281
233
|
h.hint = hint;
|
|
282
234
|
}
|
|
283
235
|
return obj;
|
|
284
236
|
}
|
|
285
237
|
static getHint(obj) {
|
|
286
|
-
const h =
|
|
238
|
+
const h = Mvcc.acquireHandle(obj);
|
|
287
239
|
return h.hint;
|
|
288
240
|
}
|
|
289
241
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
242
|
+
Mvcc.reactionsAutoStartDisabled = false;
|
|
243
|
+
Mvcc.repetitiveUsageWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
244
|
+
Mvcc.mainThreadBlockingWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
245
|
+
Mvcc.asyncActionDurationWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
246
|
+
Mvcc.sensitivity = false;
|
|
247
|
+
Mvcc.transactional = new Mvcc(false);
|
|
248
|
+
Mvcc.reactive = new Mvcc(true);
|
|
249
|
+
Mvcc.createOperation = function (h, m, options) {
|
|
250
|
+
throw misuse('this implementation of createOperation should never be called');
|
|
298
251
|
};
|
|
299
|
-
|
|
300
|
-
throw misuse('rememberOperationOptions should never be called');
|
|
252
|
+
Mvcc.rememberOperationOptions = function (proto, m, getter, setter, enumerable, configurable, options, implicit) {
|
|
253
|
+
throw misuse('this implementation of rememberOperationOptions should never be called');
|
|
301
254
|
};
|
|
302
255
|
const EMPTY_PROP_DESCRIPTOR = {
|
|
303
256
|
configurable: true,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MvccObject } from './Mvcc';
|
|
2
|
+
export declare class MvccArray<T> extends MvccObject {
|
|
3
|
+
private all;
|
|
4
|
+
constructor(reactive: boolean, array: Array<T>);
|
|
5
|
+
get length(): number;
|
|
6
|
+
set length(n: number);
|
|
7
|
+
getItem(n: number): T;
|
|
8
|
+
setItem(n: number, item: T): void;
|
|
9
|
+
toString(): string;
|
|
10
|
+
toLocaleString(): string;
|
|
11
|
+
pop(): T | undefined;
|
|
12
|
+
push(...items: T[]): number;
|
|
13
|
+
concat(...items: (T | ConcatArray<T>)[]): T[];
|
|
14
|
+
concat(...items: ConcatArray<T>[]): T[];
|
|
15
|
+
join(separator?: string): string;
|
|
16
|
+
reverse(): T[];
|
|
17
|
+
shift(): T | undefined;
|
|
18
|
+
slice(start?: number, end?: number): T[];
|
|
19
|
+
sort(compareFn?: (a: T, b: T) => number): this;
|
|
20
|
+
splice(start: number, deleteCount?: number): T[];
|
|
21
|
+
splice(start: number, deleteCount: number, ...items: T[]): T[];
|
|
22
|
+
unshift(...items: T[]): number;
|
|
23
|
+
includes(searchElement: T, fromIndex?: number): boolean;
|
|
24
|
+
indexOf(searchElement: T, fromIndex?: number): number;
|
|
25
|
+
lastIndexOf(searchElement: T, fromIndex?: number): number;
|
|
26
|
+
every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
|
|
27
|
+
every<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[];
|
|
28
|
+
some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
|
|
29
|
+
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
|
30
|
+
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
|
|
31
|
+
filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[];
|
|
32
|
+
filter<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[];
|
|
33
|
+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
|
34
|
+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
|
|
35
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
|
|
36
|
+
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
|
37
|
+
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
|
|
38
|
+
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
|
|
39
|
+
find<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
|
|
40
|
+
findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;
|
|
41
|
+
fill(value: T, start?: number, end?: number): this;
|
|
42
|
+
copyWithin(target: number, start: number, end?: number): this;
|
|
43
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
44
|
+
entries(): IterableIterator<[number, T]>;
|
|
45
|
+
keys(): IterableIterator<number>;
|
|
46
|
+
values(): IterableIterator<T>;
|
|
47
|
+
private get mutable();
|
|
48
|
+
}
|
|
49
|
+
export declare class TransactionalArray<T> extends MvccArray<T> {
|
|
50
|
+
constructor();
|
|
51
|
+
constructor(arrayLength: number);
|
|
52
|
+
constructor(arrayLength?: number);
|
|
53
|
+
constructor(...items: T[]);
|
|
54
|
+
}
|
|
55
|
+
export declare class ReactiveArray<T> extends MvccArray<T> {
|
|
56
|
+
constructor();
|
|
57
|
+
constructor(arrayLength: number);
|
|
58
|
+
constructor(arrayLength?: number);
|
|
59
|
+
constructor(...items: T[]);
|
|
60
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Sealant } from '../util/Sealant';
|
|
2
|
+
import { MvccObject } from './Mvcc';
|
|
3
|
+
export class MvccArray extends MvccObject {
|
|
4
|
+
constructor(reactive, array) {
|
|
5
|
+
super(reactive);
|
|
6
|
+
this.all = array;
|
|
7
|
+
}
|
|
8
|
+
get length() { return this.all.length; }
|
|
9
|
+
set length(n) { this.mutable.length = n; }
|
|
10
|
+
getItem(n) { return this.all[n]; }
|
|
11
|
+
setItem(n, item) { this.mutable[n] = item; }
|
|
12
|
+
toString() { return this.all.toString(); }
|
|
13
|
+
toLocaleString() { return this.all.toLocaleString(); }
|
|
14
|
+
pop() { return this.mutable.pop(); }
|
|
15
|
+
push(...items) { return this.mutable.push(...items); }
|
|
16
|
+
concat(...items) { return this.all.concat(...items); }
|
|
17
|
+
join(separator) { return this.all.join(separator); }
|
|
18
|
+
reverse() { return this.mutable.reverse(); }
|
|
19
|
+
shift() { return this.mutable.shift(); }
|
|
20
|
+
slice(start, end) { return this.all.slice(start, end); }
|
|
21
|
+
sort(compareFn) { this.mutable.sort(compareFn); return this; }
|
|
22
|
+
splice(start, deleteCount, ...items) { return this.mutable.splice(start, deleteCount, ...items); }
|
|
23
|
+
unshift(...items) { return this.mutable.unshift(...items); }
|
|
24
|
+
includes(searchElement, fromIndex) { return this.all.includes(searchElement, fromIndex); }
|
|
25
|
+
indexOf(searchElement, fromIndex) { return this.all.indexOf(searchElement, fromIndex); }
|
|
26
|
+
lastIndexOf(searchElement, fromIndex) { return this.all.lastIndexOf(searchElement, fromIndex); }
|
|
27
|
+
every(predicate, thisArg) { return this.all.every(predicate, thisArg); }
|
|
28
|
+
some(predicate, thisArg) { return this.all.some(predicate, thisArg); }
|
|
29
|
+
forEach(callbackfn, thisArg) { return this.all.forEach(callbackfn, thisArg); }
|
|
30
|
+
map(callbackfn, thisArg) { return this.all.map(callbackfn, thisArg); }
|
|
31
|
+
filter(predicate, thisArg) { return this.all.filter(predicate, thisArg); }
|
|
32
|
+
reduce(callbackfn, initialValue) { return initialValue !== undefined ? this.all.reduce(callbackfn, initialValue) : this.all.reduce(callbackfn); }
|
|
33
|
+
reduceRight(callbackfn, initialValue) { return initialValue !== undefined ? this.all.reduceRight(callbackfn, initialValue) : this.all.reduceRight(callbackfn); }
|
|
34
|
+
find(predicate, thisArg) { return this.all.find(predicate, thisArg); }
|
|
35
|
+
findIndex(predicate, thisArg) { return this.all.findIndex(predicate, thisArg); }
|
|
36
|
+
fill(value, start, end) { this.mutable.fill(value, start, end); return this; }
|
|
37
|
+
copyWithin(target, start, end) { this.mutable.copyWithin(target, start, end); return this; }
|
|
38
|
+
[Symbol.iterator]() { return this.all[Symbol.iterator](); }
|
|
39
|
+
entries() { return this.all.entries(); }
|
|
40
|
+
keys() { return this.all.keys(); }
|
|
41
|
+
values() { return this.all.values(); }
|
|
42
|
+
get mutable() {
|
|
43
|
+
const createCopy = this.all[Sealant.CreateCopy];
|
|
44
|
+
if (createCopy)
|
|
45
|
+
return this.all = createCopy.call(this.all);
|
|
46
|
+
return this.all;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class TransactionalArray extends MvccArray {
|
|
50
|
+
constructor(args) {
|
|
51
|
+
super(false, args !== undefined ? new Array(args) : new Array());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class ReactiveArray extends MvccArray {
|
|
55
|
+
constructor(args) {
|
|
56
|
+
super(true, args !== undefined ? new Array(args) : new Array());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Collection, Item, CollectionReader } from '../util/Collection';
|
|
2
|
+
import { ReactiveObject } from './Mvcc';
|
|
3
|
+
export declare abstract class ReactiveCollection<T> extends ReactiveObject implements CollectionReader<T> {
|
|
4
|
+
protected abstract a: Collection<T>;
|
|
5
|
+
get strict(): boolean;
|
|
6
|
+
get count(): number;
|
|
7
|
+
get addedCount(): number;
|
|
8
|
+
get removedCount(): number;
|
|
9
|
+
get isMergeInProgress(): boolean;
|
|
10
|
+
lookup(key: string): Item<T> | undefined;
|
|
11
|
+
claim(key: string): Item<T> | undefined;
|
|
12
|
+
add(self: T): Item<T>;
|
|
13
|
+
remove(item: Item<T>): void;
|
|
14
|
+
move(item: Item<T>, after: Item<T>): void;
|
|
15
|
+
beginMerge(): void;
|
|
16
|
+
endMerge(error?: unknown): void;
|
|
17
|
+
resetAddedAndRemovedLists(): void;
|
|
18
|
+
items(): Generator<Item<T>>;
|
|
19
|
+
addedItems(reset?: boolean): Generator<Item<T>>;
|
|
20
|
+
removedItems(reset?: boolean): Generator<Item<T>>;
|
|
21
|
+
isAdded(item: Item<T>): boolean;
|
|
22
|
+
isMoved(item: Item<T>): boolean;
|
|
23
|
+
isRemoved(item: Item<T>): boolean;
|
|
24
|
+
isCurrent(item: Item<T>): boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactiveObject } from './Mvcc';
|
|
2
|
+
export class ReactiveCollection extends ReactiveObject {
|
|
3
|
+
get strict() { return this.a.strict; }
|
|
4
|
+
get count() { return this.a.count; }
|
|
5
|
+
get addedCount() { return this.a.addedCount; }
|
|
6
|
+
get removedCount() { return this.a.removedCount; }
|
|
7
|
+
get isMergeInProgress() { return this.a.isMergeInProgress; }
|
|
8
|
+
lookup(key) { return this.a.lookup(key); }
|
|
9
|
+
claim(key) { return this.a.claim(key); }
|
|
10
|
+
add(self) { return this.a.add(self); }
|
|
11
|
+
remove(item) { return this.a.remove(item); }
|
|
12
|
+
move(item, after) { this.a.move(item, after); }
|
|
13
|
+
beginMerge() { this.a.beginMerge(); }
|
|
14
|
+
endMerge(error) { this.a.endMerge(error); }
|
|
15
|
+
resetAddedAndRemovedLists() { this.a.resetAddedAndRemovedLists(); }
|
|
16
|
+
items() { return this.a.items(); }
|
|
17
|
+
addedItems(reset) { return this.a.addedItems(reset); }
|
|
18
|
+
removedItems(reset) { return this.a.removedItems(reset); }
|
|
19
|
+
isAdded(item) { return this.a.isAdded(item); }
|
|
20
|
+
isMoved(item) { return this.a.isMoved(item); }
|
|
21
|
+
isRemoved(item) { return this.a.isRemoved(item); }
|
|
22
|
+
isCurrent(item) { return this.a.isCurrent(item); }
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MvccObject } from './Mvcc';
|
|
2
|
+
export declare class MvccMap<K, V> extends MvccObject {
|
|
3
|
+
private all;
|
|
4
|
+
constructor(reactive: boolean, map: Map<K, V>);
|
|
5
|
+
clear(): void;
|
|
6
|
+
delete(key: K): boolean;
|
|
7
|
+
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
|
8
|
+
get(key: K): V | undefined;
|
|
9
|
+
has(key: K): boolean;
|
|
10
|
+
set(key: K, value: V): this;
|
|
11
|
+
get size(): number;
|
|
12
|
+
entries(): IterableIterator<[K, V]>;
|
|
13
|
+
keys(): IterableIterator<K>;
|
|
14
|
+
values(): IterableIterator<V>;
|
|
15
|
+
[Symbol.toStringTag](): string;
|
|
16
|
+
private get mutable();
|
|
17
|
+
}
|
|
18
|
+
export declare class TransactionalMap<K, V> extends MvccMap<K, V> {
|
|
19
|
+
constructor();
|
|
20
|
+
constructor(iterable?: Iterable<readonly [K, V]> | null);
|
|
21
|
+
}
|
|
22
|
+
export declare class ReactiveMap<K, V> extends MvccMap<K, V> {
|
|
23
|
+
constructor();
|
|
24
|
+
constructor(iterable?: Iterable<readonly [K, V]> | null);
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Sealant } from '../util/Sealant';
|
|
2
|
+
import { MvccObject } from './Mvcc';
|
|
3
|
+
export class MvccMap extends MvccObject {
|
|
4
|
+
constructor(reactive, map) {
|
|
5
|
+
super(reactive);
|
|
6
|
+
this.all = map;
|
|
7
|
+
}
|
|
8
|
+
clear() { this.mutable.clear(); }
|
|
9
|
+
delete(key) { return this.mutable.delete(key); }
|
|
10
|
+
forEach(callbackfn, thisArg) { this.all.forEach(callbackfn, thisArg); }
|
|
11
|
+
get(key) { return this.all.get(key); }
|
|
12
|
+
has(key) { return this.all.has(key); }
|
|
13
|
+
set(key, value) { this.mutable.set(key, value); return this; }
|
|
14
|
+
get size() { return this.all.size; }
|
|
15
|
+
entries() { return this.all.entries(); }
|
|
16
|
+
keys() { return this.all.keys(); }
|
|
17
|
+
values() { return this.all.values(); }
|
|
18
|
+
[Symbol.toStringTag]() { return this.all[Symbol.toStringTag]; }
|
|
19
|
+
get mutable() {
|
|
20
|
+
const createCopy = this.all[Sealant.CreateCopy];
|
|
21
|
+
if (createCopy)
|
|
22
|
+
return this.all = createCopy.call(this.all);
|
|
23
|
+
return this.all;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class TransactionalMap extends MvccMap {
|
|
27
|
+
constructor(args) {
|
|
28
|
+
super(true, args !== undefined ? new Map(args) : new Map());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class ReactiveMap extends MvccMap {
|
|
32
|
+
constructor(args) {
|
|
33
|
+
super(true, args !== undefined ? new Map(args) : new Map());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -3,7 +3,7 @@ import { MemberOptions } from '../Options';
|
|
|
3
3
|
import { Controller } from '../Controller';
|
|
4
4
|
import { MemberName, ObjectHandle, Subscription, Subscriber, SubscriptionInfo, AbstractChangeset } from './Data';
|
|
5
5
|
import { Transaction } from './Transaction';
|
|
6
|
-
import { OptionsImpl } from './
|
|
6
|
+
import { OptionsImpl } from './Mvcc';
|
|
7
7
|
export declare class OperationController extends Controller<any> {
|
|
8
8
|
readonly objectHandle: ObjectHandle;
|
|
9
9
|
readonly memberName: MemberName;
|
|
@@ -19,7 +19,7 @@ export declare class OperationController extends Controller<any> {
|
|
|
19
19
|
pullLastResult(args?: any[]): any;
|
|
20
20
|
constructor(h: ObjectHandle, m: MemberName);
|
|
21
21
|
useOrRun(weak: boolean, args: any[] | undefined): Operation;
|
|
22
|
-
static
|
|
22
|
+
static getControllerOf(method: F<any>): Controller<any>;
|
|
23
23
|
static configureImpl(self: OperationController | undefined, options: Partial<MemberOptions>): MemberOptions;
|
|
24
24
|
static runWithin<T>(op: Operation | undefined, func: F<T>, ...args: any[]): T;
|
|
25
25
|
static why(): string;
|
|
@@ -55,7 +55,7 @@ declare class Operation extends Subscription implements Subscriber {
|
|
|
55
55
|
get originSnapshotId(): number;
|
|
56
56
|
hint(): string;
|
|
57
57
|
get order(): number;
|
|
58
|
-
get ['#this'](): string;
|
|
58
|
+
get ['#this#'](): string;
|
|
59
59
|
why(): string;
|
|
60
60
|
briefWhy(): string;
|
|
61
61
|
dependencies(): string[];
|