@milaboratories/uikit 2.0.3 → 2.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/uikit",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "type": "module",
5
5
  "main": "dist/pl-uikit.umd.js",
6
6
  "module": "dist/pl-uikit.js",
@@ -71,5 +71,6 @@ useRipple(btnRef);
71
71
  </span>
72
72
  <MaskIcon16 v-if="loading" name="loading" :size="size" />
73
73
  <MaskIcon16 v-else-if="icon" :name="icon" :size="size" />
74
+ <slot name="append" />
74
75
  </button>
75
76
  </template>
@@ -42,6 +42,10 @@ const props = defineProps<{
42
42
  * Block output (Note: error and value take precedence over output property)
43
43
  */
44
44
  output?: ValueOrErrors<unknown>;
45
+ /**
46
+ * Max retries for AnyLogHandle fetch (with the same parameters)
47
+ */
48
+ maxRetries?: number;
45
49
  /**
46
50
  * @TODO
47
51
  */
@@ -1,4 +1,4 @@
1
- import { type Reactive, ref, watch } from 'vue';
1
+ import { reactive, type Reactive, ref, watch } from 'vue';
2
2
  import { useTimeoutPoll, whenever } from '@vueuse/core';
3
3
  import type { AnyLogHandle, Platforma } from '@platforma-sdk/model';
4
4
 
@@ -17,9 +17,15 @@ function escapeRegExp(str: string) {
17
17
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
18
18
  }
19
19
 
20
- export function useLogHandle(props: Reactive<{ logHandle: AnyLogHandle | undefined; mockPlatforma?: Platforma; progressPrefix?: string }>) {
20
+ export function useLogHandle(
21
+ props: Reactive<{ logHandle: AnyLogHandle | undefined; maxRetries?: number; mockPlatforma?: Platforma; progressPrefix?: string }>,
22
+ ) {
21
23
  const logState = ref<LogState>();
22
24
 
25
+ const data = reactive({
26
+ errorCount: 0,
27
+ });
28
+
23
29
  async function fetchLogs() {
24
30
  // making a snapshot of the ref
25
31
  let currentLogState: LogState | undefined = logState.value;
@@ -35,9 +41,11 @@ export function useLogHandle(props: Reactive<{ logHandle: AnyLogHandle | undefin
35
41
 
36
42
  // eslint-disable-next-line no-constant-condition
37
43
  while (true) {
44
+ const result = await platforma.logDriver.readText(currentLogState.logHandle, 100, currentLogState.lastOffset);
45
+
38
46
  currentLogState.error = undefined;
39
47
 
40
- const result = await platforma.logDriver.readText(currentLogState.logHandle, 100, currentLogState.lastOffset);
48
+ data.errorCount = 0;
41
49
 
42
50
  if (result.shouldUpdateHandle) return;
43
51
 
@@ -63,7 +71,12 @@ export function useLogHandle(props: Reactive<{ logHandle: AnyLogHandle | undefin
63
71
  const fetchAndCatch = () =>
64
72
  fetchLogs().catch((err) => {
65
73
  if (logState.value) {
66
- logState.value.error = err;
74
+ data.errorCount++;
75
+ if (data.errorCount > (props.maxRetries ?? 3)) {
76
+ logState.value.error = err;
77
+ } else {
78
+ console.warn('skip error:', err, 'retry...');
79
+ }
67
80
  }
68
81
  });
69
82
 
@@ -83,6 +96,7 @@ export function useLogHandle(props: Reactive<{ logHandle: AnyLogHandle | undefin
83
96
  timeoutPoll.pause();
84
97
  } else if (lh !== logState.value?.logHandle) {
85
98
  logState.value = { logHandle: lh, lastOffset: 0, lines: '', finished: false, error: undefined };
99
+ data.errorCount = 0;
86
100
  timeoutPoll.resume();
87
101
  }
88
102
  },