reactronic 0.92.25007 → 0.92.25009
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/build/dist/source/Clock.d.ts +1 -0
- package/build/dist/source/Clock.js +12 -4
- package/build/dist/source/Reaction.js +2 -2
- package/build/dist/source/ReactiveSystem.d.ts +8 -8
- package/build/dist/source/ReactiveSystem.js +10 -10
- package/build/dist/source/Ref.js +3 -3
- package/build/dist/source/api.d.ts +2 -2
- package/build/dist/source/api.js +2 -2
- package/build/dist/source/core/ReactiveNode.js +9 -9
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { ObservableObject } from "./core/Mvcc.js";
|
|
11
|
-
import {
|
|
11
|
+
import { atomic, reactive } from "./ReactiveSystem.js";
|
|
12
12
|
export class Clock extends ObservableObject {
|
|
13
13
|
constructor(interval = 1000) {
|
|
14
14
|
super();
|
|
@@ -19,7 +19,6 @@ export class Clock extends ObservableObject {
|
|
|
19
19
|
this.interval = 0;
|
|
20
20
|
this.paused = false;
|
|
21
21
|
this.interval = interval;
|
|
22
|
-
this.tick();
|
|
23
22
|
}
|
|
24
23
|
pause(value = true) {
|
|
25
24
|
this.paused = value;
|
|
@@ -38,16 +37,25 @@ export class Clock extends ObservableObject {
|
|
|
38
37
|
setTimeout(() => this.tick(), this.interval - calibration);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
40
|
+
start() {
|
|
41
|
+
this.tick();
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
__decorate([
|
|
43
|
-
|
|
45
|
+
atomic,
|
|
44
46
|
__metadata("design:type", Function),
|
|
45
47
|
__metadata("design:paramtypes", [Boolean]),
|
|
46
48
|
__metadata("design:returntype", void 0)
|
|
47
49
|
], Clock.prototype, "pause", null);
|
|
48
50
|
__decorate([
|
|
49
|
-
|
|
51
|
+
atomic,
|
|
50
52
|
__metadata("design:type", Function),
|
|
51
53
|
__metadata("design:paramtypes", []),
|
|
52
54
|
__metadata("design:returntype", void 0)
|
|
53
55
|
], Clock.prototype, "tick", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
reactive,
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", []),
|
|
60
|
+
__metadata("design:returntype", void 0)
|
|
61
|
+
], Clock.prototype, "start", null);
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { ObservableObject } from "./core/Mvcc.js";
|
|
11
|
-
import {
|
|
11
|
+
import { reactive } from "./ReactiveSystem.js";
|
|
12
12
|
export class ReactiveProcess extends ObservableObject {
|
|
13
13
|
constructor(action) {
|
|
14
14
|
super();
|
|
@@ -19,7 +19,7 @@ export class ReactiveProcess extends ObservableObject {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
__decorate([
|
|
22
|
-
|
|
22
|
+
reactive,
|
|
23
23
|
__metadata("design:type", Function),
|
|
24
24
|
__metadata("design:paramtypes", []),
|
|
25
25
|
__metadata("design:returntype", Object)
|
|
@@ -17,14 +17,14 @@ export declare class ReactiveSystem {
|
|
|
17
17
|
static getLoggingHint<T extends object>(obj: T, full?: boolean): string | undefined;
|
|
18
18
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
19
19
|
}
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
20
|
+
export declare function atomicRun<T>(func: F<T>, ...args: any[]): T;
|
|
21
|
+
export declare function atomicRun<T>(options: SnapshotOptions, func: F<T>, ...args: any[]): T;
|
|
22
|
+
export declare function nonReactiveRun<T>(func: F<T>, ...args: any[]): T;
|
|
23
|
+
export declare function sensitiveRun<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
24
|
+
export declare function contextualRun<T>(p: Promise<T>): Promise<T>;
|
|
25
25
|
export declare function unobservable(proto: object, prop: PropertyKey): any;
|
|
26
26
|
export declare function observable(proto: object, prop: PropertyKey): any;
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
27
|
+
export declare function atomic(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
|
+
export declare function reactive(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
29
|
+
export declare function cached(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
30
30
|
export declare function options(value: Partial<MemberOptions>): F<any>;
|
|
@@ -22,7 +22,7 @@ export class ReactiveSystem {
|
|
|
22
22
|
static getLoggingHint(obj, full = false) { return ObjectHandle.getHint(obj, full); }
|
|
23
23
|
static setProfilingMode(isOn, options) { Mvcc.setProfilingMode(isOn, options); }
|
|
24
24
|
}
|
|
25
|
-
export function
|
|
25
|
+
export function atomicRun(p1, p2, p3) {
|
|
26
26
|
if (p1 instanceof Function) {
|
|
27
27
|
if (p2 !== undefined)
|
|
28
28
|
return Transaction.run(null, p1, ...p2);
|
|
@@ -36,13 +36,13 @@ export function atomically(p1, p2, p3) {
|
|
|
36
36
|
return Transaction.run(p1, p2);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
export function
|
|
39
|
+
export function nonReactiveRun(func, ...args) {
|
|
40
40
|
return OperationImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
41
41
|
}
|
|
42
|
-
export function
|
|
42
|
+
export function sensitiveRun(sensitivity, func, ...args) {
|
|
43
43
|
return Mvcc.sensitive(sensitivity, func, ...args);
|
|
44
44
|
}
|
|
45
|
-
export function
|
|
45
|
+
export function contextualRun(p) {
|
|
46
46
|
throw new Error("not implemented yet");
|
|
47
47
|
}
|
|
48
48
|
export function unobservable(proto, prop) {
|
|
@@ -51,28 +51,28 @@ export function unobservable(proto, prop) {
|
|
|
51
51
|
export function observable(proto, prop) {
|
|
52
52
|
return Mvcc.decorateData(true, proto, prop);
|
|
53
53
|
}
|
|
54
|
-
export function
|
|
54
|
+
export function atomic(proto, prop, pd) {
|
|
55
55
|
const opts = {
|
|
56
56
|
kind: Kind.atomicAction,
|
|
57
57
|
isolation: Isolation.joinToCurrentTransaction,
|
|
58
58
|
};
|
|
59
|
-
return Mvcc.decorateOperation(true,
|
|
59
|
+
return Mvcc.decorateOperation(true, atomic, opts, proto, prop, pd);
|
|
60
60
|
}
|
|
61
|
-
export function
|
|
61
|
+
export function reactive(proto, prop, pd) {
|
|
62
62
|
const opts = {
|
|
63
63
|
kind: Kind.reactiveProcess,
|
|
64
64
|
isolation: Isolation.joinAsNestedTransaction,
|
|
65
65
|
throttling: -1,
|
|
66
66
|
};
|
|
67
|
-
return Mvcc.decorateOperation(true,
|
|
67
|
+
return Mvcc.decorateOperation(true, reactive, opts, proto, prop, pd);
|
|
68
68
|
}
|
|
69
|
-
export function
|
|
69
|
+
export function cached(proto, prop, pd) {
|
|
70
70
|
const opts = {
|
|
71
71
|
kind: Kind.cachedResult,
|
|
72
72
|
isolation: Isolation.joinToCurrentTransaction,
|
|
73
73
|
noSideEffects: true,
|
|
74
74
|
};
|
|
75
|
-
return Mvcc.decorateOperation(true,
|
|
75
|
+
return Mvcc.decorateOperation(true, cached, opts, proto, prop, pd);
|
|
76
76
|
}
|
|
77
77
|
export function options(value) {
|
|
78
78
|
return Mvcc.decorateOperationParametrized(options, value);
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { atomicRun, nonReactiveRun } from "./ReactiveSystem.js";
|
|
2
2
|
export function refs(owner) {
|
|
3
3
|
return new Proxy(owner, RefGettingProxy);
|
|
4
4
|
}
|
|
@@ -28,7 +28,7 @@ export class Ref {
|
|
|
28
28
|
this.owner[this.name][this.index] = value;
|
|
29
29
|
}
|
|
30
30
|
unobs() {
|
|
31
|
-
return
|
|
31
|
+
return nonReactiveRun(() => this.variable);
|
|
32
32
|
}
|
|
33
33
|
observe() {
|
|
34
34
|
return this.variable;
|
|
@@ -52,7 +52,7 @@ export class ToggleRef extends Ref {
|
|
|
52
52
|
toggle() {
|
|
53
53
|
const o = this.owner;
|
|
54
54
|
const p = this.name;
|
|
55
|
-
|
|
55
|
+
atomicRun({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
56
56
|
const v = o[p];
|
|
57
57
|
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
58
58
|
Ref.sameRefs(v, this.valueOn));
|
|
@@ -16,8 +16,8 @@ export { Changeset } from "./core/Changeset.js";
|
|
|
16
16
|
export { Transaction } from "./core/Transaction.js";
|
|
17
17
|
export { Indicator } from "./core/Indicator.js";
|
|
18
18
|
export { Journal } from "./core/Journal.js";
|
|
19
|
-
export {
|
|
20
|
-
export { ReactiveSystem, observable, unobservable,
|
|
19
|
+
export { atomicRun, nonReactiveRun, sensitiveRun, contextualRun } from "./ReactiveSystem.js";
|
|
20
|
+
export { ReactiveSystem, observable, unobservable, atomic, reactive, cached, options } from "./ReactiveSystem.js";
|
|
21
21
|
export { ReactiveProcess } from "./Reaction.js";
|
|
22
22
|
export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
|
|
23
23
|
export type { Script, ScriptAsync, Handler, ReactiveNodeDecl, ReactiveNodeDriver, ReactiveNodeContext } from "./core/ReactiveNode.js";
|
package/build/dist/source/api.js
CHANGED
|
@@ -12,8 +12,8 @@ export { Changeset } from "./core/Changeset.js";
|
|
|
12
12
|
export { Transaction } from "./core/Transaction.js";
|
|
13
13
|
export { Indicator } from "./core/Indicator.js";
|
|
14
14
|
export { Journal } from "./core/Journal.js";
|
|
15
|
-
export {
|
|
16
|
-
export { ReactiveSystem, observable, unobservable,
|
|
15
|
+
export { atomicRun, nonReactiveRun, sensitiveRun, contextualRun } from "./ReactiveSystem.js";
|
|
16
|
+
export { ReactiveSystem, observable, unobservable, atomic, reactive, cached, options } from "./ReactiveSystem.js";
|
|
17
17
|
export { ReactiveProcess } from "./Reaction.js";
|
|
18
18
|
export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
|
|
19
19
|
export { Clock } from "./Clock.js";
|
|
@@ -22,7 +22,7 @@ import { emitLetters, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js
|
|
|
22
22
|
import { Isolation, Reentrance } from "../Options.js";
|
|
23
23
|
import { ObservableObject } from "../core/Mvcc.js";
|
|
24
24
|
import { Transaction } from "../core/Transaction.js";
|
|
25
|
-
import { ReactiveSystem, options, unobservable,
|
|
25
|
+
import { ReactiveSystem, options, unobservable, reactive, atomicRun, nonReactiveRun } from "../ReactiveSystem.js";
|
|
26
26
|
export var Mode;
|
|
27
27
|
(function (Mode) {
|
|
28
28
|
Mode[Mode["default"] = 0] = "default";
|
|
@@ -333,13 +333,13 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
333
333
|
static setNodeVariableValue(variable, value) {
|
|
334
334
|
const node = ReactiveNodeImpl.ownSlot.instance;
|
|
335
335
|
const owner = node.owner;
|
|
336
|
-
const hostCtx =
|
|
336
|
+
const hostCtx = nonReactiveRun(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
|
|
337
337
|
if (value && value !== hostCtx) {
|
|
338
338
|
if (hostCtx)
|
|
339
339
|
node.outer = owner;
|
|
340
340
|
else
|
|
341
341
|
node.outer = owner.outer;
|
|
342
|
-
|
|
342
|
+
atomicRun({ isolation: Isolation.joinAsNestedTransaction }, () => {
|
|
343
343
|
const ctx = node.context;
|
|
344
344
|
if (ctx) {
|
|
345
345
|
ctx.variable = variable;
|
|
@@ -359,7 +359,7 @@ ReactiveNodeImpl.logging = undefined;
|
|
|
359
359
|
ReactiveNodeImpl.grandNodeCount = 0;
|
|
360
360
|
ReactiveNodeImpl.disposableNodeCount = 0;
|
|
361
361
|
__decorate([
|
|
362
|
-
|
|
362
|
+
reactive,
|
|
363
363
|
options({
|
|
364
364
|
reentrance: Reentrance.cancelAndWaitPrevious,
|
|
365
365
|
allowObsoleteToFinish: true,
|
|
@@ -484,7 +484,7 @@ function triggerUpdateViaSlot(slot) {
|
|
|
484
484
|
});
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
nonReactiveRun(node.update, node.declaration.triggers);
|
|
488
488
|
}
|
|
489
489
|
else
|
|
490
490
|
updateNow(slot);
|
|
@@ -493,7 +493,7 @@ function triggerUpdateViaSlot(slot) {
|
|
|
493
493
|
function mountOrRemountIfNecessary(node) {
|
|
494
494
|
const driver = node.driver;
|
|
495
495
|
if (node.stamp === Number.MAX_SAFE_INTEGER) {
|
|
496
|
-
|
|
496
|
+
nonReactiveRun(() => {
|
|
497
497
|
node.stamp = Number.MAX_SAFE_INTEGER - 1;
|
|
498
498
|
driver.runPreparation(node);
|
|
499
499
|
if (!node.has(Mode.manualMount)) {
|
|
@@ -504,7 +504,7 @@ function mountOrRemountIfNecessary(node) {
|
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
else if (node.isMoved && !node.has(Mode.manualMount) && node.host !== node)
|
|
507
|
-
|
|
507
|
+
nonReactiveRun(() => driver.runMount(node));
|
|
508
508
|
}
|
|
509
509
|
function updateNow(slot) {
|
|
510
510
|
const node = slot.instance;
|
|
@@ -537,7 +537,7 @@ function triggerFinalization(slot, isLeader, individual) {
|
|
|
537
537
|
if (individual && node.key !== node.declaration.key && !driver.isPartition)
|
|
538
538
|
console.log(`WARNING: it is recommended to assign explicit key for conditional element in order to avoid unexpected side effects: ${node.key}`);
|
|
539
539
|
node.stamp = ~node.stamp;
|
|
540
|
-
const childrenAreLeaders =
|
|
540
|
+
const childrenAreLeaders = nonReactiveRun(() => driver.runFinalization(node, isLeader));
|
|
541
541
|
if (node.has(Mode.autonomous)) {
|
|
542
542
|
slot.aux = undefined;
|
|
543
543
|
const last = gLastToDispose;
|
|
@@ -546,7 +546,7 @@ function triggerFinalization(slot, isLeader, individual) {
|
|
|
546
546
|
else
|
|
547
547
|
gFirstToDispose = gLastToDispose = slot;
|
|
548
548
|
if (gFirstToDispose === slot)
|
|
549
|
-
|
|
549
|
+
atomicRun({ isolation: Isolation.disjoinForInternalDisposal, hint: `runDisposalLoop(initiator=${slot.instance.key})` }, () => {
|
|
550
550
|
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
551
551
|
});
|
|
552
552
|
}
|