@mittwald/flow-react-components 0.2.0-alpha.647 → 0.2.0-alpha.648
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/CHANGELOG.md +4 -0
- package/dist/assets/doc-properties.json +13649 -13649
- package/dist/js/components/src/components/Action/models/ActionExecution.mjs +5 -6
- package/dist/js/components/src/components/Action/models/ActionExecution.mjs.map +1 -1
- package/dist/js/components/src/components/Action/models/ActionExecutionBatch.mjs +18 -12
- package/dist/js/components/src/components/Action/models/ActionExecutionBatch.mjs.map +1 -1
- package/dist/types/components/Action/models/ActionExecution.d.ts.map +1 -1
- package/dist/types/components/Action/models/ActionExecutionBatch.d.ts +1 -1
- package/dist/types/components/Action/models/ActionExecutionBatch.d.ts.map +1 -1
- package/dist/types/components/Action/stories/Default.stories.d.ts +2 -0
- package/dist/types/components/Action/stories/Default.stories.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/js/components/src/lib/promises/callAndReact.mjs +0 -32
- package/dist/js/components/src/lib/promises/callAndReact.mjs.map +0 -1
- package/dist/types/lib/promises/callAndReact.d.ts +0 -10
- package/dist/types/lib/promises/callAndReact.d.ts.map +0 -1
- package/dist/types/lib/promises/callAndReact.test.d.ts +0 -2
- package/dist/types/lib/promises/callAndReact.test.d.ts.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
import { ActionExecutionBatch } from './ActionExecutionBatch.mjs';
|
|
4
|
+
import { callFunctionsInOrder } from '../../../lib/promises/callFunctionsInOrder.mjs';
|
|
4
5
|
|
|
5
6
|
class ActionExecution {
|
|
6
7
|
action;
|
|
@@ -9,12 +10,10 @@ class ActionExecution {
|
|
|
9
10
|
}
|
|
10
11
|
execute = (...args) => {
|
|
11
12
|
const batches = this.getBatchedActions();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
void executeAllBatches().catch((error) => console.error(error));
|
|
13
|
+
const executeBatchedActions = callFunctionsInOrder(
|
|
14
|
+
batches.map((b) => b.executeBatch.bind(b))
|
|
15
|
+
);
|
|
16
|
+
executeBatchedActions(...args);
|
|
18
17
|
};
|
|
19
18
|
getBatchedActions = () => {
|
|
20
19
|
let currentAction = this.action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionExecution.mjs","sources":["../../../../../../../src/components/Action/models/ActionExecution.tsx"],"sourcesContent":["import type { ActionModel } from \"@/components/Action/models/ActionModel\";\nimport { ActionExecutionBatch } from \"@/components/Action/models/ActionExecutionBatch\";\n\nexport class ActionExecution {\n private readonly action: ActionModel;\n\n public constructor(action: ActionModel) {\n this.action = action;\n }\n\n public execute = (...args: unknown[]): void => {\n const batches = this.getBatchedActions();\n\n const
|
|
1
|
+
{"version":3,"file":"ActionExecution.mjs","sources":["../../../../../../../src/components/Action/models/ActionExecution.tsx"],"sourcesContent":["import type { ActionModel } from \"@/components/Action/models/ActionModel\";\nimport { ActionExecutionBatch } from \"@/components/Action/models/ActionExecutionBatch\";\nimport { callFunctionsInOrder } from \"@/lib/promises/callFunctionsInOrder\";\n\nexport class ActionExecution {\n private readonly action: ActionModel;\n\n public constructor(action: ActionModel) {\n this.action = action;\n }\n\n public execute = (...args: unknown[]): void => {\n const batches = this.getBatchedActions();\n\n const executeBatchedActions = callFunctionsInOrder(\n batches.map((b) => b.executeBatch.bind(b)),\n );\n\n executeBatchedActions(...args);\n };\n\n private getBatchedActions = (): ActionExecutionBatch[] => {\n let currentAction: ActionModel | undefined = this.action;\n\n const batches: ActionExecutionBatch[] = [];\n let currentBatch: ActionExecutionBatch = new ActionExecutionBatch(\n this.action,\n );\n\n let skipCount = 0;\n\n while (currentAction) {\n const { onAction, break: $break, skip } = currentAction.actionProps;\n\n if (currentAction.needsConfirmation) {\n currentBatch.addAction(currentAction);\n break;\n }\n\n if (skip) {\n skipCount = skip === true ? 1 : skip;\n currentAction = currentAction.parentAction;\n continue;\n }\n\n if (skipCount > 0) {\n currentAction = currentAction.parentAction;\n skipCount--;\n continue;\n }\n\n if ($break) {\n break;\n }\n\n if (onAction) {\n currentBatch.addAction(currentAction);\n } else {\n batches.push(currentBatch);\n currentBatch = new ActionExecutionBatch(this.action);\n currentBatch.addAction(currentAction);\n }\n\n currentAction = currentAction.parentAction;\n }\n\n batches.push(currentBatch);\n return batches;\n };\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,eAAA,CAAgB;AAAA,EACV,MAAA;AAAA,EAEV,YAAY,MAAA,EAAqB;AACtC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEO,OAAA,GAAU,IAAI,IAAA,KAA0B;AAC7C,IAAA,MAAM,OAAA,GAAU,KAAK,iBAAA,EAAkB;AAEvC,IAAA,MAAM,qBAAA,GAAwB,oBAAA;AAAA,MAC5B,OAAA,CAAQ,IAAI,CAAC,CAAA,KAAM,EAAE,YAAA,CAAa,IAAA,CAAK,CAAC,CAAC;AAAA,KAC3C;AAEA,IAAA,qBAAA,CAAsB,GAAG,IAAI,CAAA;AAAA,EAC/B,CAAA;AAAA,EAEQ,oBAAoB,MAA8B;AACxD,IAAA,IAAI,gBAAyC,IAAA,CAAK,MAAA;AAElD,IAAA,MAAM,UAAkC,EAAC;AACzC,IAAA,IAAI,eAAqC,IAAI,oBAAA;AAAA,MAC3C,IAAA,CAAK;AAAA,KACP;AAEA,IAAA,IAAI,SAAA,GAAY,CAAA;AAEhB,IAAA,OAAO,aAAA,EAAe;AACpB,MAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,MAAA,EAAQ,IAAA,KAAS,aAAA,CAAc,WAAA;AAExD,MAAA,IAAI,cAAc,iBAAA,EAAmB;AACnC,QAAA,YAAA,CAAa,UAAU,aAAa,CAAA;AACpC,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,SAAA,GAAY,IAAA,KAAS,OAAO,CAAA,GAAI,IAAA;AAChC,QAAA,aAAA,GAAgB,aAAA,CAAc,YAAA;AAC9B,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,YAAY,CAAA,EAAG;AACjB,QAAA,aAAA,GAAgB,aAAA,CAAc,YAAA;AAC9B,QAAA,SAAA,EAAA;AACA,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,QAAA,EAAU;AACZ,QAAA,YAAA,CAAa,UAAU,aAAa,CAAA;AAAA,MACtC,CAAA,MAAO;AACL,QAAA,OAAA,CAAQ,KAAK,YAAY,CAAA;AACzB,QAAA,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAA,CAAK,MAAM,CAAA;AACnD,QAAA,YAAA,CAAa,UAAU,aAAa,CAAA;AAAA,MACtC;AAEA,MAAA,aAAA,GAAgB,aAAA,CAAc,YAAA;AAAA,IAChC;AAEA,IAAA,OAAA,CAAQ,KAAK,YAAY,CAAA;AACzB,IAAA,OAAO,OAAA;AAAA,EACT,CAAA;AACF;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
import { callFunctionsInOrder } from '../../../lib/promises/callFunctionsInOrder.mjs';
|
|
4
|
-
import { callAndReact } from '../../../lib/promises/callAndReact.mjs';
|
|
5
4
|
import { getExecutionFunction } from './getExecutionFunction.mjs';
|
|
6
5
|
|
|
7
6
|
class ActionExecutionBatch {
|
|
@@ -13,7 +12,7 @@ class ActionExecutionBatch {
|
|
|
13
12
|
addAction(action) {
|
|
14
13
|
this.actions.push(action);
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
executeBatch(...args) {
|
|
17
16
|
if (this.actions.length === 0) {
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
@@ -23,17 +22,24 @@ class ActionExecutionBatch {
|
|
|
23
22
|
);
|
|
24
23
|
const executionFunctions = this.actions.map((c) => getExecutionFunction(c));
|
|
25
24
|
const executeBatch = callFunctionsInOrder(executionFunctions);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const onError = (error) => {
|
|
26
|
+
executionState.onFailed(error);
|
|
27
|
+
throw error;
|
|
28
|
+
};
|
|
29
|
+
const onSucceeded = () => {
|
|
30
|
+
executionState.onSucceeded();
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
const result = executeBatch(...args);
|
|
34
|
+
if (result instanceof Promise) {
|
|
35
|
+
executionState.onAsyncStart();
|
|
36
|
+
return result.then(onSucceeded).catch(onError);
|
|
37
|
+
} else {
|
|
38
|
+
onSucceeded();
|
|
39
|
+
return result;
|
|
33
40
|
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
throw caughtError;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
onError(error);
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionExecutionBatch.mjs","sources":["../../../../../../../src/components/Action/models/ActionExecutionBatch.ts"],"sourcesContent":["import type { ActionModel } from \"@/components/Action/models/ActionModel\";\nimport { callFunctionsInOrder } from \"@/lib/promises/callFunctionsInOrder\";\nimport {
|
|
1
|
+
{"version":3,"file":"ActionExecutionBatch.mjs","sources":["../../../../../../../src/components/Action/models/ActionExecutionBatch.ts"],"sourcesContent":["import type { ActionModel } from \"@/components/Action/models/ActionModel\";\nimport { callFunctionsInOrder } from \"@/lib/promises/callFunctionsInOrder\";\nimport { getExecutionFunction } from \"@/components/Action/models/getExecutionFunction\";\n\nexport class ActionExecutionBatch {\n private readonly actions: ActionModel[] = [];\n public readonly baseAction: ActionModel;\n\n constructor(baseAction: ActionModel) {\n this.baseAction = baseAction;\n }\n\n public addAction(action: ActionModel): void {\n this.actions.push(action);\n }\n\n public executeBatch(...args: unknown[]) {\n if (this.actions.length === 0) {\n return;\n }\n\n const batchFeedback =\n this.actions[this.actions.length - 1]?.actionProps.showFeedback;\n\n const executionState = this.baseAction.state.withFeedback(\n this.baseAction.needsConfirmation ? false : batchFeedback,\n );\n\n const executionFunctions = this.actions.map((c) => getExecutionFunction(c));\n\n const executeBatch = callFunctionsInOrder(executionFunctions);\n\n const onError = (error: unknown): void => {\n executionState.onFailed(error);\n throw error;\n };\n\n const onSucceeded = (): void => {\n executionState.onSucceeded();\n };\n\n try {\n const result = executeBatch(...args);\n if (result instanceof Promise) {\n executionState.onAsyncStart();\n return result.then(onSucceeded).catch(onError);\n } else {\n onSucceeded();\n return result;\n }\n } catch (error) {\n onError(error);\n }\n }\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,oBAAA,CAAqB;AAAA,EACf,UAAyB,EAAC;AAAA,EAC3B,UAAA;AAAA,EAEhB,YAAY,UAAA,EAAyB;AACnC,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACpB;AAAA,EAEO,UAAU,MAAA,EAA2B;AAC1C,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,EAC1B;AAAA,EAEO,gBAAgB,IAAA,EAAiB;AACtC,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG;AAC7B,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,aAAA,GACJ,KAAK,OAAA,CAAQ,IAAA,CAAK,QAAQ,MAAA,GAAS,CAAC,GAAG,WAAA,CAAY,YAAA;AAErD,IAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,YAAA;AAAA,MAC3C,IAAA,CAAK,UAAA,CAAW,iBAAA,GAAoB,KAAA,GAAQ;AAAA,KAC9C;AAEA,IAAA,MAAM,kBAAA,GAAqB,KAAK,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAAM,oBAAA,CAAqB,CAAC,CAAC,CAAA;AAE1E,IAAA,MAAM,YAAA,GAAe,qBAAqB,kBAAkB,CAAA;AAE5D,IAAA,MAAM,OAAA,GAAU,CAAC,KAAA,KAAyB;AACxC,MAAA,cAAA,CAAe,SAAS,KAAK,CAAA;AAC7B,MAAA,MAAM,KAAA;AAAA,IACR,CAAA;AAEA,IAAA,MAAM,cAAc,MAAY;AAC9B,MAAA,cAAA,CAAe,WAAA,EAAY;AAAA,IAC7B,CAAA;AAEA,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,YAAA,CAAa,GAAG,IAAI,CAAA;AACnC,MAAA,IAAI,kBAAkB,OAAA,EAAS;AAC7B,QAAA,cAAA,CAAe,YAAA,EAAa;AAC5B,QAAA,OAAO,MAAA,CAAO,IAAA,CAAK,WAAW,CAAA,CAAE,MAAM,OAAO,CAAA;AAAA,MAC/C,CAAA,MAAO;AACL,QAAA,WAAA,EAAY;AACZ,QAAA,OAAO,MAAA;AAAA,MACT;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACf;AAAA,EACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionExecution.d.ts","sourceRoot":"","sources":["../../../../../src/components/Action/models/ActionExecution.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionExecution.d.ts","sourceRoot":"","sources":["../../../../../src/components/Action/models/ActionExecution.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAI1E,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAElB,MAAM,EAAE,WAAW;IAI/B,OAAO,GAAI,GAAG,MAAM,OAAO,EAAE,KAAG,IAAI,CAQzC;IAEF,OAAO,CAAC,iBAAiB,CA+CvB;CACH"}
|
|
@@ -4,6 +4,6 @@ export declare class ActionExecutionBatch {
|
|
|
4
4
|
readonly baseAction: ActionModel;
|
|
5
5
|
constructor(baseAction: ActionModel);
|
|
6
6
|
addAction(action: ActionModel): void;
|
|
7
|
-
executeBatch(args: unknown[]):
|
|
7
|
+
executeBatch(...args: unknown[]): unknown;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=ActionExecutionBatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionExecutionBatch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Action/models/ActionExecutionBatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionExecutionBatch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Action/models/ActionExecutionBatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAI1E,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,SAAgB,UAAU,EAAE,WAAW,CAAC;gBAE5B,UAAU,EAAE,WAAW;IAI5B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAIpC,YAAY,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE;CAsCvC"}
|
|
@@ -10,5 +10,7 @@ export declare const AsyncWithFeedback: Story;
|
|
|
10
10
|
export declare const AsyncLongWithFeedback: Story;
|
|
11
11
|
export declare const Nested: Story;
|
|
12
12
|
export declare const NestedAsync: Story;
|
|
13
|
+
export declare const SyncError: Story;
|
|
14
|
+
export declare const AsyncError: Story;
|
|
13
15
|
export declare const WithConfirmationModal: Story;
|
|
14
16
|
//# sourceMappingURL=Default.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Default.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Action/stories/Default.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Default.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Action/stories/Default.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAcvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAsB7B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC;AAErC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,KAAK,EAAE,KAInB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAIvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAK/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAKnC,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAIpB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAKzB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAIvB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAIxB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAkBnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.648",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@internationalized/string-compiler": "^3.2.6",
|
|
60
60
|
"@mittwald/password-tools-js": "3.0.0-alpha.18",
|
|
61
|
-
"@mittwald/react-tunnel": "0.2.0-alpha.
|
|
61
|
+
"@mittwald/react-tunnel": "0.2.0-alpha.648",
|
|
62
62
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
63
63
|
"@react-aria/form": "^3.1.3",
|
|
64
64
|
"@react-aria/live-announcer": "^3.4.4",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@faker-js/faker": "^10.2.0",
|
|
104
104
|
"@internationalized/date": "^3.10.1",
|
|
105
105
|
"@mittwald/flow-core": "",
|
|
106
|
-
"@mittwald/flow-design-tokens": "0.2.0-alpha.
|
|
106
|
+
"@mittwald/flow-design-tokens": "0.2.0-alpha.648",
|
|
107
107
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
108
108
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
109
109
|
"@mittwald/typescript-config": "",
|
|
@@ -172,5 +172,5 @@
|
|
|
172
172
|
"optional": true
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
|
-
"gitHead": "
|
|
175
|
+
"gitHead": "09b86cf1bd8fa9401c7074f76d01fa7acfa90736"
|
|
176
176
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
/* */
|
|
3
|
-
const emptyFunction = () => {
|
|
4
|
-
};
|
|
5
|
-
const callAndReact = (fn, options = {}) => {
|
|
6
|
-
const {
|
|
7
|
-
onSync = emptyFunction,
|
|
8
|
-
onAsync = emptyFunction,
|
|
9
|
-
then = emptyFunction,
|
|
10
|
-
catch: $catch = emptyFunction,
|
|
11
|
-
finally: $finally = emptyFunction
|
|
12
|
-
} = options;
|
|
13
|
-
try {
|
|
14
|
-
const result = fn();
|
|
15
|
-
if (result instanceof Promise) {
|
|
16
|
-
onAsync();
|
|
17
|
-
return result.then(then).catch($catch).finally($finally);
|
|
18
|
-
} else {
|
|
19
|
-
onSync();
|
|
20
|
-
then(result);
|
|
21
|
-
$finally();
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
} catch (error) {
|
|
25
|
-
onSync();
|
|
26
|
-
$catch(error);
|
|
27
|
-
$finally();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { callAndReact };
|
|
32
|
-
//# sourceMappingURL=callAndReact.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callAndReact.mjs","sources":["../../../../../../src/lib/promises/callAndReact.ts"],"sourcesContent":["interface Options {\n onSync?: () => void;\n onAsync?: () => void;\n then?: (result: unknown) => void;\n catch?: (error: unknown) => void;\n finally?: () => void;\n}\n\nconst emptyFunction = (): void => {\n // do nothing\n};\n\nexport const callAndReact = (\n fn: (...args: unknown[]) => unknown,\n options: Options = {},\n) => {\n const {\n onSync = emptyFunction,\n onAsync = emptyFunction,\n then = emptyFunction,\n catch: $catch = emptyFunction,\n finally: $finally = emptyFunction,\n } = options;\n try {\n const result = fn();\n\n if (result instanceof Promise) {\n onAsync();\n return result.then(then).catch($catch).finally($finally);\n } else {\n onSync();\n then(result);\n $finally();\n return result;\n }\n } catch (error) {\n onSync();\n $catch(error);\n $finally();\n }\n};\n"],"names":[],"mappings":"AAQA,MAAM,gBAAgB,MAAY;AAElC,CAAA;AAEO,MAAM,YAAA,GAAe,CAC1B,EAAA,EACA,OAAA,GAAmB,EAAC,KACjB;AACH,EAAA,MAAM;AAAA,IACJ,MAAA,GAAS,aAAA;AAAA,IACT,OAAA,GAAU,aAAA;AAAA,IACV,IAAA,GAAO,aAAA;AAAA,IACP,OAAO,MAAA,GAAS,aAAA;AAAA,IAChB,SAAS,QAAA,GAAW;AAAA,GACtB,GAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAM,SAAS,EAAA,EAAG;AAElB,IAAA,IAAI,kBAAkB,OAAA,EAAS;AAC7B,MAAA,OAAA,EAAQ;AACR,MAAA,OAAO,MAAA,CAAO,KAAK,IAAI,CAAA,CAAE,MAAM,MAAM,CAAA,CAAE,QAAQ,QAAQ,CAAA;AAAA,IACzD,CAAA,MAAO;AACL,MAAA,MAAA,EAAO;AACP,MAAA,IAAA,CAAK,MAAM,CAAA;AACX,MAAA,QAAA,EAAS;AACT,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,MAAA,EAAO;AACP,IAAA,MAAA,CAAO,KAAK,CAAA;AACZ,IAAA,QAAA,EAAS;AAAA,EACX;AACF;;;;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface Options {
|
|
2
|
-
onSync?: () => void;
|
|
3
|
-
onAsync?: () => void;
|
|
4
|
-
then?: (result: unknown) => void;
|
|
5
|
-
catch?: (error: unknown) => void;
|
|
6
|
-
finally?: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare const callAndReact: (fn: (...args: unknown[]) => unknown, options?: Options) => unknown;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=callAndReact.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callAndReact.d.ts","sourceRoot":"","sources":["../../../../src/lib/promises/callAndReact.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAMD,eAAO,MAAM,YAAY,GACvB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACnC,UAAS,OAAY,YA0BtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callAndReact.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/promises/callAndReact.test.ts"],"names":[],"mappings":""}
|