@tramvai/module-common 3.17.0 → 3.19.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.
@@ -7,7 +7,7 @@ import { ConditionFailError } from '@tinkoff/errors';
7
7
  import { ActionChecker } from './actionChecker.browser.js';
8
8
  import { actionType } from './constants.browser.js';
9
9
  import { actionTramvaiReducer } from './actionTramvaiReducer.browser.js';
10
- import { Deferred } from './deferred/deferred.browser.js';
10
+ import { Deferred } from './deferred/deferred.inline.browser.js';
11
11
 
12
12
  const EMPTY_DEPS = {};
13
13
  const getParameters = (action) => action[ACTION_PARAMETERS];
@@ -7,7 +7,7 @@ import { ConditionFailError } from '@tinkoff/errors';
7
7
  import { ActionChecker } from './actionChecker.es.js';
8
8
  import { actionType } from './constants.es.js';
9
9
  import { actionTramvaiReducer } from './actionTramvaiReducer.es.js';
10
- import { Deferred } from './deferred/deferred.es.js';
10
+ import { Deferred } from './deferred/deferred.inline.es.js';
11
11
 
12
12
  const EMPTY_DEPS = {};
13
13
  const getParameters = (action) => action[ACTION_PARAMETERS];
@@ -11,7 +11,7 @@ var errors = require('@tinkoff/errors');
11
11
  var actionChecker = require('./actionChecker.js');
12
12
  var constants = require('./constants.js');
13
13
  var actionTramvaiReducer = require('./actionTramvaiReducer.js');
14
- var deferred = require('./deferred/deferred.js');
14
+ var deferred_inline = require('./deferred/deferred.inline.js');
15
15
 
16
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
17
 
@@ -63,10 +63,10 @@ class ActionExecution {
63
63
  const isDeferredAction = parameters.deferred;
64
64
  // will be created when spa run actions mode is "before"
65
65
  if (isDeferredAction && !this.deferredActionsMap.get(action.name)) {
66
- const deferred$1 = new deferred.Deferred();
66
+ const deferred = new deferred_inline.Deferred();
67
67
  // avoid unhandled promise rejection
68
- deferred$1.promise.catch(() => { });
69
- this.deferredActionsMap.set(action.name, deferred$1);
68
+ deferred.promise.catch(() => { });
69
+ this.deferredActionsMap.set(action.name, deferred);
70
70
  }
71
71
  executionState.status = 'pending';
72
72
  return this.executionContextManager.withContext(executionContext, {
@@ -1,7 +1,7 @@
1
1
  import { useDi } from '@tramvai/react';
2
2
  import { DEFERRED_ACTIONS_MAP_TOKEN } from '@tramvai/tokens-common';
3
3
  import { deserializeError } from '@tramvai/safe-strings';
4
- import { Deferred } from './deferred.browser.js';
4
+ import { Deferred } from './deferred.inline.browser.js';
5
5
 
6
6
  function Await({ action, children, error, }) {
7
7
  const deferredMap = useDi(DEFERRED_ACTIONS_MAP_TOKEN);
@@ -1,7 +1,7 @@
1
1
  import { useDi } from '@tramvai/react';
2
2
  import { DEFERRED_ACTIONS_MAP_TOKEN } from '@tramvai/tokens-common';
3
3
  import { deserializeError } from '@tramvai/safe-strings';
4
- import { Deferred } from './deferred.es.js';
4
+ import { Deferred } from './deferred.inline.es.js';
5
5
 
6
6
  function Await({ action, children, error, }) {
7
7
  const deferredMap = useDi(DEFERRED_ACTIONS_MAP_TOKEN);
@@ -5,36 +5,36 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var react = require('@tramvai/react');
6
6
  var tokensCommon = require('@tramvai/tokens-common');
7
7
  var safeStrings = require('@tramvai/safe-strings');
8
- var deferred = require('./deferred.js');
8
+ var deferred_inline = require('./deferred.inline.js');
9
9
 
10
10
  function Await({ action, children, error, }) {
11
11
  const deferredMap = react.useDi(tokensCommon.DEFERRED_ACTIONS_MAP_TOKEN);
12
12
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13
- let deferred$1 = deferredMap.get(action.name);
13
+ let deferred = deferredMap.get(action.name);
14
14
  if (!action.deferred) {
15
15
  throw new Error(`Action ${action.name} is not deferred`);
16
16
  }
17
17
  // will be created when spa run actions mode is "after"
18
- if (!deferred$1) {
19
- deferred$1 = new deferred.Deferred();
18
+ if (!deferred) {
19
+ deferred = new deferred_inline.Deferred();
20
20
  // avoid unhandled promise rejection
21
- deferred$1.promise.catch(() => { });
22
- deferredMap.set(action.name, deferred$1);
21
+ deferred.promise.catch(() => { });
22
+ deferredMap.set(action.name, deferred);
23
23
  }
24
- if (deferred$1.isResolved()) {
25
- return children(deferred$1.resolveData);
24
+ if (deferred.isResolved()) {
25
+ return children(deferred.resolveData);
26
26
  }
27
- if (deferred$1.isRejected()) {
28
- const reason = deferred$1.rejectReason instanceof Error
29
- ? deferred$1.rejectReason
27
+ if (deferred.isRejected()) {
28
+ const reason = deferred.rejectReason instanceof Error
29
+ ? deferred.rejectReason
30
30
  : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
- safeStrings.deserializeError(deferred$1.rejectReason);
31
+ safeStrings.deserializeError(deferred.rejectReason);
32
32
  if (!error) {
33
33
  throw reason;
34
34
  }
35
35
  return error(reason);
36
36
  }
37
- throw deferred$1.promise;
37
+ throw deferred.promise;
38
38
  }
39
39
 
40
40
  exports.Await = Await;
@@ -0,0 +1,30 @@
1
+ class Deferred {
2
+ constructor() {
3
+ this.isResolved = () => {
4
+ return typeof this.resolveData !== 'undefined';
5
+ };
6
+ this.isRejected = () => {
7
+ return typeof this.rejectReason !== 'undefined';
8
+ };
9
+ this.reset = () => {
10
+ this.resolveData = undefined;
11
+ this.rejectReason = undefined;
12
+ this.promise = this.initPromise();
13
+ };
14
+ this.initPromise = () => {
15
+ return new Promise((resolve, reject) => {
16
+ this.resolve = (value) => {
17
+ this.resolveData = value;
18
+ resolve(value);
19
+ };
20
+ this.reject = (reason) => {
21
+ this.rejectReason = reason;
22
+ reject(reason);
23
+ };
24
+ });
25
+ };
26
+ this.promise = this.initPromise();
27
+ }
28
+ }
29
+
30
+ export { Deferred };
@@ -1,3 +1,14 @@
1
- import type { Deferred } from '@tramvai/tokens-common';
2
- export declare function __Deferred(this: Deferred & Record<string, any>): void;
1
+ import type { Deferred as IDeferred } from '@tramvai/tokens-common';
2
+ export declare class Deferred implements IDeferred {
3
+ promise: Promise<any>;
4
+ resolve: (value: any) => void;
5
+ reject: (reason: any) => void;
6
+ resolveData: any;
7
+ rejectReason: any;
8
+ isResolved: () => boolean;
9
+ isRejected: () => boolean;
10
+ reset: () => void;
11
+ private initPromise;
12
+ constructor();
13
+ }
3
14
  //# sourceMappingURL=deferred.inline.d.ts.map
@@ -1,28 +1,30 @@
1
- function __Deferred() {
2
- this.initPromise = () => {
3
- return new Promise((resolve, reject) => {
4
- this.resolve = (value) => {
5
- this.resolveData = value;
6
- resolve(value);
7
- };
8
- this.reject = (reason) => {
9
- this.rejectReason = reason;
10
- reject(reason);
11
- };
12
- });
13
- };
14
- this.promise = this.initPromise();
15
- this.isResolved = () => {
16
- return typeof this.resolveData !== 'undefined';
17
- };
18
- this.isRejected = () => {
19
- return typeof this.rejectReason !== 'undefined';
20
- };
21
- this.reset = () => {
22
- this.resolveData = undefined;
23
- this.rejectReason = undefined;
1
+ class Deferred {
2
+ constructor() {
3
+ this.isResolved = () => {
4
+ return typeof this.resolveData !== 'undefined';
5
+ };
6
+ this.isRejected = () => {
7
+ return typeof this.rejectReason !== 'undefined';
8
+ };
9
+ this.reset = () => {
10
+ this.resolveData = undefined;
11
+ this.rejectReason = undefined;
12
+ this.promise = this.initPromise();
13
+ };
14
+ this.initPromise = () => {
15
+ return new Promise((resolve, reject) => {
16
+ this.resolve = (value) => {
17
+ this.resolveData = value;
18
+ resolve(value);
19
+ };
20
+ this.reject = (reason) => {
21
+ this.rejectReason = reason;
22
+ reject(reason);
23
+ };
24
+ });
25
+ };
24
26
  this.promise = this.initPromise();
25
- };
27
+ }
26
28
  }
27
29
 
28
- export { __Deferred };
30
+ export { Deferred };
@@ -2,31 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function __Deferred() {
6
- this.initPromise = () => {
7
- return new Promise((resolve, reject) => {
8
- this.resolve = (value) => {
9
- this.resolveData = value;
10
- resolve(value);
11
- };
12
- this.reject = (reason) => {
13
- this.rejectReason = reason;
14
- reject(reason);
15
- };
16
- });
17
- };
18
- this.promise = this.initPromise();
19
- this.isResolved = () => {
20
- return typeof this.resolveData !== 'undefined';
21
- };
22
- this.isRejected = () => {
23
- return typeof this.rejectReason !== 'undefined';
24
- };
25
- this.reset = () => {
26
- this.resolveData = undefined;
27
- this.rejectReason = undefined;
5
+ class Deferred {
6
+ constructor() {
7
+ this.isResolved = () => {
8
+ return typeof this.resolveData !== 'undefined';
9
+ };
10
+ this.isRejected = () => {
11
+ return typeof this.rejectReason !== 'undefined';
12
+ };
13
+ this.reset = () => {
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
+ this.resolveData = value;
22
+ resolve(value);
23
+ };
24
+ this.reject = (reason) => {
25
+ this.rejectReason = reason;
26
+ reject(reason);
27
+ };
28
+ });
29
+ };
28
30
  this.promise = this.initPromise();
29
- };
31
+ }
30
32
  }
31
33
 
32
- exports.__Deferred = __Deferred;
34
+ exports.Deferred = Deferred;
@@ -1,7 +1,7 @@
1
1
  import { provide, commandLineListTokens, optional } from '@tramvai/core';
2
2
  import { ResourceSlot, ResourceType, RESOURCES_REGISTRY, REACT_SERVER_RENDER_MODE } from '@tramvai/tokens-render';
3
3
  import { DEFERRED_ACTIONS_MAP_TOKEN } from '@tramvai/tokens-common';
4
- import { __Deferred } from './deferred.inline.es.js';
4
+ import { Deferred } from './deferred.inline.es.js';
5
5
  import { generateDeferredResolve, generateDeferredReject } from './clientScriptsUtils.es.js';
6
6
 
7
7
  const providers = [
@@ -18,7 +18,7 @@ const providers = [
18
18
  resourcesRegistry.register({
19
19
  slot: ResourceSlot.HEAD_CORE_SCRIPTS,
20
20
  type: ResourceType.inlineScript,
21
- payload: `window.__Deferred = ${__Deferred}
21
+ payload: `window.__Deferred = ${Deferred}
22
22
  window.__TRAMVAI_DEFERRED_ACTIONS = {};`,
23
23
  });
24
24
  deferredMap.forEach((deferred, key) => {
@@ -22,7 +22,7 @@ const providers = [
22
22
  resourcesRegistry.register({
23
23
  slot: tokensRender.ResourceSlot.HEAD_CORE_SCRIPTS,
24
24
  type: tokensRender.ResourceType.inlineScript,
25
- payload: `window.__Deferred = ${deferred_inline.__Deferred}
25
+ payload: `window.__Deferred = ${deferred_inline.Deferred}
26
26
  window.__TRAMVAI_DEFERRED_ACTIONS = {};`,
27
27
  });
28
28
  deferredMap.forEach((deferred, key) => {
@@ -1,7 +1,7 @@
1
1
  export { CommonModule } from './CommonModule.browser.js';
2
2
  export { CommandModule } from './command/CommandModule.browser.js';
3
3
  export { ActionExecution } from './actions/actionExecution.browser.js';
4
- export { Deferred } from './actions/deferred/deferred.browser.js';
4
+ export { Deferred } from './actions/deferred/deferred.inline.browser.js';
5
5
  export { Await } from './actions/deferred/await.browser.js';
6
6
  export { ExecutionContextManager } from './executionContext/executionContextManager.browser.js';
7
7
  import './actions/ActionModule.browser.js';
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CommonModule } from './CommonModule';
2
2
  export { CommandModule } from './command/CommandModule';
3
3
  export { ActionExecution } from './actions/actionExecution';
4
- export { Deferred } from './actions/deferred/deferred';
4
+ export { Deferred } from './actions/deferred/deferred.inline';
5
5
  export { Await } from './actions/deferred/await';
6
6
  export { ExecutionContextManager } from './executionContext/executionContextManager';
7
7
  export { alwaysCondition, onlyServer, onlyBrowser, pageServer, pageBrowser, } from './actions/ActionModule';
package/lib/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CommonModule } from './CommonModule.es.js';
2
2
  export { CommandModule } from './command/CommandModule.es.js';
3
3
  export { ActionExecution } from './actions/actionExecution.es.js';
4
- export { Deferred } from './actions/deferred/deferred.es.js';
4
+ export { Deferred } from './actions/deferred/deferred.inline.es.js';
5
5
  export { Await } from './actions/deferred/await.es.js';
6
6
  export { ExecutionContextManager } from './executionContext/executionContextManager.es.js';
7
7
  import './actions/ActionModule.es.js';
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var CommonModule = require('./CommonModule.js');
6
6
  var CommandModule = require('./command/CommandModule.js');
7
7
  var actionExecution = require('./actions/actionExecution.js');
8
- var deferred = require('./actions/deferred/deferred.js');
8
+ var deferred_inline = require('./actions/deferred/deferred.inline.js');
9
9
  var _await = require('./actions/deferred/await.js');
10
10
  var executionContextManager = require('./executionContext/executionContextManager.js');
11
11
  require('./actions/ActionModule.js');
@@ -31,7 +31,7 @@ Object.defineProperty(exports, 'CommandModule', {
31
31
  get: function () { return CommandModule.CommandModule; }
32
32
  });
33
33
  exports.ActionExecution = actionExecution.ActionExecution;
34
- exports.Deferred = deferred.Deferred;
34
+ exports.Deferred = deferred_inline.Deferred;
35
35
  exports.Await = _await.Await;
36
36
  exports.ExecutionContextManager = executionContextManager.ExecutionContextManager;
37
37
  exports.createConsumerContext = createConsumerContext.createConsumerContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-common",
3
- "version": "3.17.0",
3
+ "version": "3.19.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -30,35 +30,35 @@
30
30
  "watch": "tsc -w"
31
31
  },
32
32
  "dependencies": {
33
- "@tinkoff/errors": "0.4.1",
33
+ "@tinkoff/errors": "0.4.2",
34
34
  "@tinkoff/hook-runner": "0.5.1",
35
35
  "@tinkoff/lru-cache-nano": "^7.9.0",
36
36
  "@akashbabu/lfu-cache": "1.0.2",
37
37
  "@tinkoff/pubsub": "0.6.1",
38
38
  "@tinkoff/url": "0.9.2",
39
39
  "@tramvai/safe-strings": "0.6.2",
40
- "@tramvai/experiments": "3.17.0",
41
- "@tramvai/module-cookie": "3.17.0",
42
- "@tramvai/module-environment": "3.17.0",
43
- "@tramvai/module-log": "3.17.0",
44
- "@tramvai/tokens-child-app": "3.17.0",
45
- "@tramvai/tokens-core-private": "3.17.0",
46
- "@tramvai/tokens-common": "3.17.0",
47
- "@tramvai/tokens-render": "3.17.0",
48
- "@tramvai/tokens-server-private": "3.17.0",
49
- "@tramvai/types-actions-state-context": "3.17.0",
40
+ "@tramvai/experiments": "3.19.1",
41
+ "@tramvai/module-cookie": "3.19.1",
42
+ "@tramvai/module-environment": "3.19.1",
43
+ "@tramvai/module-log": "3.19.1",
44
+ "@tramvai/tokens-child-app": "3.19.1",
45
+ "@tramvai/tokens-core-private": "3.19.1",
46
+ "@tramvai/tokens-common": "3.19.1",
47
+ "@tramvai/tokens-render": "3.19.1",
48
+ "@tramvai/tokens-server-private": "3.19.1",
49
+ "@tramvai/types-actions-state-context": "3.19.1",
50
50
  "hoist-non-react-statics": "^3.3.1",
51
51
  "node-abort-controller": "^3.0.1"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@tinkoff/dippy": "0.9.1",
55
55
  "@tinkoff/utils": "^2.1.2",
56
- "@tramvai/cli": "3.17.0",
57
- "@tramvai/core": "3.17.0",
58
- "@tramvai/papi": "3.17.0",
59
- "@tramvai/react": "3.17.0",
60
- "@tramvai/state": "3.17.0",
61
- "@tramvai/tokens-server": "3.17.0",
56
+ "@tramvai/cli": "3.19.1",
57
+ "@tramvai/core": "3.19.1",
58
+ "@tramvai/papi": "3.19.1",
59
+ "@tramvai/react": "3.19.1",
60
+ "@tramvai/state": "3.19.1",
61
+ "@tramvai/tokens-server": "3.19.1",
62
62
  "react": ">=16.14.0",
63
63
  "tslib": "^2.4.0"
64
64
  },
@@ -1,30 +0,0 @@
1
- class Deferred {
2
- constructor() {
3
- this.promise = this.initPromise();
4
- }
5
- isResolved() {
6
- return typeof this.resolveData !== 'undefined';
7
- }
8
- isRejected() {
9
- return typeof this.rejectReason !== 'undefined';
10
- }
11
- reset() {
12
- this.resolveData = undefined;
13
- this.rejectReason = undefined;
14
- this.promise = this.initPromise();
15
- }
16
- initPromise() {
17
- return new Promise((resolve, reject) => {
18
- this.resolve = (value) => {
19
- this.resolveData = value;
20
- resolve(value);
21
- };
22
- this.reject = (reason) => {
23
- this.rejectReason = reason;
24
- reject(reason);
25
- };
26
- });
27
- }
28
- }
29
-
30
- export { Deferred };
@@ -1,14 +0,0 @@
1
- import type { Deferred as IDeferred } from '@tramvai/tokens-common';
2
- export declare class Deferred implements IDeferred {
3
- promise: Promise<any>;
4
- resolve: (value: any) => void;
5
- reject: (reason: any) => void;
6
- resolveData: any;
7
- rejectReason: any;
8
- constructor();
9
- isResolved(): boolean;
10
- isRejected(): boolean;
11
- reset(): void;
12
- private initPromise;
13
- }
14
- //# sourceMappingURL=deferred.d.ts.map
@@ -1,30 +0,0 @@
1
- class Deferred {
2
- constructor() {
3
- this.promise = this.initPromise();
4
- }
5
- isResolved() {
6
- return typeof this.resolveData !== 'undefined';
7
- }
8
- isRejected() {
9
- return typeof this.rejectReason !== 'undefined';
10
- }
11
- reset() {
12
- this.resolveData = undefined;
13
- this.rejectReason = undefined;
14
- this.promise = this.initPromise();
15
- }
16
- initPromise() {
17
- return new Promise((resolve, reject) => {
18
- this.resolve = (value) => {
19
- this.resolveData = value;
20
- resolve(value);
21
- };
22
- this.reject = (reason) => {
23
- this.rejectReason = reason;
24
- reject(reason);
25
- };
26
- });
27
- }
28
- }
29
-
30
- export { Deferred };
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- class Deferred {
6
- constructor() {
7
- this.promise = this.initPromise();
8
- }
9
- isResolved() {
10
- return typeof this.resolveData !== 'undefined';
11
- }
12
- isRejected() {
13
- return typeof this.rejectReason !== 'undefined';
14
- }
15
- reset() {
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
- this.resolveData = value;
24
- resolve(value);
25
- };
26
- this.reject = (reason) => {
27
- this.rejectReason = reason;
28
- reject(reason);
29
- };
30
- });
31
- }
32
- }
33
-
34
- exports.Deferred = Deferred;