reactronic 0.21.516 → 0.21.520

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 CHANGED
@@ -6,7 +6,7 @@
6
6
  [![CircleCI Status](https://circleci.com/gh/nezaboodka/reactronic.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/nezaboodka/reactronic)
7
7
  ![Coverage](https://img.shields.io/badge/coverage-97%25-success.svg)
8
8
  ![Lines](https://img.shields.io/badge/lines-1715-success.svg)
9
- [![Demo](https://img.shields.io/badge/demo-live-success.svg)](https://gitlab.com/nezaboodka/nevod.web.public/-/blob/master/README.md)
9
+ [![Demo](https://img.shields.io/badge/demo-live-success.svg)](https://gitlab.com/nezaboodka/nevod.website/-/blob/master/README.md)
10
10
 
11
11
  # **Reactronic** - Transactional Reactive State Management
12
12
 
@@ -27,8 +27,8 @@ export declare class Ref<T = any> {
27
27
  static similarRefs(v1: Ref, v2: Ref): boolean;
28
28
  }
29
29
  export declare class ToggleRef<T = boolean> extends Ref<T> {
30
- readonly value1: T;
31
- readonly value2: T;
32
- constructor(owner: any, name: string, value1: T, value2: T);
30
+ readonly valueOn: T;
31
+ readonly valueOff: T;
32
+ constructor(owner: any, name: string, valueOn: T, valueOff: T);
33
33
  toggle(): void;
34
34
  }
@@ -49,22 +49,22 @@ class Ref {
49
49
  }
50
50
  exports.Ref = Ref;
51
51
  class ToggleRef extends Ref {
52
- constructor(owner, name, value1, value2) {
52
+ constructor(owner, name, valueOn, valueOff) {
53
53
  super(owner, name);
54
- this.value1 = value1;
55
- this.value2 = value2;
54
+ this.valueOn = valueOn;
55
+ this.valueOff = valueOff;
56
56
  }
57
57
  toggle() {
58
58
  const o = this.owner;
59
59
  const p = this.name;
60
60
  Transaction_1.Transaction.runAs({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
61
61
  const v = o[p];
62
- const isValue1 = v === this.value1 || (v instanceof Ref && this.value1 instanceof Ref &&
63
- Ref.sameRefs(v, this.value1));
64
- if (!isValue1)
65
- o[p] = this.value1;
62
+ const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
63
+ Ref.sameRefs(v, this.valueOn));
64
+ if (!isOn)
65
+ o[p] = this.valueOn;
66
66
  else
67
- o[p] = this.value2;
67
+ o[p] = this.valueOff;
68
68
  });
69
69
  }
70
70
  }
@@ -24,10 +24,10 @@ export interface ProfilingOptions {
24
24
  }
25
25
  export declare const TraceLevel: {
26
26
  Error: TraceOptions;
27
- Minimal: TraceOptions;
28
- Info: TraceOptions;
27
+ Transactions: TraceOptions;
28
+ Operations: TraceOptions;
29
29
  Debug: TraceOptions;
30
- Suppress: TraceOptions;
30
+ Silent: TraceOptions;
31
31
  };
32
32
  declare global {
33
33
  interface Window {
@@ -20,7 +20,7 @@ exports.TraceLevel = {
20
20
  margin1: 0,
21
21
  margin2: 0,
22
22
  },
23
- Minimal: {
23
+ Transactions: {
24
24
  silent: false,
25
25
  transaction: true,
26
26
  operation: false,
@@ -38,7 +38,7 @@ exports.TraceLevel = {
38
38
  margin1: 0,
39
39
  margin2: 0,
40
40
  },
41
- Info: {
41
+ Operations: {
42
42
  silent: false,
43
43
  transaction: true,
44
44
  operation: true,
@@ -74,7 +74,7 @@ exports.TraceLevel = {
74
74
  margin1: 0,
75
75
  margin2: 0,
76
76
  },
77
- Suppress: {
77
+ Silent: {
78
78
  silent: true,
79
79
  transaction: false,
80
80
  operation: false,
@@ -12,7 +12,7 @@ const Hooks_1 = require("./Hooks");
12
12
  const TransactionJournal_1 = require("./TransactionJournal");
13
13
  const ROOT_ARGS = [];
14
14
  const ROOT_HOLDER = new Data_1.ObjectHolder(undefined, undefined, Hooks_1.Hooks.proxy, Snapshot_1.ROOT_REV, 'root-holder');
15
- const ROOT_CAUSE = { revision: Snapshot_1.ROOT_REV, memberName: 'root-cause', usageCount: 0 };
15
+ const ROOT_TRIGGER = { revision: Snapshot_1.ROOT_REV, memberName: 'root-trigger', usageCount: 0 };
16
16
  class OperationController extends Controller_1.Controller {
17
17
  constructor(ownHolder, memberName) {
18
18
  super();
@@ -35,7 +35,7 @@ class OperationController extends Controller_1.Controller {
35
35
  const op = oc.operation;
36
36
  const opts = op.options;
37
37
  if (!oc.isUpToDate && oc.revision.data[Data_1.Meta.Disposed] === undefined
38
- && (!weak || op.cause === ROOT_CAUSE || !op.successor ||
38
+ && (!weak || op.cause === ROOT_TRIGGER || !op.successor ||
39
39
  op.successor.transaction.isFinished)) {
40
40
  const standalone = weak || opts.kind === Options_1.Kind.Reaction ||
41
41
  (opts.kind === Options_1.Kind.Cache && (oc.revision.snapshot.sealed ||
@@ -69,7 +69,7 @@ class OperationController extends Controller_1.Controller {
69
69
  throw (0, Dbg_1.misuse)('a method is expected with reactronic decorator');
70
70
  op.options = new Hooks_1.OptionsImpl(op.options.getter, op.options.setter, op.options, options, false);
71
71
  if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.write)
72
- Dbg_1.Dbg.log('║', ' ', `${op.hint()}.options = ...`);
72
+ Dbg_1.Dbg.log('║', ' ', `${op.hint()}.options = ...`);
73
73
  return op.options;
74
74
  }
75
75
  static runWithin(op, func, ...args) {
@@ -105,7 +105,7 @@ class OperationController extends Controller_1.Controller {
105
105
  const ctx = Snapshot_1.Snapshot.current();
106
106
  const r = ctx.seekRevision(this.ownHolder, this.memberName);
107
107
  const op = this.peekFromRevision(r);
108
- const isValid = op.options.kind !== Options_1.Kind.Transaction && op.cause !== ROOT_CAUSE &&
108
+ const isValid = op.options.kind !== Options_1.Kind.Transaction && op.cause !== ROOT_TRIGGER &&
109
109
  (ctx === op.revision.snapshot || ctx.timestamp < op.obsoleteSince) &&
110
110
  (!op.options.sensitiveArgs || args === undefined ||
111
111
  op.args.length === args.length && op.args.every((t, i) => t === args[i])) ||
@@ -144,7 +144,7 @@ class OperationController extends Controller_1.Controller {
144
144
  if (op2.controller !== this) {
145
145
  r2 = Snapshot_1.Snapshot.edit().getEditableRevision(h, m, Data_1.Meta.Holder, this);
146
146
  op2 = r2.data[m] = new Operation(this, r2, op2);
147
- op2.cause = ROOT_CAUSE;
147
+ op2.cause = ROOT_TRIGGER;
148
148
  Snapshot_1.Snapshot.markEdited(op2, true, r2, m, h);
149
149
  }
150
150
  return op2;
@@ -160,7 +160,7 @@ class OperationController extends Controller_1.Controller {
160
160
  if (!oc.operation.transaction.isCanceled) {
161
161
  oc = this.edit();
162
162
  if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.transaction || Dbg_1.Dbg.trace.operation || Dbg_1.Dbg.trace.obsolete))
163
- Dbg_1.Dbg.log('║', ' (f)', `${oc.operation.why()}`);
163
+ Dbg_1.Dbg.log('║', ' 𝑓', `${oc.operation.why()}`);
164
164
  oc.operation.run(this.ownHolder.proxy, argsx);
165
165
  }
166
166
  else {
@@ -168,7 +168,7 @@ class OperationController extends Controller_1.Controller {
168
168
  if (oc.operation.options.kind === Options_1.Kind.Transaction || !oc.isUpToDate) {
169
169
  oc = this.edit();
170
170
  if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.transaction || Dbg_1.Dbg.trace.operation || Dbg_1.Dbg.trace.obsolete))
171
- Dbg_1.Dbg.log('║', ' (f)', `${oc.operation.why()}`);
171
+ Dbg_1.Dbg.log('║', ' 𝑓', `${oc.operation.why()}`);
172
172
  oc.operation.run(this.ownHolder.proxy, argsx);
173
173
  }
174
174
  }
@@ -215,14 +215,14 @@ class Operation extends Data_1.Observable {
215
215
  const prev = this.revision.prev.revision.data[this.controller.memberName];
216
216
  if (prev instanceof Operation)
217
217
  ms = prev.started !== 0 ? Math.abs(this.started || ms) - Math.abs(prev.started) : Infinity;
218
- let cause;
218
+ let trigger;
219
219
  if (this.cause)
220
- cause = ` << ${propagationHint(this.cause, true).join(' << ')}`;
220
+ trigger = ` << ${propagationHint(this.cause, true).join(' << ')}`;
221
221
  else if (this.controller.options.kind === Options_1.Kind.Transaction)
222
- cause = ' << operation';
222
+ trigger = ' << operation';
223
223
  else
224
- cause = ` << called within ${this.revision.snapshot.hint}`;
225
- return `${this.hint()}${cause} (${ms !== Infinity ? `${ms}ms since previous run` : 'initial run'})`;
224
+ trigger = ` << called within ${this.revision.snapshot.hint}`;
225
+ return `${this.hint()}${trigger} (${ms !== Infinity ? `${ms}ms since previous run` : 'initial run'})`;
226
226
  }
227
227
  briefWhy() {
228
228
  return this.cause ? propagationHint(this.cause, false)[0] : ROOT_HOLDER.hint;
@@ -443,12 +443,12 @@ class Operation extends Data_1.Observable {
443
443
  static markEdited(value, edited, r, m, h) {
444
444
  edited ? r.changes.set(m, Operation.current) : r.changes.delete(m);
445
445
  if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.write)
446
- edited ? Dbg_1.Dbg.log('║', ' ', `${Snapshot_1.Dump.rev(r, m)} = ${valueHint(value)}`) : Dbg_1.Dbg.log('║', ' ', `${Snapshot_1.Dump.rev(r, m)} = ${valueHint(value)}`, undefined, ' (same as previous)');
446
+ edited ? Dbg_1.Dbg.log('║', ' ', `${Snapshot_1.Dump.rev(r, m)} = ${valueHint(value)}`) : Dbg_1.Dbg.log('║', ' ', `${Snapshot_1.Dump.rev(r, m)} = ${valueHint(value)}`, undefined, ' (same as previous)');
447
447
  }
448
448
  static isConflicting(oldValue, newValue) {
449
449
  let result = oldValue !== newValue;
450
450
  if (result)
451
- result = oldValue instanceof Operation && oldValue.cause !== ROOT_CAUSE;
451
+ result = oldValue instanceof Operation && oldValue.cause !== ROOT_TRIGGER;
452
452
  return result;
453
453
  }
454
454
  static propagateAllChangesThroughSubscriptions(snapshot) {
@@ -569,7 +569,7 @@ class Operation extends Data_1.Observable {
569
569
  }
570
570
  static init() {
571
571
  Object.freeze(ROOT_ARGS);
572
- Object.freeze(ROOT_CAUSE);
572
+ Object.freeze(ROOT_TRIGGER);
573
573
  Dbg_1.Dbg.getMergedTraceOptions = getMergedTraceOptions;
574
574
  Snapshot_1.Snapshot.markUsed = Operation.markUsed;
575
575
  Snapshot_1.Snapshot.markEdited = Operation.markEdited;
@@ -27,7 +27,7 @@ class Dbg {
27
27
  const t = Dbg.global;
28
28
  const o = Object.keys(Dbg.global).filter(x => t[x] === true).join(', ');
29
29
  Dbg.log('', '', `Reactronic trace is enabled: ${o}`);
30
- Dbg.log('', '', 'Method-level trace can be configured with @trace decorator');
30
+ Dbg.log('', '', 'Method-level trace can be configured with @options({ trace: ... }) decorator');
31
31
  }
32
32
  else
33
33
  Dbg.log('', '', 'Reactronic trace is disabled');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.21.516",
3
+ "version": "0.21.520",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "main": "build/dist/source/api.js",
6
6
  "types": "build/dist/source/api.d.ts",
@@ -29,16 +29,16 @@
29
29
  },
30
30
  "homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
31
31
  "devDependencies": {
32
- "@types/node": "16.10.1",
33
- "@types/react": "17.0.24",
34
- "@typescript-eslint/eslint-plugin": "4.31.2",
35
- "@typescript-eslint/parser": "4.31.2",
32
+ "@types/node": "16.11.10",
33
+ "@types/react": "17.0.37",
34
+ "@typescript-eslint/eslint-plugin": "5.4.0",
35
+ "@typescript-eslint/parser": "5.4.0",
36
36
  "ava": "3.15.0",
37
- "eslint": "7.32.0",
37
+ "eslint": "8.3.0",
38
38
  "nyc": "15.1.0",
39
39
  "react": "17.0.2",
40
- "ts-node": "10.2.1",
41
- "tsconfig-paths": "3.11.0",
40
+ "ts-node": "10.4.0",
41
+ "tsconfig-paths": "3.12.0",
42
42
  "typescript": "4.4.3"
43
43
  },
44
44
  "scripts": {