@antcde/vue-utils 0.2.13 → 0.2.14-rc.00a441c
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/dist/index.js
CHANGED
|
@@ -1,182 +1,350 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computed as
|
|
3
|
-
import { useI18n as
|
|
4
|
-
import { newCommsClient as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
L(n, ["state", "system", "store"])
|
|
31
|
-
);
|
|
1
|
+
import { objectOmit as e, objectPick as t, useAsyncState as n, useColorMode as r, useMagicKeys as i, watchDebounced as a, whenever as o } from "@vueuse/core";
|
|
2
|
+
import { computed as s, inject as c, onBeforeUnmount as l, onMounted as u, onUnmounted as d, readonly as f, ref as p, shallowRef as m, watch as h } from "vue";
|
|
3
|
+
import { useI18n as g } from "vue-i18n";
|
|
4
|
+
import { newCommsClient as _, newCommsHost as v } from "@antcde/connect-ts";
|
|
5
|
+
import { BehaviorSubject as y, Subject as b, concat as x, concatMap as S, debounceTime as C, distinctUntilChanged as w, filter as T, map as E } from "rxjs";
|
|
6
|
+
//#region src/useAntColorMode.ts
|
|
7
|
+
function D(e, n) {
|
|
8
|
+
let i = r(n), a = s(() => e.context.value.darkMode), o = s(() => {
|
|
9
|
+
switch (a.value) {
|
|
10
|
+
case null: return "auto";
|
|
11
|
+
case !0: return "dark";
|
|
12
|
+
case !1: return "light";
|
|
13
|
+
default: return i.value;
|
|
14
|
+
}
|
|
15
|
+
}), c = s(() => {
|
|
16
|
+
switch (o.value) {
|
|
17
|
+
case "light":
|
|
18
|
+
case "auto": return !1;
|
|
19
|
+
case "dark": return !0;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return Object.assign(o, {
|
|
23
|
+
host: a,
|
|
24
|
+
isDark: c
|
|
25
|
+
}, t(i, [
|
|
26
|
+
"state",
|
|
27
|
+
"system",
|
|
28
|
+
"store"
|
|
29
|
+
]));
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{ immediate: !0 }
|
|
39
|
-
), n;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/useAntI18n.ts
|
|
33
|
+
function O(e, t) {
|
|
34
|
+
let n = g(t);
|
|
35
|
+
return h(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/useCommsClient.ts
|
|
39
|
+
function k(t, n, r) {
|
|
40
|
+
let i = p({}), a = _({
|
|
41
|
+
parent: window.parent,
|
|
42
|
+
connect: t,
|
|
43
|
+
manifest: r
|
|
44
|
+
}), o = p(""), c = s({
|
|
45
|
+
get: () => o.value,
|
|
46
|
+
set: (e) => a.appState.set(e)
|
|
47
|
+
});
|
|
48
|
+
return a.context.subscribe((e) => i.value = e), x(a.appState.get(), a.appState).subscribe((e) => o.value = e), j(a.signal, a, n), l(() => a.unsubscribe()), Object.assign(e(a, [
|
|
49
|
+
"context",
|
|
50
|
+
"toolbar",
|
|
51
|
+
"appState"
|
|
52
|
+
]), {
|
|
53
|
+
context: i,
|
|
54
|
+
toolbar: A(a),
|
|
55
|
+
appState: c
|
|
56
|
+
});
|
|
54
57
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
58
|
+
function A(e) {
|
|
59
|
+
let t = p(""), n = {
|
|
60
|
+
title: s({
|
|
61
|
+
get: () => e.toolbar.get().title,
|
|
62
|
+
set: (t) => e.toolbar.set((e) => ({
|
|
63
|
+
...e,
|
|
64
|
+
title: t
|
|
65
|
+
}))
|
|
66
|
+
}),
|
|
67
|
+
subtitle: s({
|
|
68
|
+
get: () => e.toolbar.get().subtitle,
|
|
69
|
+
set: (t) => e.toolbar.set((e) => ({
|
|
70
|
+
...e,
|
|
71
|
+
subtitle: t
|
|
72
|
+
}))
|
|
73
|
+
}),
|
|
74
|
+
searchEnabled: s({
|
|
75
|
+
get: () => e.toolbar.get().search.enabled,
|
|
76
|
+
set: (t) => e.toolbar.set((e) => ({
|
|
77
|
+
...e,
|
|
78
|
+
search: {
|
|
79
|
+
...e.search,
|
|
80
|
+
enabled: t
|
|
81
|
+
}
|
|
82
|
+
}))
|
|
83
|
+
}),
|
|
84
|
+
search: s({
|
|
85
|
+
get: () => t.value,
|
|
86
|
+
set: (t) => e.toolbar.set((e) => ({
|
|
87
|
+
...e,
|
|
88
|
+
search: {
|
|
89
|
+
...e.search,
|
|
90
|
+
input: t
|
|
91
|
+
}
|
|
92
|
+
}))
|
|
93
|
+
}),
|
|
94
|
+
menu: s({
|
|
95
|
+
get: () => e.toolbar.get().menu ?? [],
|
|
96
|
+
set: (t) => e.toolbar.set((e) => ({
|
|
97
|
+
...e,
|
|
98
|
+
menu: t
|
|
99
|
+
}))
|
|
100
|
+
}),
|
|
101
|
+
isLoading: s({
|
|
102
|
+
get: () => e.toolbar.get().isLoading,
|
|
103
|
+
set: (t) => e.toolbar.set((e) => ({
|
|
104
|
+
...e,
|
|
105
|
+
isLoading: t
|
|
106
|
+
}))
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
return e.toolbar.pipe(E((e) => e.search.input ?? ""), w(), C(300)).forEach((e) => t.value = e), n;
|
|
83
110
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
S((c) => t(c))
|
|
88
|
-
).subscribe();
|
|
89
|
-
return o.add(m), m.add(g(s, () => i.next({ hotkeys: { ctrl: !0 } }))), m.add(g(r, () => i.next({ hotkeys: { shift: !0 } }))), m;
|
|
111
|
+
function j(e, t, n) {
|
|
112
|
+
let r = i(), a = r.ctrl ?? s(() => !1), c = r.shift ?? s(() => !1), l = new b(), u = l.pipe(S(n ?? ((e) => Promise.resolve(e))), S((t) => e(t))).subscribe();
|
|
113
|
+
return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
|
|
90
114
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/useCommsHost.ts
|
|
117
|
+
function M(e) {
|
|
118
|
+
let { context: t } = e, n = new y({}), r = (e) => n.next(e(n.value)), i = p(), o = new y(void 0), c = h(i, (e) => o.next(e), { immediate: !0 }), l = o.asObservable().pipe(E((e) => e?.contentWindow), T((e) => !!e)), u = v({
|
|
119
|
+
...e,
|
|
120
|
+
contextChanges: n,
|
|
121
|
+
windowChanges: l
|
|
122
|
+
});
|
|
123
|
+
Object.entries(t).map(([e, t]) => h(t, (t) => r((n) => ({
|
|
124
|
+
...n,
|
|
125
|
+
[e]: t
|
|
126
|
+
})), { immediate: !0 })).forEach((e) => u.scope.add(e)), u.toolbar.subscribe((t) => {
|
|
127
|
+
let n = e.toolbar;
|
|
128
|
+
n.title.value = t.title, n.subtitle.value = t.subtitle, n.searchEnabled.value = t.search?.enabled ?? !1, n.search.value = t.search?.input, n.menu.value = t.menu, n.isLoading.value = t?.isLoading ?? !1;
|
|
129
|
+
});
|
|
130
|
+
let d = a(e.toolbar.search, (e) => u.toolbar.set.search(e), {
|
|
131
|
+
immediate: !0,
|
|
132
|
+
debounce: 100
|
|
133
|
+
});
|
|
134
|
+
u.scope.add(c), u.scope.add(d);
|
|
135
|
+
let f = p(u.appState.get()), m = s({
|
|
136
|
+
get: () => f.value,
|
|
137
|
+
set: (e) => u.appState.set(e)
|
|
138
|
+
});
|
|
139
|
+
u.appState.changes.subscribe((e) => f.value = e);
|
|
140
|
+
let g = p(!1);
|
|
141
|
+
u.isConnectionInitialized.subscribe((e) => g.value = e);
|
|
142
|
+
let _ = p(null);
|
|
143
|
+
u.manifest?.subscribe((e) => _.value = e);
|
|
144
|
+
let { unsubscribe: b, signal: x, closed: S } = u;
|
|
145
|
+
return {
|
|
146
|
+
...e,
|
|
147
|
+
client: i,
|
|
148
|
+
appState: m,
|
|
149
|
+
isConnectionInitialized: g,
|
|
150
|
+
manifest: _,
|
|
151
|
+
unsubscribe: b,
|
|
152
|
+
signal: x,
|
|
153
|
+
closed: S
|
|
154
|
+
};
|
|
127
155
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/usePermissions.ts
|
|
158
|
+
function N(e) {
|
|
159
|
+
let t = s(() => e.value?.user), n = s(() => e.value?.license), r = s(() => e.value?.project), i = s(() => !!t.value?.is_admin), a = s(() => !!n.value?.user_is_admin), o = s(() => !!r.value?.user_is_admin || a.value);
|
|
160
|
+
function c(e) {
|
|
161
|
+
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
|
|
162
|
+
}
|
|
163
|
+
function l(e) {
|
|
164
|
+
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : !!n.value.user_permissions?.[String(e)];
|
|
165
|
+
}
|
|
166
|
+
function u(e) {
|
|
167
|
+
return !t.value || !r.value ? !1 : i.value || a.value || o.value ? !0 : (r.value.user_roles ?? []).some((t) => t.name === e);
|
|
168
|
+
}
|
|
169
|
+
function d(e) {
|
|
170
|
+
return !t.value || !r.value ? !1 : i.value || a.value ? !0 : !!r.value.user_permissions?.[String(e)];
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
isGlobalAdmin: i,
|
|
174
|
+
isLicenseAdmin: a,
|
|
175
|
+
isProjectAdmin: o,
|
|
176
|
+
hasLicenseRole: c,
|
|
177
|
+
hasLicensePermission: l,
|
|
178
|
+
hasProjectRole: u,
|
|
179
|
+
hasProjectPermission: d
|
|
180
|
+
};
|
|
143
181
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/useTemplateVersioning.ts
|
|
184
|
+
function P(e) {
|
|
185
|
+
let t = m(null), n = m(null), r = m(null), i = m(null), a = m([]), o = m(null), c = p(!1), l = p(!1), u = p(!1), d = p(!1), f = p(!1), h = p(!1), g = s(() => t.value?.has_update ?? !1), _ = s(() => t.value?.current_version ?? null), v = s(() => t.value?.latest_version ?? null), y = s(() => n.value ? n.value.added.length + n.value.removed.length + n.value.modified.length + n.value.relations_added.length + n.value.relations_removed.length : 0);
|
|
186
|
+
async function b(n) {
|
|
187
|
+
c.value = !0;
|
|
188
|
+
try {
|
|
189
|
+
return t.value = (await e.tasks.checkForUpdates(n))?.data ?? null, t.value;
|
|
190
|
+
} catch {
|
|
191
|
+
return t.value = null, null;
|
|
192
|
+
} finally {
|
|
193
|
+
c.value = !1;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function x(t, r) {
|
|
197
|
+
l.value = !0;
|
|
198
|
+
try {
|
|
199
|
+
return n.value = (await e.tasks.versionDiff(t, r))?.data ?? null, n.value;
|
|
200
|
+
} catch {
|
|
201
|
+
return n.value = null, null;
|
|
202
|
+
} finally {
|
|
203
|
+
l.value = !1;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function S(t, r, i) {
|
|
207
|
+
l.value = !0;
|
|
208
|
+
try {
|
|
209
|
+
return n.value = (await e.tasks.versionCompare(t, r, i))?.data ?? null, n.value;
|
|
210
|
+
} catch {
|
|
211
|
+
return n.value = null, null;
|
|
212
|
+
} finally {
|
|
213
|
+
l.value = !1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function C(t) {
|
|
217
|
+
u.value = !0;
|
|
218
|
+
try {
|
|
219
|
+
return r.value = (await e.tasks.versionDiffOriginal(t))?.data ?? null, r.value;
|
|
220
|
+
} catch {
|
|
221
|
+
return r.value = null, null;
|
|
222
|
+
} finally {
|
|
223
|
+
u.value = !1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
async function w(r, a) {
|
|
227
|
+
d.value = !0;
|
|
228
|
+
try {
|
|
229
|
+
return i.value = (await e.tasks.syncToLatestVersion(r, a))?.data ?? null, t.value = null, n.value = null, i.value;
|
|
230
|
+
} catch {
|
|
231
|
+
return i.value = null, null;
|
|
232
|
+
} finally {
|
|
233
|
+
d.value = !1;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async function T(t, n) {
|
|
237
|
+
f.value = !0;
|
|
238
|
+
try {
|
|
239
|
+
let r = (await e.tasks.publishVersion(t, { change_summary: n }))?.data ?? null;
|
|
240
|
+
return r && (a.value = [r, ...a.value], o.value = r), r;
|
|
241
|
+
} catch {
|
|
242
|
+
return null;
|
|
243
|
+
} finally {
|
|
244
|
+
f.value = !1;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async function E(t) {
|
|
248
|
+
h.value = !0;
|
|
249
|
+
try {
|
|
250
|
+
return a.value = (await e.tasks.listVersions(t))?.data ?? [], a.value;
|
|
251
|
+
} catch {
|
|
252
|
+
return a.value = [], [];
|
|
253
|
+
} finally {
|
|
254
|
+
h.value = !1;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function D(t) {
|
|
258
|
+
try {
|
|
259
|
+
return o.value = (await e.tasks.latestVersion(t))?.data ?? null, o.value;
|
|
260
|
+
} catch {
|
|
261
|
+
return o.value = null, null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let O = m([]), k = p(!1), A = p(!1), j = m([]);
|
|
265
|
+
async function M(t) {
|
|
266
|
+
k.value = !0;
|
|
267
|
+
try {
|
|
268
|
+
return O.value = (await e.tasks.getInstances(t))?.data ?? [], O.value;
|
|
269
|
+
} catch {
|
|
270
|
+
return O.value = [], [];
|
|
271
|
+
} finally {
|
|
272
|
+
k.value = !1;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function N(t, n) {
|
|
276
|
+
A.value = !0, j.value = [];
|
|
277
|
+
try {
|
|
278
|
+
return j.value = (await e.tasks.pushSync(t, n))?.data ?? [], j.value;
|
|
279
|
+
} catch {
|
|
280
|
+
return j.value = [], [];
|
|
281
|
+
} finally {
|
|
282
|
+
A.value = !1;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function P() {
|
|
286
|
+
t.value = null, n.value = null, r.value = null, i.value = null, a.value = [], o.value = null, O.value = [], j.value = [];
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
updateCheck: t,
|
|
290
|
+
diff: n,
|
|
291
|
+
userCustomizations: r,
|
|
292
|
+
syncResult: i,
|
|
293
|
+
versions: a,
|
|
294
|
+
latestVersion: o,
|
|
295
|
+
instances: O,
|
|
296
|
+
pushSyncResults: j,
|
|
297
|
+
isCheckingUpdate: c,
|
|
298
|
+
isFetchingDiff: l,
|
|
299
|
+
isFetchingCustomizations: u,
|
|
300
|
+
isSyncing: d,
|
|
301
|
+
isPublishing: f,
|
|
302
|
+
isFetchingVersions: h,
|
|
303
|
+
isFetchingInstances: k,
|
|
304
|
+
isPushSyncing: A,
|
|
305
|
+
hasUpdate: g,
|
|
306
|
+
currentVersion: _,
|
|
307
|
+
availableVersion: v,
|
|
308
|
+
totalChanges: y,
|
|
309
|
+
checkForUpdates: b,
|
|
310
|
+
fetchDiff: x,
|
|
311
|
+
fetchUserCustomizations: C,
|
|
312
|
+
compareVersions: S,
|
|
313
|
+
syncToVersion: w,
|
|
314
|
+
publishVersion: T,
|
|
315
|
+
fetchVersions: E,
|
|
316
|
+
fetchLatestVersion: D,
|
|
317
|
+
fetchInstances: M,
|
|
318
|
+
pushSync: N,
|
|
319
|
+
reset: P
|
|
320
|
+
};
|
|
151
321
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/utils.ts
|
|
324
|
+
function F(e = "comms") {
|
|
325
|
+
let [t, n] = I(e, () => k(), (e) => e.unsubscribe());
|
|
326
|
+
return {
|
|
327
|
+
provideComms: t,
|
|
328
|
+
injectComms: n
|
|
329
|
+
};
|
|
159
330
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
execute: (...r) => s.execute(void 0, ...r),
|
|
164
|
-
executeDelayed: s.execute
|
|
165
|
-
});
|
|
331
|
+
function I(e, t, n) {
|
|
332
|
+
let r, i = () => (!r && (r = t()), r);
|
|
333
|
+
return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
|
|
166
334
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
335
|
+
function L(t, r, i) {
|
|
336
|
+
let a = n(t, r, {
|
|
337
|
+
immediate: !1,
|
|
338
|
+
...i
|
|
339
|
+
});
|
|
340
|
+
return Object.assign(e(a, ["execute"]), {
|
|
341
|
+
execute: (...e) => a.execute(void 0, ...e),
|
|
342
|
+
executeDelayed: a.execute
|
|
343
|
+
});
|
|
171
344
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
ae as useCommsInjection,
|
|
179
|
-
oe as usePermissions,
|
|
180
|
-
ue as useSignal,
|
|
181
|
-
Q as useSingleton
|
|
182
|
-
};
|
|
345
|
+
function R(e) {
|
|
346
|
+
let t, n = p(void 0);
|
|
347
|
+
return u(() => t = e.signal.receive((e) => n.value = e)), d(() => t?.()), [f(n), () => t?.()];
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
export { D as useAntColorMode, O as useAntI18n, L as useApi, k as useCommsClient, M as useCommsHost, F as useCommsInjection, N as usePermissions, R as useSignal, I as useSingleton, P as useTemplateVersioning };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { useAntI18n, type UseAntI18nReturn } from './useAntI18n';
|
|
|
3
3
|
export { type UseCommsClient, useCommsClient } from './useCommsClient';
|
|
4
4
|
export { type CommsHostArgs, type UseCommsHost, useCommsHost } from './useCommsHost';
|
|
5
5
|
export { type UsePermissions, usePermissions } from './usePermissions';
|
|
6
|
+
export { useTemplateVersioning, type UseTemplateVersioningReturn } from './useTemplateVersioning';
|
|
6
7
|
export { type AnyUseApiReturn, type CommsToolbar, useApi, type UseApiReturn, useCommsInjection, useSignal, useSingleton, } from './utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntConnect, Client, Context, Signal } from '@antcde/connect-ts';
|
|
1
|
+
import { AntConnect, AppManifest, Client, Context, Signal } from '@antcde/connect-ts';
|
|
2
2
|
import { ObservableInput } from 'rxjs';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
4
|
import { CommsToolbar } from './utils';
|
|
@@ -20,5 +20,5 @@ type KeyboardShortcutsHook = (signal: Signal) => ObservableInput<Signal>;
|
|
|
20
20
|
* @param keyboardsShortcuts By default it will process keyboards from the client and send them to the host.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export declare function useCommsClient(connect?: AntConnect, keyboardsShortcuts?: KeyboardShortcutsHook): UseCommsClient;
|
|
23
|
+
export declare function useCommsClient(connect?: AntConnect, keyboardsShortcuts?: KeyboardShortcutsHook, manifest?: AppManifest): UseCommsClient;
|
|
24
24
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntConnect, LabelFilterState, License, Notepad, Notification, ProjectShort, SignalObserverFactory, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
|
|
1
|
+
import { AntConnect, AppManifest, LabelFilterState, License, Notepad, Notification, ProjectShort, SignalObserverFactory, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
|
|
2
2
|
import { SubscriptionLike } from 'rxjs';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
4
|
import { CommsToolbar } from './utils';
|
|
@@ -30,6 +30,7 @@ export interface UseCommsHost extends CommsHostArgs, SubscriptionLike {
|
|
|
30
30
|
client: Ref<HTMLIFrameElement | null | undefined>;
|
|
31
31
|
appState: Ref<string>;
|
|
32
32
|
isConnectionInitialized: Ref<boolean>;
|
|
33
|
+
manifest: Ref<AppManifest | null>;
|
|
33
34
|
signal: SignalReceiver & SignalSender;
|
|
34
35
|
}
|
|
35
36
|
export declare function useCommsHost(args: CommsHostArgs): UseCommsHost;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AntConnect, PushSyncResult, TaskTemplateVersion, TemplateInstance, VersionCheck, VersionDiff, VersionSyncResult } from '@antcde/connect-ts';
|
|
2
|
+
import { ComputedRef, ref, shallowRef } from 'vue';
|
|
3
|
+
export interface UseTemplateVersioningReturn {
|
|
4
|
+
updateCheck: Readonly<ReturnType<typeof shallowRef<VersionCheck | null>>>;
|
|
5
|
+
diff: Readonly<ReturnType<typeof shallowRef<VersionDiff | null>>>;
|
|
6
|
+
userCustomizations: Readonly<ReturnType<typeof shallowRef<VersionDiff | null>>>;
|
|
7
|
+
syncResult: Readonly<ReturnType<typeof shallowRef<VersionSyncResult | null>>>;
|
|
8
|
+
versions: Readonly<ReturnType<typeof shallowRef<TaskTemplateVersion[]>>>;
|
|
9
|
+
latestVersion: Readonly<ReturnType<typeof shallowRef<TaskTemplateVersion | null>>>;
|
|
10
|
+
instances: Readonly<ReturnType<typeof shallowRef<TemplateInstance[]>>>;
|
|
11
|
+
pushSyncResults: Readonly<ReturnType<typeof shallowRef<PushSyncResult[]>>>;
|
|
12
|
+
isCheckingUpdate: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
13
|
+
isFetchingDiff: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
14
|
+
isFetchingCustomizations: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
15
|
+
isSyncing: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
16
|
+
isPublishing: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
17
|
+
isFetchingVersions: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
18
|
+
isFetchingInstances: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
19
|
+
isPushSyncing: Readonly<ReturnType<typeof ref<boolean>>>;
|
|
20
|
+
hasUpdate: ComputedRef<boolean>;
|
|
21
|
+
currentVersion: ComputedRef<number | null>;
|
|
22
|
+
availableVersion: ComputedRef<number | null>;
|
|
23
|
+
totalChanges: ComputedRef<number>;
|
|
24
|
+
checkForUpdates: (taskId: string) => Promise<VersionCheck | null>;
|
|
25
|
+
fetchDiff: (taskId: string, targetVersionId?: string) => Promise<VersionDiff | null>;
|
|
26
|
+
fetchUserCustomizations: (taskId: string) => Promise<VersionDiff | null>;
|
|
27
|
+
compareVersions: (templateId: string, fromVersionId: string, toVersionId: string) => Promise<VersionDiff | null>;
|
|
28
|
+
syncToVersion: (taskId: string, targetVersionId?: string) => Promise<VersionSyncResult | null>;
|
|
29
|
+
publishVersion: (templateId: string, changeSummary?: string) => Promise<TaskTemplateVersion | null>;
|
|
30
|
+
fetchVersions: (templateId: string) => Promise<TaskTemplateVersion[]>;
|
|
31
|
+
fetchLatestVersion: (templateId: string) => Promise<TaskTemplateVersion | null>;
|
|
32
|
+
fetchInstances: (templateId: string) => Promise<TemplateInstance[]>;
|
|
33
|
+
pushSync: (templateId: string, instanceIds: string[]) => Promise<PushSyncResult[]>;
|
|
34
|
+
reset: () => void;
|
|
35
|
+
}
|
|
36
|
+
export declare function useTemplateVersioning(connect: AntConnect): UseTemplateVersioningReturn;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antcde/vue-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.14-rc.00a441c",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"clean": "pnpm dlx rimraf dist"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@vueuse/core": "^
|
|
28
|
+
"@vueuse/core": "^14.0.0",
|
|
29
29
|
"rxjs": "^7.0.0",
|
|
30
30
|
"vue": "^3.5.10",
|
|
31
31
|
"vue-i18n": "^11.1.12"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@antcde/connect-ts": "0.4.
|
|
34
|
+
"@antcde/connect-ts": "0.4.18-rc.00a441c"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tsconfig/node22": "^22.0.5",
|
|
38
|
-
"@types/node": "^22.19.
|
|
39
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
40
|
-
"@vue/tsconfig": "^0.
|
|
41
|
-
"typescript": "~
|
|
42
|
-
"vite": "^
|
|
38
|
+
"@types/node": "^22.19.19",
|
|
39
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
40
|
+
"@vue/tsconfig": "^0.9.1",
|
|
41
|
+
"typescript": "~6.0.3",
|
|
42
|
+
"vite": "^8.0.14",
|
|
43
43
|
"vite-plugin-dts": "^4.5.4",
|
|
44
|
-
"vue-tsc": "^3.2
|
|
44
|
+
"vue-tsc": "^3.3.2"
|
|
45
45
|
}
|
|
46
46
|
}
|