@v1nt1248/3nclient-lib 0.1.29 → 0.1.32

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.
Files changed (41) hide show
  1. package/dist/components/ui3n-badge/ui3n-badge.vue.d.ts +7 -2
  2. package/dist/components/ui3n-breadcrumbs/ui3n-breadcrumb.vue.d.ts +7 -2
  3. package/dist/components/ui3n-breadcrumbs/ui3n-breadcrumbs.vue.d.ts +7 -2
  4. package/dist/components/ui3n-button/ui3n-button.vue.d.ts +11 -5
  5. package/dist/components/ui3n-checkbox/ui3n-checkbox.vue.d.ts +9 -2
  6. package/dist/components/ui3n-chip/ui3n-chip.vue.d.ts +7 -2
  7. package/dist/components/ui3n-dialog/ui3n-dialog.vue.d.ts +6 -13
  8. package/dist/components/ui3n-drop-files/ui3n-drop-files.vue.d.ts +9 -2
  9. package/dist/components/ui3n-list/ui3n-list.vue.d.ts +6 -11
  10. package/dist/components/ui3n-menu/ui3n-menu.vue.d.ts +11 -2
  11. package/dist/components/ui3n-notification/ui3n-notification.vue.d.ts +1 -1
  12. package/dist/components/ui3n-radio-group/ui3n-radio-group.vue.d.ts +7 -2
  13. package/dist/components/ui3n-radio-group/ui3n-radio.vue.d.ts +9 -2
  14. package/dist/components/ui3n-switch/ui3n-switch.vue.d.ts +9 -2
  15. package/dist/components/ui3n-table/ui3n-table.vue.d.ts +6 -9
  16. package/dist/components/ui3n-tabs/ui3n-tabs.vue.d.ts +9 -2
  17. package/dist/components/ui3n-tooltip/ui3n-tooltip.vue.d.ts +11 -2
  18. package/dist/components/ui3n-virtual-scroll/ui3n-virtual-scroll.vue.d.ts +4 -4
  19. package/dist/style.css +1 -1
  20. package/dist/ui3n-components.js +5639 -5759
  21. package/dist/ui3n-plugins.js +2890 -3034
  22. package/dist/ui3n-utils.js +1986 -2137
  23. package/dist/utils/index.d.ts +4 -1
  24. package/dist/utils/{sqlite-on-3nstorage/synced.d.ts → processes/named-procs.d.ts} +4 -34
  25. package/dist/utils/processes/single.d.ts +56 -0
  26. package/dist/utils/processes/sleep.d.ts +1 -0
  27. package/dist/utils/sqlite-on-3nstorage/index.d.ts +1 -1
  28. package/package.json +24 -24
  29. package/src/components/ui3n-button/ui3n-button.vue +2 -2
  30. package/src/components/ui3n-checkbox/ui3n-checkbox.vue +3 -3
  31. package/src/components/ui3n-chip/ui3n-chip.vue +0 -2
  32. package/src/components/ui3n-dialog/ui3n-dialog.vue +8 -6
  33. package/src/components/ui3n-input/ui3n-input.vue +0 -2
  34. package/src/components/ui3n-menu/ui3n-menu.vue +2 -2
  35. package/src/components/ui3n-radio-group/ui3n-radio.vue +2 -2
  36. package/src/components/ui3n-table/composables/useTable.ts +2 -1
  37. package/src/components/ui3n-table/ui3n-table.vue +2 -2
  38. package/src/components/ui3n-tabs/ui3n-tabs.vue +2 -2
  39. package/src/components/ui3n-text/ui3n-text.vue +0 -2
  40. package/dist/utils/processes.d.ts +0 -136
  41. /package/dist/utils/{sqlite-on-3nstorage → processes}/deferred.d.ts +0 -0
@@ -1,4 +1,7 @@
1
- export * from './processes';
1
+ export * from './processes/deferred';
2
+ export * from './processes/sleep';
3
+ export * from './processes/single';
4
+ export * from './processes/named-procs';
2
5
  export * from './textarea-max-rows';
3
6
  export * from './common';
4
7
  export * from './ui';
@@ -1,11 +1,4 @@
1
- /**
2
- * This represents a function that will create a promise, potentially starting
3
- * some background process, only when it is called. Such wrap of code is needed
4
- * for scheduling, as very often any start of an action must be postponed till
5
- * later time. Scheduler needs a not-yet-started activity, as scheduler has
6
- * control action's start.
7
- */
8
- export type Action<T> = () => Promise<T>;
1
+ import { Action } from './single';
9
2
  /**
10
3
  * This is a container of processes, labeled by some ids. It allows to track if
11
4
  * there is a process already in progress with a given id. And, it allows to
@@ -14,15 +7,15 @@ export type Action<T> = () => Promise<T>;
14
7
  * Common use of such class is to reuse getting of some expensive resource(s).
15
8
  */
16
9
  export declare class NamedProcs {
17
- private processes;
10
+ private promises;
18
11
  constructor();
19
12
  /**
20
13
  * @param id is a string key of a process
21
14
  * @return a promise of a process' completion, or undefined, if process with
22
15
  * given id is unknown.
23
16
  */
24
- latestTaskAtThisMoment<T>(id: string): Promise<T> | undefined;
25
- isProcessing(id: string): boolean;
17
+ getP<T>(id: string): Promise<T> | undefined;
18
+ private insertPromise;
26
19
  /**
27
20
  * This method will add a promise of an already started process.
28
21
  * @param id is a string key of a process
@@ -48,26 +41,3 @@ export declare class NamedProcs {
48
41
  */
49
42
  startOrChain<T>(id: string, action: Action<T>): Promise<T>;
50
43
  }
51
- /**
52
- * This is a container of process. It allows to track if a process is already
53
- * in progress. It also allows to chain process, when needed.
54
- *
55
- * Common use of such class is to reuse getting of some expensive resource, or
56
- * do ning something as an exclusive process.
57
- */
58
- export declare class SingleProc {
59
- private onGoingIdle?;
60
- private actions;
61
- private running;
62
- constructor(onGoingIdle?: (() => void) | undefined);
63
- isProcessing(): boolean;
64
- latestTaskAtThisMoment<T>(): Promise<T> | undefined;
65
- addStarted<T>(promise: Promise<T>): Promise<T>;
66
- start<T>(action: Action<T>): Promise<T>;
67
- private runIfIdle;
68
- startOrChain<T>(action: Action<T>): Promise<T>;
69
- }
70
- /**
71
- * This wraps given function/method into syncing wrap.
72
- */
73
- export declare function makeSyncedFunc<T extends Function>(syncProc: SingleProc, thisArg: any, func: T): T;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * This represents a function that will create a promise, potentially starting
3
+ * some background process, only when it is called. Such wrap of code is needed
4
+ * for scheduling, as very often any start of an action must be postponed till
5
+ * later time. Scheduler needs a not-yet-started activity, as scheduler has
6
+ * control action's start.
7
+ */
8
+ export type Action<T> = () => Promise<T>;
9
+ /**
10
+ * This is a container of process. It allows to track if a process is already
11
+ * in progress. It also allows to chain process, when needed.
12
+ *
13
+ * Common use of such class is to reuse getting of some expensive resource, or
14
+ * do ning something as an exclusive process.
15
+ */
16
+ export declare class SingleProc {
17
+ private promise;
18
+ constructor();
19
+ private insertPromise;
20
+ getP<T>(): Promise<T> | undefined;
21
+ addStarted<T>(promise: Promise<T>): Promise<T>;
22
+ start<T>(action: Action<T>): Promise<T>;
23
+ startOrChain<T>(action: Action<T>): Promise<T>;
24
+ }
25
+ /**
26
+ * This wraps given function/method into syncing wrap.
27
+ */
28
+ export declare function makeSyncedFunc<T extends Function>(syncProc: SingleProc, thisArg: any, func: T): T;
29
+ /**
30
+ * This is a cycling process, that ensures single execution.
31
+ * It cycles while given "while" predicate returns true. When predicate returns
32
+ * false, process goes to idle. Pushing this process into action is done via
33
+ * startIfIdle() method.
34
+ */
35
+ export declare class SingleCyclicProc {
36
+ private cycleWhile;
37
+ private action;
38
+ private proc;
39
+ /**
40
+ * @param cycleWhile is a "while" predicate. When it returns true, process
41
+ * continues to cycle, and when it returns false, process goes to idle.
42
+ * @param action is an async cycle body to run at each iteration.
43
+ */
44
+ constructor(cycleWhile: () => boolean, action: () => Promise<void>);
45
+ /**
46
+ * This starts process, if it is idle.
47
+ */
48
+ startIfIdle(): void;
49
+ private cycleOrIdle;
50
+ isRunning(): boolean;
51
+ /**
52
+ * This makes process unusable and unstartable. Waiting on a return promise,
53
+ * awaits the completion of the last iteration this process is in (if any).
54
+ */
55
+ close(): Promise<void>;
56
+ }
@@ -0,0 +1 @@
1
+ export declare function sleep(millis: number): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { Database as DBClass, BindParams as QueryParams, QueryExecResult as QueryResult } from './types';
2
- import { SingleProc, Action } from './synced';
2
+ import { SingleProc, Action } from '../processes/single';
3
3
  export type Database = DBClass;
4
4
  export type BindParams = QueryParams;
5
5
  export type QueryExecResult = QueryResult;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.1.29",
5
+ "version": "0.1.32",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -51,28 +51,28 @@
51
51
  "docs:preview": "vitepress preview docs"
52
52
  },
53
53
  "dependencies": {
54
- "@floating-ui/vue": "^1.1.4",
55
- "dayjs": "1.11.12",
54
+ "@floating-ui/vue": "1.1.5",
55
+ "dayjs": "1.11.13",
56
56
  "lodash": "4.17.21",
57
57
  "mitt": "3.0.1",
58
- "sanitize-html": "2.13.0",
59
- "tslib": "2.6.3",
58
+ "sanitize-html": "2.13.1",
59
+ "tslib": "2.8.0",
60
60
  "vuedraggable": "^4.1.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "pinia": "2.2.2",
64
- "vue": "3.5.5"
63
+ "pinia": "2.2.4",
64
+ "vue": "3.5.12"
65
65
  },
66
66
  "devDependencies": {
67
- "@types/lodash": "4.17.5",
68
- "@types/node": "20.14.2",
69
- "@types/sanitize-html": "2.11.0",
67
+ "@types/lodash": "4.17.12",
68
+ "@types/node": "20.16.13",
69
+ "@types/sanitize-html": "2.13.0",
70
70
  "@typescript-eslint/eslint-plugin": "8.0.1",
71
71
  "@typescript-eslint/parser": "8.0.1",
72
- "@vitejs/plugin-vue": "5.1.2",
73
- "@vue/compiler-core": "3.5.5",
72
+ "@vitejs/plugin-vue": "5.1.4",
73
+ "@vue/compiler-core": "3.5.12",
74
74
  "@vue/eslint-config-typescript": "13.0.0",
75
- "@vue/runtime-core": "3.5.5",
75
+ "@vue/runtime-core": "3.5.12",
76
76
  "@vuedx/typescript-plugin-vue": "0.7.6",
77
77
  "eslint": "9.9.0",
78
78
  "eslint-config-prettier": "^9.1.0",
@@ -83,25 +83,25 @@
83
83
  "eslint-plugin-vue": "9.27.0",
84
84
  "jackspeak": "4.0.1",
85
85
  "path": "0.12.7",
86
- "pinia": "2.2.1",
86
+ "pinia": "2.2.4",
87
87
  "postcss-html": "1.7.0",
88
88
  "prettier": "^3.3.3",
89
- "sass": "1.77.8",
89
+ "sass": "1.80.3",
90
90
  "stylelint": "16.8.1",
91
91
  "stylelint-config-recommended-scss": "14.1.0",
92
92
  "stylelint-config-recommended-vue": "1.5.0",
93
93
  "stylelint-config-standard": "36.0.1",
94
94
  "stylelint-scss": "6.5.0",
95
- "typescript": "5.5.4",
96
- "vite": "5.4.0",
97
- "vite-plugin-css-injected-by-js": "3.5.1",
98
- "vite-plugin-dts": "4.0.2",
99
- "vite-plugin-vue-devtools": "^7.3.7",
100
- "vitepress": "1.3.2",
101
- "vue": "3.5.5",
102
- "vue-tsc": "2.0.29"
95
+ "typescript": "5.6.3",
96
+ "vite": "5.4.9",
97
+ "vite-plugin-css-injected-by-js": "3.5.2",
98
+ "vite-plugin-dts": "4.2.4",
99
+ "vite-plugin-vue-devtools": "^7.5.2",
100
+ "vitepress": "1.4.1",
101
+ "vue": "3.5.12",
102
+ "vue-tsc": "2.1.6"
103
103
  },
104
- "packageManager": "pnpm@9.7.0",
104
+ "packageManager": "pnpm@9.12.0",
105
105
  "pnpm": {
106
106
  "peerDependencyRules": {
107
107
  "ignoreMissing": [
@@ -108,7 +108,7 @@ onMounted(() => {
108
108
  </template>
109
109
 
110
110
  <style lang="scss" module>
111
- @import "../../assets/styles/mixins";
111
+ @use '../../assets/styles/mixins' as mixins;
112
112
 
113
113
  .ui3nButton {
114
114
  --ui3n-button-padding: var(--spacing-m);
@@ -296,6 +296,6 @@ onMounted(() => {
296
296
  }
297
297
 
298
298
  .elevation {
299
- @include elevation();
299
+ @include mixins.elevation();
300
300
  }
301
301
  </style>
@@ -172,7 +172,7 @@ function change(ev: Event) {
172
172
  </template>
173
173
 
174
174
  <style lang="scss" module>
175
- @import "../../assets/styles/mixins";
175
+ @use '../../assets/styles/mixins' as mixins;
176
176
 
177
177
  .ui3nCheckbox {
178
178
  --ui3n-checkbox-size: 16px;
@@ -213,7 +213,7 @@ function change(ev: Event) {
213
213
  &:hover {
214
214
  border-color: hsl(from var(--ui3n-checkbox-color) h s calc(l - 10));
215
215
  background-color: hsl(from var(--ui3n-checkbox-color) h s calc(l - 10));
216
- @include ripple(hsl(from var(--ui3n-checkbox-color) h s calc(l - 10)));
216
+ @include mixins.ripple(hsl(from var(--ui3n-checkbox-color) h s calc(l - 10)));
217
217
  }
218
218
  }
219
219
 
@@ -221,7 +221,7 @@ function change(ev: Event) {
221
221
  &:hover {
222
222
  border-color: hsl(from var(--ui3n-checkbox-color) h s calc(l - 10));
223
223
  background-color: hsl(from transparent h s calc(l - 10));
224
- @include ripple(hsl(from transparent h s calc(l - 10)));
224
+ @include mixins.ripple(hsl(from transparent h s calc(l - 10)));
225
225
  }
226
226
  }
227
227
 
@@ -68,8 +68,6 @@ const mainCssClasses = computed(() => {
68
68
  </template>
69
69
 
70
70
  <style lang="scss" module>
71
- @import "../../assets/styles/mixins";
72
-
73
71
  .ui3nChip {
74
72
  position: relative;
75
73
  display: flex;
@@ -78,10 +78,11 @@ function closeDialog(arg?: { ev?: Event; withAction?: boolean }) {
78
78
  }
79
79
  }
80
80
 
81
- function startEmit(event: Ui3nDialogEvent) {
81
+ function startEmit(event: Ui3nDialogEvent, ev?: Event) {
82
82
  if (event === 'click-overlay') {
83
83
  emits(event);
84
- closeDialog();
84
+ dialogProps.value.closeOnClickOverlay && closeDialog({ ev });
85
+ return;
85
86
  }
86
87
 
87
88
  if (event === 'confirm') {
@@ -114,7 +115,7 @@ function handleEvent(event: Event, eventName: Ui3nDialogEvent) {
114
115
  <div
115
116
  v-if="show"
116
117
  :class="$style.overlay"
117
- @click="dialogProps.closeOnClickOverlay ? closeDialog({ ev: $event }) : startEmit('click-overlay')"
118
+ @click="startEmit('click-overlay', $event)"
118
119
  >
119
120
  <div
120
121
  ref="dialogElement"
@@ -191,7 +192,7 @@ function handleEvent(event: Event, eventName: Ui3nDialogEvent) {
191
192
  </template>
192
193
 
193
194
  <style lang="scss" module>
194
- @import '../../assets/styles/mixins';
195
+ @use '../../assets/styles/mixins' as mixins;
195
196
 
196
197
  .overlay {
197
198
  position: fixed;
@@ -221,7 +222,8 @@ function handleEvent(event: Event, eventName: Ui3nDialogEvent) {
221
222
  background-color: var(--color-bg-block-primary-default);
222
223
  border-radius: var(--dialog-border-radius);
223
224
  outline: none;
224
- @include elevation();
225
+
226
+ @include mixins.elevation();
225
227
  }
226
228
 
227
229
  .title {
@@ -237,7 +239,7 @@ function handleEvent(event: Event, eventName: Ui3nDialogEvent) {
237
239
  line-height: 1.2;
238
240
  color: var(--color-text-control-primary-default);
239
241
  border-bottom: 1px solid var(--color-border-block-primary-default);
240
- @include text-overflow-ellipsis();
242
+ @include mixins.text-overflow-ellipsis();
241
243
  }
242
244
 
243
245
  .closeBtn {
@@ -211,8 +211,6 @@ watch(
211
211
  </template>
212
212
 
213
213
  <style lang="scss" module>
214
- @import "../../assets/styles/mixins";
215
-
216
214
  .ui3nInput {
217
215
  --ui3n-input-height: var(--spacing-l);
218
216
  --ui3n-input-padding-left: var(--spacing-s);
@@ -92,7 +92,7 @@ watch(
92
92
  </template>
93
93
 
94
94
  <style lang="scss" module>
95
- @import "../../assets/styles/mixins";
95
+ @use '../../assets/styles/mixins' as mixins;
96
96
 
97
97
  .ui3nMenu {
98
98
  --ui3n-menu-content-bg: var(--color-bg-control-secondary-default);
@@ -112,6 +112,6 @@ watch(
112
112
  border-radius: 4px;
113
113
  background-color: var(--ui3n-menu-content-bg);
114
114
  z-index: 1000;
115
- @include elevation(3);
115
+ @include mixins.elevation(3);
116
116
  }
117
117
  </style>
@@ -196,7 +196,7 @@ watch(
196
196
  </template>
197
197
 
198
198
  <style lang="scss" module>
199
- @import "../../assets/styles/mixins";
199
+ @use '../../assets/styles/mixins' as mixins;
200
200
 
201
201
  .ui3nRadio {
202
202
  --ui3n-radio-size: 16px;
@@ -241,7 +241,7 @@ watch(
241
241
  &:hover {
242
242
  cursor: pointer;
243
243
  background-color: hsl(from transparent h s calc(l - 10));
244
- @include ripple(hsl(from transparent h s calc(l - 10)));
244
+ @include mixins.ripple(hsl(from transparent h s calc(l - 10)));
245
245
  }
246
246
  }
247
247
 
@@ -98,7 +98,8 @@ export function useTable<T extends Ui3nTableBodyBaseItem>(props: Ui3nTableProps<
98
98
  if (isEmpty(props.body.rowsStyle) || !isRowKeyUsed.value) return {};
99
99
 
100
100
  const rowKey = row[currentConfig.value.fieldAsRowKey as keyof T] as string | number;
101
- return get(props, ['body', 'rowsStyle', rowKey], {});
101
+ // @ts-expect-error
102
+ return get(props, ['body', 'rowsStyle', rowKey], {} as Record<string, string>);
102
103
  }
103
104
 
104
105
  function closeGroupActionsRow() {
@@ -159,7 +159,7 @@ const eventsHandlers = {
159
159
  </template>
160
160
 
161
161
  <style lang="scss" module>
162
- @import "../../assets/styles/mixins.scss";
162
+ @use '../../assets/styles/mixins' as mixins;
163
163
 
164
164
  .ui3nTable {
165
165
  --ui3n-table-columns-width: auto;
@@ -225,7 +225,7 @@ const eventsHandlers = {
225
225
  font-size: var(--font-14);
226
226
  font-weight: 500;
227
227
  color: var(--color-text-table-primary-default);
228
- @include text-overflow-ellipsis;
228
+ @include mixins.text-overflow-ellipsis();
229
229
  }
230
230
 
231
231
  .sortableActive {
@@ -83,7 +83,7 @@ const onClick = (ev: MouseEvent) => {
83
83
  </template>
84
84
 
85
85
  <style lang="scss" module>
86
- @import "../../assets/styles/mixins";
86
+ @use '../../assets/styles/mixins' as mixins;
87
87
 
88
88
  .ui3nTabs {
89
89
  --ui3n-tabs-height: 48px;
@@ -101,7 +101,7 @@ const onClick = (ev: MouseEvent) => {
101
101
  position: relative;
102
102
  user-select: none;
103
103
  color: v-bind(inactiveColorValue);
104
- @include ripple(var(--color-bg-control-secondary-default));
104
+ @include mixins.ripple(var(--color-bg-control-secondary-default));
105
105
 
106
106
  &:hover {
107
107
  background-color: var(--color-bg-control-secondary-default);
@@ -69,7 +69,6 @@ function onBlur(event: Event) {
69
69
  }
70
70
 
71
71
  function onInput(event: Event) {
72
- console.log('onInput!');
73
72
  const value = (event.target as HTMLInputElement).value;
74
73
  validate(value);
75
74
  emit('update:text', value);
@@ -77,7 +76,6 @@ function onInput(event: Event) {
77
76
  }
78
77
 
79
78
  function onEnterKeydown(event: KeyboardEvent) {
80
- console.log('onEnterKeydown: ', event);
81
79
  const { altKey, ctrlKey, shiftKey, metaKey, target } = event;
82
80
  const value = (target as HTMLInputElement).value;
83
81
  validate(value);
@@ -1,136 +0,0 @@
1
- export declare function sleep(millis: number): Promise<void>;
2
- /**
3
- * Standard Promise has no finally() method, when all respected libraries do.
4
- * Inside of an async function one may use try-finally clause. But, when we
5
- * work with raw promises, we need a compact finalization routine. And this is
6
- * it for synchronous completion.
7
- * @param promise
8
- * @param fin is a synchronous function that performs necessary
9
- * finalization/cleanup. Use finalizeAsync, when finalization is asynchronous.
10
- * @return a finalized promise
11
- */
12
- export declare function finalize<T>(promise: Promise<T>, fin: () => void): Promise<T>;
13
- /**
14
- * Standard Promise has no finally() method, when all respected libraries do.
15
- * Inside of an async function one may use try-finally clause. But, when we
16
- * work with raw promises, we need a compact finalization routine. And this is
17
- * it for an asynchronous completion.
18
- * @param promise
19
- * @param fin is an asynchronous function that performs necessary
20
- * finalization/cleanup. Use finalize, when finalization is synchronous
21
- * (is not returning promise).
22
- * @return a finalized promise
23
- */
24
- export declare function finalizeAsync<T>(promise: Promise<T>, fin: () => Promise<void>): Promise<T>;
25
- /**
26
- * This represents a function that will create a promise, potentially starting
27
- * some background process, only when it is called. Such wrap of code is needed
28
- * for scheduling, as very often any start of an action must be postponed till
29
- * later time. Scheduler needs a not-yet-started activity, as scheduler has
30
- * control action's start.
31
- */
32
- export type Action<T> = () => Promise<T>;
33
- /**
34
- * This is a container of processes, labeled by some ids. It allows to track if
35
- * there is a process already in progress with a given id. And, it allows to
36
- * chain process, when needed.
37
- *
38
- * Common use of such class is to reuse getting of some expensive resource(s).
39
- */
40
- export declare class NamedProcs {
41
- private promises;
42
- constructor();
43
- /**
44
- * @param id is a string key of a process
45
- * @return a promise of a process' completion, or undefined, if process with
46
- * given id is unknown.
47
- */
48
- getP<T>(id: string): Promise<T> | undefined;
49
- private insertPromise;
50
- /**
51
- * This method will add a promise of an already started process.
52
- * @param id is a string key of a process
53
- * @param promise of an already started process
54
- * @return a promise of a process' completion.
55
- */
56
- addStarted<T>(id: string, promise: Promise<T>): Promise<T>;
57
- /**
58
- * This method will start a given action only, if a process with a given id
59
- * is not running.
60
- * @param id is a string key of a process
61
- * @param action is a function that starts some process
62
- * @return a promise of a process' completion.
63
- */
64
- start<T>(id: string, action: Action<T>): Promise<T>;
65
- /**
66
- * This method will chain a given action to an already running process, or,
67
- * if identified process is not running, this will start given action under
68
- * a given id.
69
- * @param id is a string key of a process
70
- * @param action is a function that starts some process
71
- * @return a promise of a process' completion.
72
- */
73
- startOrChain<T>(id: string, action: Action<T>): Promise<T>;
74
- }
75
- /**
76
- * This is a container of process. It allows to track if a process is already
77
- * in progress. It also allows to chain process, when needed.
78
- *
79
- * Common use of such class is to reuse getting of some expensive resource, or
80
- * do ning something as an exclusive process.
81
- */
82
- export declare class SingleProc {
83
- private promise;
84
- constructor();
85
- private insertPromise;
86
- getP<T>(): Promise<T> | undefined;
87
- addStarted<T>(promise: Promise<T>): Promise<T>;
88
- start<T>(action: Action<T>): Promise<T>;
89
- startOrChain<T>(action: Action<T>): Promise<T>;
90
- }
91
- export declare class DeduppedRunner<T> {
92
- private readonly action;
93
- private proc;
94
- private waiting;
95
- constructor(action: Action<T>);
96
- trigger(): Promise<T>;
97
- private startAction;
98
- }
99
- /**
100
- * This wraps given function/method into syncing wrap.
101
- */
102
- export declare function makeSyncedFunc<T extends Function>(syncProc: SingleProc, thisArg: any, func: T): T;
103
- /**
104
- * This is a cycling process, that ensures single execution.
105
- * It cycles while given "while" predicate returns true. When predicate returns
106
- * false, process goes to idle. Pushing this process into action is done via
107
- * startIfIdle() method.
108
- */
109
- export declare class SingleCyclicProc {
110
- private cycleWhile;
111
- private action;
112
- private proc;
113
- /**
114
- * @param cycleWhile is a "while" predicate. When it returns true, process
115
- * continues to cycle, and when it returns false, process goes to idle.
116
- * @param action is an async cycle body to run at each iteration.
117
- */
118
- constructor(cycleWhile: () => boolean, action: () => Promise<void>);
119
- /**
120
- * This starts process, if it is idle.
121
- */
122
- startIfIdle(): void;
123
- private cycleOrIdle;
124
- isRunning(): boolean;
125
- /**
126
- * This makes process unusable and unstartable. Waiting on a return promise,
127
- * awaits the completion of the last iteration this process is in (if any).
128
- */
129
- close(): Promise<void>;
130
- }
131
- export interface Deferred<T> {
132
- promise: Promise<T>;
133
- resolve: (result: T | PromiseLike<T>) => void;
134
- reject: (err: any) => void;
135
- }
136
- export declare function defer<T>(): Deferred<T>;