@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/CHANGELOG.md +12 -0
- package/dist/pl-uikit.js +140 -136
- package/dist/pl-uikit.umd.cjs +5 -5
- package/dist/src/components/PlBtnGhost/PlBtnGhost.vue.d.ts +1 -0
- package/dist/src/components/PlLogView/PlLogView.vue.d.ts +8 -0
- package/dist/src/components/PlLogView/useLogHandle.d.ts +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/PlBtnGhost/PlBtnGhost.vue +1 -0
- package/src/components/PlLogView/PlLogView.vue +4 -0
- package/src/components/PlLogView/useLogHandle.ts +18 -4
package/package.json
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
},
|