@tramvai/core 5.49.1 → 5.53.74

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.
@@ -34,6 +34,8 @@ function appProviders(name, bundles, actions, modules) {
34
34
  ];
35
35
  }
36
36
  class App {
37
+ di;
38
+ modulesToResolve;
37
39
  constructor({ name, modules = [], bundles = {}, actions = [], providers }) {
38
40
  this.di = createContainer();
39
41
  this.modulesToResolve = new Set();
package/lib/createApp.js CHANGED
@@ -38,6 +38,8 @@ function appProviders(name, bundles, actions, modules) {
38
38
  ];
39
39
  }
40
40
  class App {
41
+ di;
42
+ modulesToResolve;
41
43
  constructor({ name, modules = [], bundles = {}, actions = [], providers }) {
42
44
  this.di = dippy.createContainer();
43
45
  this.modulesToResolve = new Set();
package/lib/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './actions/declareAction';
5
5
  export * from '@tramvai/tokens-core';
6
6
  export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, Scope, Provider, createToken, provide, optional, ExtractTokenType, ExtractDependencyType, Module, MODULE_PARAMETERS, getModuleParameters, walkOfModules, isExtendedModule, ModuleType, ExtendedModule, declareModule, } from '@tinkoff/dippy';
7
7
  export { Deferred } from './utils/deferred.inline';
8
+ export { DoubleLinkedList } from './utils/doubleLinkedList';
8
9
  //# sourceMappingURL=index.d.ts.map
package/lib/index.es.js CHANGED
@@ -5,3 +5,4 @@ export { declareAction, isTramvaiAction } from './actions/declareAction.es.js';
5
5
  export * from '@tramvai/tokens-core';
6
6
  export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, MODULE_PARAMETERS, Module, Scope, createToken, declareModule, getModuleParameters, isExtendedModule, optional, provide, walkOfModules } from '@tinkoff/dippy';
7
7
  export { Deferred } from './utils/deferred.inline.es.js';
8
+ export { DoubleLinkedList } from './utils/doubleLinkedList.es.js';
package/lib/index.js CHANGED
@@ -9,6 +9,7 @@ var declareAction = require('./actions/declareAction.js');
9
9
  var tokensCore = require('@tramvai/tokens-core');
10
10
  var dippy = require('@tinkoff/dippy');
11
11
  var deferred_inline = require('./utils/deferred.inline.js');
12
+ var doubleLinkedList = require('./utils/doubleLinkedList.js');
12
13
 
13
14
 
14
15
 
@@ -67,6 +68,7 @@ Object.defineProperty(exports, 'walkOfModules', {
67
68
  get: function () { return dippy.walkOfModules; }
68
69
  });
69
70
  exports.Deferred = deferred_inline.Deferred;
71
+ exports.DoubleLinkedList = doubleLinkedList.DoubleLinkedList;
70
72
  Object.keys(tokensCore).forEach(function (k) {
71
73
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
72
74
  enumerable: true,
@@ -1,38 +1,41 @@
1
1
  class Deferred {
2
- constructor() {
2
+ promise;
3
+ status = 'pending';
4
+ resolve = () => { };
5
+ reject = () => { };
6
+ resolveData;
7
+ rejectReason;
8
+ isResolved = () => {
9
+ return typeof this.resolveData !== 'undefined';
10
+ };
11
+ isRejected = () => {
12
+ return typeof this.rejectReason !== 'undefined';
13
+ };
14
+ reset = () => {
3
15
  this.status = 'pending';
4
- this.resolve = () => { };
5
- this.reject = () => { };
6
- this.isResolved = () => {
7
- return typeof this.resolveData !== 'undefined';
8
- };
9
- this.isRejected = () => {
10
- return typeof this.rejectReason !== 'undefined';
11
- };
12
- this.reset = () => {
13
- this.status = 'pending';
14
- this.resolveData = undefined;
15
- this.rejectReason = undefined;
16
- this.promise = this.initPromise();
17
- };
18
- this.initPromise = () => {
19
- return new Promise((resolve, reject) => {
20
- this.resolve = (value) => {
21
- if (this.status === 'pending') {
22
- this.resolveData = value;
23
- this.status = 'resolved';
24
- resolve(value);
25
- }
26
- };
27
- this.reject = (reason) => {
28
- if (this.status === 'pending') {
29
- this.rejectReason = reason;
30
- this.status = 'rejected';
31
- reject(reason);
32
- }
33
- };
34
- });
35
- };
16
+ this.resolveData = undefined;
17
+ this.rejectReason = undefined;
18
+ this.promise = this.initPromise();
19
+ };
20
+ initPromise = () => {
21
+ return new Promise((resolve, reject) => {
22
+ this.resolve = (value) => {
23
+ if (this.status === 'pending') {
24
+ this.resolveData = value;
25
+ this.status = 'resolved';
26
+ resolve(value);
27
+ }
28
+ };
29
+ this.reject = (reason) => {
30
+ if (this.status === 'pending') {
31
+ this.rejectReason = reason;
32
+ this.status = 'rejected';
33
+ reject(reason);
34
+ }
35
+ };
36
+ });
37
+ };
38
+ constructor() {
36
39
  this.promise = this.initPromise();
37
40
  }
38
41
  }
@@ -3,40 +3,43 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  class Deferred {
6
- constructor() {
6
+ promise;
7
+ status = 'pending';
8
+ resolve = () => { };
9
+ reject = () => { };
10
+ resolveData;
11
+ rejectReason;
12
+ isResolved = () => {
13
+ return typeof this.resolveData !== 'undefined';
14
+ };
15
+ isRejected = () => {
16
+ return typeof this.rejectReason !== 'undefined';
17
+ };
18
+ reset = () => {
7
19
  this.status = 'pending';
8
- this.resolve = () => { };
9
- this.reject = () => { };
10
- this.isResolved = () => {
11
- return typeof this.resolveData !== 'undefined';
12
- };
13
- this.isRejected = () => {
14
- return typeof this.rejectReason !== 'undefined';
15
- };
16
- this.reset = () => {
17
- this.status = 'pending';
18
- this.resolveData = undefined;
19
- this.rejectReason = undefined;
20
- this.promise = this.initPromise();
21
- };
22
- this.initPromise = () => {
23
- return new Promise((resolve, reject) => {
24
- this.resolve = (value) => {
25
- if (this.status === 'pending') {
26
- this.resolveData = value;
27
- this.status = 'resolved';
28
- resolve(value);
29
- }
30
- };
31
- this.reject = (reason) => {
32
- if (this.status === 'pending') {
33
- this.rejectReason = reason;
34
- this.status = 'rejected';
35
- reject(reason);
36
- }
37
- };
38
- });
39
- };
20
+ this.resolveData = undefined;
21
+ this.rejectReason = undefined;
22
+ this.promise = this.initPromise();
23
+ };
24
+ initPromise = () => {
25
+ return new Promise((resolve, reject) => {
26
+ this.resolve = (value) => {
27
+ if (this.status === 'pending') {
28
+ this.resolveData = value;
29
+ this.status = 'resolved';
30
+ resolve(value);
31
+ }
32
+ };
33
+ this.reject = (reason) => {
34
+ if (this.status === 'pending') {
35
+ this.rejectReason = reason;
36
+ this.status = 'rejected';
37
+ reject(reason);
38
+ }
39
+ };
40
+ });
41
+ };
42
+ constructor() {
40
43
  this.promise = this.initPromise();
41
44
  }
42
45
  }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Represents a node in the doubly linked list
3
+ * @interface
4
+ * @template Value
5
+ */
6
+ interface ListNode<Value> {
7
+ /** Reference to next node */
8
+ next: ListNode<Value> | null;
9
+ /** Reference to previous node */
10
+ prev: ListNode<Value> | null;
11
+ /** The node's value */
12
+ value: Value;
13
+ }
14
+ /**
15
+ * Represents a doubly linked list data structure.
16
+ * @template Value The type of elements held in the list
17
+ */
18
+ export declare class DoubleLinkedList<Value> {
19
+ /**
20
+ * The number of elements in the list
21
+ * @type {number}
22
+ */
23
+ length: number;
24
+ /**
25
+ * Reference to the first node in the list
26
+ * @type {ListNode<Value> | null}
27
+ */
28
+ start: null | ListNode<Value>;
29
+ /**
30
+ * Reference to the last node in the list
31
+ * @type {ListNode<Value> | null}
32
+ */
33
+ end: null | ListNode<Value>;
34
+ /**
35
+ * Creates a new DoubleLinkedList instance
36
+ * @constructor
37
+ * @param {Value[]} [initArray] Optional array of initial values
38
+ * @example
39
+ * const list = new DoubleLinkedList([1, 2, 3]);
40
+ */
41
+ constructor(initArray?: Value[]);
42
+ /**
43
+ * Adds a value to the end of the list
44
+ * @param {Value} value The value to add
45
+ * @example
46
+ * list.push(42);
47
+ */
48
+ push(value: Value): void;
49
+ /**
50
+ * Removes and returns the last value from the list
51
+ * @returns {Value | null} The removed value or null if list is empty
52
+ * @example
53
+ * const last = list.pop();
54
+ */
55
+ pop(): Value | null;
56
+ /**
57
+ * Removes and returns the first value from the list
58
+ * @returns {Value | null} The removed value or null if list is empty
59
+ * @example
60
+ * const first = list.shift();
61
+ */
62
+ shift(): Value | null;
63
+ /**
64
+ * Returns the current number of elements in the list
65
+ * @returns {number} The list size
66
+ * @example
67
+ * const size = list.size();
68
+ */
69
+ size(): number;
70
+ /**
71
+ * Converts the list to an array of values
72
+ * @returns {Value[]} Array containing list values
73
+ * @example
74
+ * const arr = list.toArray();
75
+ */
76
+ toArray(): Value[];
77
+ /**
78
+ * Returns a JSON string representation of the list
79
+ * @returns {string} JSON string of values
80
+ * @example
81
+ * const str = list.toString(); // "[1,2,3]"
82
+ */
83
+ toString(): string;
84
+ /**
85
+ * Iterates through the list values
86
+ * @yields {Value} The next value in the list
87
+ * @example
88
+ * for (const value of list) {
89
+ * console.log(value);
90
+ * }
91
+ */
92
+ [Symbol.iterator](): Generator<Value, void, unknown>;
93
+ }
94
+ export {};
95
+ //# sourceMappingURL=doubleLinkedList.d.ts.map
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Represents a doubly linked list data structure.
3
+ * @template Value The type of elements held in the list
4
+ */
5
+ class DoubleLinkedList {
6
+ /**
7
+ * The number of elements in the list
8
+ * @type {number}
9
+ */
10
+ length;
11
+ /**
12
+ * Reference to the first node in the list
13
+ * @type {ListNode<Value> | null}
14
+ */
15
+ start;
16
+ /**
17
+ * Reference to the last node in the list
18
+ * @type {ListNode<Value> | null}
19
+ */
20
+ end;
21
+ /**
22
+ * Creates a new DoubleLinkedList instance
23
+ * @constructor
24
+ * @param {Value[]} [initArray] Optional array of initial values
25
+ * @example
26
+ * const list = new DoubleLinkedList([1, 2, 3]);
27
+ */
28
+ constructor(initArray) {
29
+ this.length = 0;
30
+ this.start = null;
31
+ this.end = null;
32
+ if (initArray) {
33
+ for (const item of initArray) {
34
+ this.push(item);
35
+ }
36
+ }
37
+ }
38
+ /**
39
+ * Adds a value to the end of the list
40
+ * @param {Value} value The value to add
41
+ * @example
42
+ * list.push(42);
43
+ */
44
+ push(value) {
45
+ const newNode = {
46
+ value,
47
+ next: null,
48
+ prev: null,
49
+ };
50
+ this.length++;
51
+ if (this.start === null) {
52
+ this.start = newNode;
53
+ this.end = newNode;
54
+ return;
55
+ }
56
+ const currentEnd = this.end;
57
+ this.end = newNode;
58
+ this.end.prev = currentEnd;
59
+ if (currentEnd !== null) {
60
+ currentEnd.next = this.end;
61
+ }
62
+ }
63
+ /**
64
+ * Removes and returns the last value from the list
65
+ * @returns {Value | null} The removed value or null if list is empty
66
+ * @example
67
+ * const last = list.pop();
68
+ */
69
+ pop() {
70
+ if (this.end === null) {
71
+ return null;
72
+ }
73
+ this.length--;
74
+ // if equal we have only 1 node, so we just remove start
75
+ if (this.end === this.start) {
76
+ this.start = null;
77
+ }
78
+ const { value } = this.end;
79
+ this.end = this.end.prev;
80
+ if (this.end) {
81
+ this.end.next = null;
82
+ }
83
+ return value;
84
+ }
85
+ /**
86
+ * Removes and returns the first value from the list
87
+ * @returns {Value | null} The removed value or null if list is empty
88
+ * @example
89
+ * const first = list.shift();
90
+ */
91
+ shift() {
92
+ if (this.start === null) {
93
+ return null;
94
+ }
95
+ this.length--;
96
+ // if equal we have only 1 node, so we just remove end
97
+ if (this.end === this.start) {
98
+ this.end = null;
99
+ }
100
+ const { value } = this.start;
101
+ this.start = this.start.next;
102
+ if (this.start) {
103
+ this.start.prev = null;
104
+ }
105
+ return value;
106
+ }
107
+ /**
108
+ * Returns the current number of elements in the list
109
+ * @returns {number} The list size
110
+ * @example
111
+ * const size = list.size();
112
+ */
113
+ size() {
114
+ return this.length;
115
+ }
116
+ /**
117
+ * Converts the list to an array of values
118
+ * @returns {Value[]} Array containing list values
119
+ * @example
120
+ * const arr = list.toArray();
121
+ */
122
+ toArray() {
123
+ const result = [];
124
+ let current = this.start;
125
+ while (current) {
126
+ result.push(current.value);
127
+ current = current.next;
128
+ }
129
+ return result;
130
+ }
131
+ /**
132
+ * Returns a JSON string representation of the list
133
+ * @returns {string} JSON string of values
134
+ * @example
135
+ * const str = list.toString(); // "[1,2,3]"
136
+ */
137
+ toString() {
138
+ const result = [this.start?.value];
139
+ let currentNode = this.start;
140
+ while (currentNode?.next) {
141
+ result.push(currentNode.next.value);
142
+ currentNode = currentNode.next;
143
+ }
144
+ return JSON.stringify(result);
145
+ }
146
+ /**
147
+ * Iterates through the list values
148
+ * @yields {Value} The next value in the list
149
+ * @example
150
+ * for (const value of list) {
151
+ * console.log(value);
152
+ * }
153
+ */
154
+ *[Symbol.iterator]() {
155
+ let current = this.start;
156
+ while (current) {
157
+ yield current.value;
158
+ current = current.next;
159
+ }
160
+ }
161
+ }
162
+
163
+ export { DoubleLinkedList };
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Represents a doubly linked list data structure.
7
+ * @template Value The type of elements held in the list
8
+ */
9
+ class DoubleLinkedList {
10
+ /**
11
+ * The number of elements in the list
12
+ * @type {number}
13
+ */
14
+ length;
15
+ /**
16
+ * Reference to the first node in the list
17
+ * @type {ListNode<Value> | null}
18
+ */
19
+ start;
20
+ /**
21
+ * Reference to the last node in the list
22
+ * @type {ListNode<Value> | null}
23
+ */
24
+ end;
25
+ /**
26
+ * Creates a new DoubleLinkedList instance
27
+ * @constructor
28
+ * @param {Value[]} [initArray] Optional array of initial values
29
+ * @example
30
+ * const list = new DoubleLinkedList([1, 2, 3]);
31
+ */
32
+ constructor(initArray) {
33
+ this.length = 0;
34
+ this.start = null;
35
+ this.end = null;
36
+ if (initArray) {
37
+ for (const item of initArray) {
38
+ this.push(item);
39
+ }
40
+ }
41
+ }
42
+ /**
43
+ * Adds a value to the end of the list
44
+ * @param {Value} value The value to add
45
+ * @example
46
+ * list.push(42);
47
+ */
48
+ push(value) {
49
+ const newNode = {
50
+ value,
51
+ next: null,
52
+ prev: null,
53
+ };
54
+ this.length++;
55
+ if (this.start === null) {
56
+ this.start = newNode;
57
+ this.end = newNode;
58
+ return;
59
+ }
60
+ const currentEnd = this.end;
61
+ this.end = newNode;
62
+ this.end.prev = currentEnd;
63
+ if (currentEnd !== null) {
64
+ currentEnd.next = this.end;
65
+ }
66
+ }
67
+ /**
68
+ * Removes and returns the last value from the list
69
+ * @returns {Value | null} The removed value or null if list is empty
70
+ * @example
71
+ * const last = list.pop();
72
+ */
73
+ pop() {
74
+ if (this.end === null) {
75
+ return null;
76
+ }
77
+ this.length--;
78
+ // if equal we have only 1 node, so we just remove start
79
+ if (this.end === this.start) {
80
+ this.start = null;
81
+ }
82
+ const { value } = this.end;
83
+ this.end = this.end.prev;
84
+ if (this.end) {
85
+ this.end.next = null;
86
+ }
87
+ return value;
88
+ }
89
+ /**
90
+ * Removes and returns the first value from the list
91
+ * @returns {Value | null} The removed value or null if list is empty
92
+ * @example
93
+ * const first = list.shift();
94
+ */
95
+ shift() {
96
+ if (this.start === null) {
97
+ return null;
98
+ }
99
+ this.length--;
100
+ // if equal we have only 1 node, so we just remove end
101
+ if (this.end === this.start) {
102
+ this.end = null;
103
+ }
104
+ const { value } = this.start;
105
+ this.start = this.start.next;
106
+ if (this.start) {
107
+ this.start.prev = null;
108
+ }
109
+ return value;
110
+ }
111
+ /**
112
+ * Returns the current number of elements in the list
113
+ * @returns {number} The list size
114
+ * @example
115
+ * const size = list.size();
116
+ */
117
+ size() {
118
+ return this.length;
119
+ }
120
+ /**
121
+ * Converts the list to an array of values
122
+ * @returns {Value[]} Array containing list values
123
+ * @example
124
+ * const arr = list.toArray();
125
+ */
126
+ toArray() {
127
+ const result = [];
128
+ let current = this.start;
129
+ while (current) {
130
+ result.push(current.value);
131
+ current = current.next;
132
+ }
133
+ return result;
134
+ }
135
+ /**
136
+ * Returns a JSON string representation of the list
137
+ * @returns {string} JSON string of values
138
+ * @example
139
+ * const str = list.toString(); // "[1,2,3]"
140
+ */
141
+ toString() {
142
+ const result = [this.start?.value];
143
+ let currentNode = this.start;
144
+ while (currentNode?.next) {
145
+ result.push(currentNode.next.value);
146
+ currentNode = currentNode.next;
147
+ }
148
+ return JSON.stringify(result);
149
+ }
150
+ /**
151
+ * Iterates through the list values
152
+ * @yields {Value} The next value in the list
153
+ * @example
154
+ * for (const value of list) {
155
+ * console.log(value);
156
+ * }
157
+ */
158
+ *[Symbol.iterator]() {
159
+ let current = this.start;
160
+ while (current) {
161
+ yield current.value;
162
+ current = current.next;
163
+ }
164
+ }
165
+ }
166
+
167
+ exports.DoubleLinkedList = DoubleLinkedList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/core",
3
- "version": "5.49.1",
3
+ "version": "5.53.74",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -18,11 +18,11 @@
18
18
  "watch": "tsc -w"
19
19
  },
20
20
  "dependencies": {
21
+ "@tinkoff/dippy": "0.11.5",
21
22
  "@tinkoff/utils": "^2.1.2",
22
- "@tramvai/tokens-common": "5.49.1",
23
- "@tramvai/tokens-core": "5.49.1",
24
- "@tramvai/types-actions-state-context": "5.49.1",
25
- "@tinkoff/dippy": "0.11.4",
23
+ "@tramvai/tokens-common": "5.53.74",
24
+ "@tramvai/tokens-core": "5.53.74",
25
+ "@tramvai/types-actions-state-context": "5.53.74",
26
26
  "tslib": "^2.4.0"
27
27
  },
28
28
  "peerDependencies": {