@antcde/vue-utils 0.2.12-rc.64ce643 → 0.2.13-rc.0c67d53
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 +98 -95
- package/dist/types/useCommsClient.d.ts +2 -2
- package/dist/types/useCommsHost.d.ts +2 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useColorMode as
|
|
2
|
-
import { computed as u, watch as h, ref as d, onBeforeUnmount as
|
|
3
|
-
import { useI18n as
|
|
4
|
-
import { newCommsClient as
|
|
5
|
-
import { concat as
|
|
6
|
-
function
|
|
7
|
-
const n =
|
|
1
|
+
import { useColorMode as L, objectPick as M, objectOmit as w, useMagicKeys as O, whenever as S, watchDebounced as I, useAsyncState as E } from "@vueuse/core";
|
|
2
|
+
import { computed as u, watch as h, ref as d, onBeforeUnmount as U, onMounted as D, onUnmounted as H, readonly as W, inject as z } from "vue";
|
|
3
|
+
import { useI18n as B } from "vue-i18n";
|
|
4
|
+
import { newCommsClient as K, newCommsHost as R } from "@antcde/connect-ts";
|
|
5
|
+
import { concat as T, Subject as G, concatMap as j, map as x, distinctUntilChanged as V, debounceTime as q, BehaviorSubject as C, filter as F } from "rxjs";
|
|
6
|
+
function se(s, o) {
|
|
7
|
+
const n = L(o), e = u(() => s.context.value.darkMode), t = u(() => {
|
|
8
8
|
switch (e.value) {
|
|
9
9
|
case null:
|
|
10
10
|
return "auto";
|
|
@@ -16,7 +16,7 @@ function te(t, o) {
|
|
|
16
16
|
return n.value;
|
|
17
17
|
}
|
|
18
18
|
}), r = u(() => {
|
|
19
|
-
switch (
|
|
19
|
+
switch (t.value) {
|
|
20
20
|
case "light":
|
|
21
21
|
case "auto":
|
|
22
22
|
return !1;
|
|
@@ -25,158 +25,161 @@ function te(t, o) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
return Object.assign(
|
|
28
|
-
|
|
28
|
+
t,
|
|
29
29
|
{ host: e, isDark: r },
|
|
30
|
-
|
|
30
|
+
M(n, ["state", "system", "store"])
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const n =
|
|
33
|
+
function ne(s, o) {
|
|
34
|
+
const n = B(o);
|
|
35
35
|
return h(
|
|
36
|
-
() =>
|
|
36
|
+
() => s.context.value.user?.language,
|
|
37
37
|
(e) => n.locale.value = e ?? "en",
|
|
38
38
|
{ immediate: !0 }
|
|
39
39
|
), n;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
get: () =>
|
|
44
|
-
set: (i) =>
|
|
41
|
+
function J(s, o, n) {
|
|
42
|
+
const e = d({}), t = K({ parent: window.parent, connect: s, manifest: n }), r = d(""), l = u({
|
|
43
|
+
get: () => r.value,
|
|
44
|
+
set: (i) => t.appState.set(i)
|
|
45
45
|
});
|
|
46
|
-
return
|
|
47
|
-
|
|
46
|
+
return t.context.subscribe((i) => e.value = i), T(t.appState.get(), t.appState).subscribe((i) => r.value = i), Q(t.signal, t, o), U(() => t.unsubscribe()), Object.assign(
|
|
47
|
+
w(t, ["context", "toolbar", "appState"]),
|
|
48
48
|
{
|
|
49
|
-
context:
|
|
50
|
-
toolbar:
|
|
51
|
-
appState:
|
|
49
|
+
context: e,
|
|
50
|
+
toolbar: N(t),
|
|
51
|
+
appState: l
|
|
52
52
|
}
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function N(s) {
|
|
56
56
|
const o = d(""), n = {
|
|
57
57
|
title: u({
|
|
58
|
-
get: () =>
|
|
59
|
-
set: (e) =>
|
|
58
|
+
get: () => s.toolbar.get().title,
|
|
59
|
+
set: (e) => s.toolbar.set((t) => ({ ...t, title: e }))
|
|
60
60
|
}),
|
|
61
61
|
subtitle: u({
|
|
62
|
-
get: () =>
|
|
63
|
-
set: (e) =>
|
|
62
|
+
get: () => s.toolbar.get().subtitle,
|
|
63
|
+
set: (e) => s.toolbar.set((t) => ({ ...t, subtitle: e }))
|
|
64
64
|
}),
|
|
65
65
|
searchEnabled: u({
|
|
66
|
-
get: () =>
|
|
67
|
-
set: (e) =>
|
|
66
|
+
get: () => s.toolbar.get().search.enabled,
|
|
67
|
+
set: (e) => s.toolbar.set((t) => ({ ...t, search: { ...t.search, enabled: e } }))
|
|
68
68
|
}),
|
|
69
69
|
search: u({
|
|
70
70
|
get: () => o.value,
|
|
71
|
-
set: (e) =>
|
|
71
|
+
set: (e) => s.toolbar.set((t) => ({ ...t, search: { ...t.search, input: e } }))
|
|
72
72
|
}),
|
|
73
73
|
menu: u({
|
|
74
|
-
get: () =>
|
|
75
|
-
set: (e) =>
|
|
74
|
+
get: () => s.toolbar.get().menu ?? [],
|
|
75
|
+
set: (e) => s.toolbar.set((t) => ({ ...t, menu: e }))
|
|
76
76
|
}),
|
|
77
77
|
isLoading: u({
|
|
78
|
-
get: () =>
|
|
79
|
-
set: (e) =>
|
|
78
|
+
get: () => s.toolbar.get().isLoading,
|
|
79
|
+
set: (e) => s.toolbar.set((t) => ({ ...t, isLoading: e }))
|
|
80
80
|
})
|
|
81
81
|
};
|
|
82
|
-
return
|
|
82
|
+
return s.toolbar.pipe(x((e) => e.search.input ?? ""), V(), q(300)).forEach((e) => o.value = e), n;
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
const e =
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
function Q(s, o, n) {
|
|
85
|
+
const e = O(), t = e.ctrl ?? u(() => !1), r = e.shift ?? u(() => !1), l = new G(), i = l.pipe(
|
|
86
|
+
j(n ?? ((c) => Promise.resolve(c))),
|
|
87
|
+
j((c) => s(c))
|
|
88
88
|
).subscribe();
|
|
89
|
-
return o.add(
|
|
89
|
+
return o.add(i), i.add(S(t, () => l.next({ hotkeys: { ctrl: !0 } }))), i.add(S(r, () => l.next({ hotkeys: { shift: !0 } }))), i;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const { context: o } =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
), c =
|
|
91
|
+
function oe(s) {
|
|
92
|
+
const { context: o } = s, n = new C({}), e = (a) => n.next(a(n.value)), t = d(), r = new C(void 0), l = h(t, (a) => r.next(a), { immediate: !0 }), i = r.asObservable().pipe(
|
|
93
|
+
x((a) => a?.contentWindow),
|
|
94
|
+
F((a) => !!a)
|
|
95
|
+
), c = R({ ...s, contextChanges: n, windowChanges: i });
|
|
96
96
|
Object.entries(o).map(([a, b]) => h(
|
|
97
97
|
b,
|
|
98
|
-
(
|
|
98
|
+
(k) => e((P) => ({ ...P, [a]: k })),
|
|
99
99
|
{ immediate: !0 }
|
|
100
100
|
)).forEach((a) => c.scope.add(a)), c.toolbar.subscribe((a) => {
|
|
101
|
-
const b =
|
|
101
|
+
const b = s.toolbar;
|
|
102
102
|
b.title.value = a.title, b.subtitle.value = a.subtitle, b.searchEnabled.value = a.search?.enabled ?? !1, b.search.value = a.search?.input, b.menu.value = a.menu, b.isLoading.value = a?.isLoading ?? !1;
|
|
103
103
|
});
|
|
104
|
-
const
|
|
105
|
-
|
|
104
|
+
const p = I(
|
|
105
|
+
s.toolbar.search,
|
|
106
106
|
(a) => c.toolbar.set.search(a),
|
|
107
107
|
{ immediate: !0, debounce: 100 }
|
|
108
108
|
);
|
|
109
|
-
c.scope.add(
|
|
110
|
-
const
|
|
111
|
-
get: () =>
|
|
109
|
+
c.scope.add(l), c.scope.add(p);
|
|
110
|
+
const f = d(c.appState.get()), m = u({
|
|
111
|
+
get: () => f.value,
|
|
112
112
|
set: (a) => c.appState.set(a)
|
|
113
113
|
});
|
|
114
|
-
c.appState.changes.subscribe((a) =>
|
|
114
|
+
c.appState.changes.subscribe((a) => f.value = a);
|
|
115
115
|
const v = d(!1);
|
|
116
116
|
c.isConnectionInitialized.subscribe((a) => v.value = a);
|
|
117
|
-
const
|
|
117
|
+
const g = d(null);
|
|
118
|
+
c.manifest?.subscribe((a) => g.value = a);
|
|
119
|
+
const { unsubscribe: y, signal: _, closed: A } = c;
|
|
118
120
|
return {
|
|
119
|
-
...
|
|
120
|
-
client:
|
|
121
|
-
appState:
|
|
121
|
+
...s,
|
|
122
|
+
client: t,
|
|
123
|
+
appState: m,
|
|
122
124
|
isConnectionInitialized: v,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
manifest: g,
|
|
126
|
+
unsubscribe: y,
|
|
127
|
+
signal: _,
|
|
128
|
+
closed: A
|
|
126
129
|
};
|
|
127
130
|
}
|
|
128
|
-
function
|
|
129
|
-
const o = u(() =>
|
|
130
|
-
function m
|
|
131
|
-
return !o.value || !n.value ? !1 :
|
|
131
|
+
function ae(s) {
|
|
132
|
+
const o = u(() => s.value?.user), n = u(() => s.value?.license), e = u(() => s.value?.project), t = u(() => !!o.value?.is_admin), r = u(() => !!n.value?.user_is_admin), l = u(() => !!e.value?.user_is_admin);
|
|
133
|
+
function i(m) {
|
|
134
|
+
return !o.value || !n.value ? !1 : t.value || r.value ? !0 : (n.value.user_roles ?? []).some((v) => v.name === m);
|
|
132
135
|
}
|
|
133
|
-
function c(
|
|
134
|
-
return !o.value || !n.value ? !1 :
|
|
136
|
+
function c(m) {
|
|
137
|
+
return !o.value || !n.value ? !1 : t.value || r.value ? !0 : !!n.value.user_permissions?.[String(m)];
|
|
135
138
|
}
|
|
136
|
-
function
|
|
137
|
-
return !o.value || !e.value ? !1 :
|
|
139
|
+
function p(m) {
|
|
140
|
+
return !o.value || !e.value ? !1 : t.value || r.value || l.value ? !0 : (e.value.user_roles ?? []).some((v) => v.name === m);
|
|
138
141
|
}
|
|
139
|
-
function
|
|
140
|
-
return !o.value || !e.value ? !1 :
|
|
142
|
+
function f(m) {
|
|
143
|
+
return !o.value || !e.value ? !1 : t.value || r.value ? !0 : !!e.value.user_permissions?.[String(m)];
|
|
141
144
|
}
|
|
142
|
-
return { isGlobalAdmin:
|
|
145
|
+
return { isGlobalAdmin: t, isLicenseAdmin: r, isProjectAdmin: l, hasLicenseRole: i, hasLicensePermission: c, hasProjectRole: p, hasProjectPermission: f };
|
|
143
146
|
}
|
|
144
|
-
function
|
|
145
|
-
const [o, n] =
|
|
146
|
-
|
|
147
|
-
() =>
|
|
147
|
+
function re(s = "comms") {
|
|
148
|
+
const [o, n] = X(
|
|
149
|
+
s,
|
|
150
|
+
() => J(),
|
|
148
151
|
(e) => e.unsubscribe()
|
|
149
152
|
);
|
|
150
153
|
return { provideComms: o, injectComms: n };
|
|
151
154
|
}
|
|
152
|
-
function
|
|
155
|
+
function X(s, o, n) {
|
|
153
156
|
let e;
|
|
154
|
-
const
|
|
157
|
+
const t = () => (!e && (e = o()), e);
|
|
155
158
|
return [
|
|
156
|
-
(r) => (r.onUnmount(() => n && e && n(e)), r.provide(
|
|
157
|
-
() =>
|
|
159
|
+
(r) => (r.onUnmount(() => n && e && n(e)), r.provide(s, t)),
|
|
160
|
+
() => z(s)()
|
|
158
161
|
];
|
|
159
162
|
}
|
|
160
|
-
function
|
|
161
|
-
const
|
|
162
|
-
return Object.assign(
|
|
163
|
-
execute: (...r) =>
|
|
164
|
-
executeDelayed:
|
|
163
|
+
function ue(s, o, n) {
|
|
164
|
+
const t = E(s, o, { immediate: !1, ...n });
|
|
165
|
+
return Object.assign(w(t, ["execute"]), {
|
|
166
|
+
execute: (...r) => t.execute(void 0, ...r),
|
|
167
|
+
executeDelayed: t.execute
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
|
-
function
|
|
170
|
+
function ce(s) {
|
|
168
171
|
let o;
|
|
169
172
|
const n = d(void 0);
|
|
170
|
-
return
|
|
173
|
+
return D(() => o = s.signal.receive((e) => n.value = e)), H(() => o?.()), [W(n), () => o?.()];
|
|
171
174
|
}
|
|
172
175
|
export {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
se as useAntColorMode,
|
|
177
|
+
ne as useAntI18n,
|
|
178
|
+
ue as useApi,
|
|
179
|
+
J as useCommsClient,
|
|
180
|
+
oe as useCommsHost,
|
|
181
|
+
re as useCommsInjection,
|
|
182
|
+
ae as usePermissions,
|
|
183
|
+
ce as useSignal,
|
|
184
|
+
X as useSingleton
|
|
182
185
|
};
|
|
@@ -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;
|
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.13-rc.0c67d53",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"vue-i18n": "^11.1.12"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@antcde/connect-ts": "
|
|
34
|
+
"@antcde/connect-ts": "0.4.17-rc.0c67d53"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tsconfig/node22": "^22.0.
|
|
38
|
-
"@types/node": "^22.
|
|
39
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
37
|
+
"@tsconfig/node22": "^22.0.5",
|
|
38
|
+
"@types/node": "^22.19.17",
|
|
39
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
40
40
|
"@vue/tsconfig": "^0.8.1",
|
|
41
41
|
"typescript": "~5.9.3",
|
|
42
|
-
"vite": "^7.
|
|
42
|
+
"vite": "^7.3.2",
|
|
43
43
|
"vite-plugin-dts": "^4.5.4",
|
|
44
|
-
"vue-tsc": "^3.
|
|
44
|
+
"vue-tsc": "^3.2.6"
|
|
45
45
|
}
|
|
46
46
|
}
|