@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 CHANGED
@@ -1,10 +1,10 @@
1
- import { useColorMode as P, objectPick as L, objectOmit as C, useMagicKeys as M, whenever as g, watchDebounced as O, useAsyncState as I } from "@vueuse/core";
2
- import { computed as u, watch as h, ref as d, onBeforeUnmount as E, onMounted as U, onUnmounted as D, readonly as H, inject as W } from "vue";
3
- import { useI18n as z } from "vue-i18n";
4
- import { newCommsClient as B, newCommsHost as K } from "@antcde/connect-ts";
5
- import { concat as R, Subject as T, concatMap as S, map as w, distinctUntilChanged as G, debounceTime as V, BehaviorSubject as j, filter as q } from "rxjs";
6
- function te(t, o) {
7
- const n = P(o), e = u(() => t.context.value.darkMode), s = u(() => {
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 (s.value) {
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
- s,
28
+ t,
29
29
  { host: e, isDark: r },
30
- L(n, ["state", "system", "store"])
30
+ M(n, ["state", "system", "store"])
31
31
  );
32
32
  }
33
- function se(t, o) {
34
- const n = z(o);
33
+ function ne(s, o) {
34
+ const n = B(o);
35
35
  return h(
36
- () => t.context.value.user?.language,
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 F(t, o) {
42
- const n = d({}), e = B({ parent: window.parent, connect: t }), s = d(""), r = u({
43
- get: () => s.value,
44
- set: (i) => e.appState.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 e.context.subscribe((i) => n.value = i), R(e.appState.get(), e.appState).subscribe((i) => s.value = i), N(e.signal, e, o), E(() => e.unsubscribe()), Object.assign(
47
- C(e, ["context", "toolbar", "appState"]),
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: n,
50
- toolbar: J(e),
51
- appState: r
49
+ context: e,
50
+ toolbar: N(t),
51
+ appState: l
52
52
  }
53
53
  );
54
54
  }
55
- function J(t) {
55
+ function N(s) {
56
56
  const o = d(""), n = {
57
57
  title: u({
58
- get: () => t.toolbar.get().title,
59
- set: (e) => t.toolbar.set((s) => ({ ...s, title: 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: () => t.toolbar.get().subtitle,
63
- set: (e) => t.toolbar.set((s) => ({ ...s, subtitle: 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: () => t.toolbar.get().search.enabled,
67
- set: (e) => t.toolbar.set((s) => ({ ...s, search: { ...s.search, enabled: 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) => t.toolbar.set((s) => ({ ...s, search: { ...s.search, input: e } }))
71
+ set: (e) => s.toolbar.set((t) => ({ ...t, search: { ...t.search, input: e } }))
72
72
  }),
73
73
  menu: u({
74
- get: () => t.toolbar.get().menu ?? [],
75
- set: (e) => t.toolbar.set((s) => ({ ...s, menu: 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: () => t.toolbar.get().isLoading,
79
- set: (e) => t.toolbar.set((s) => ({ ...s, isLoading: e }))
78
+ get: () => s.toolbar.get().isLoading,
79
+ set: (e) => s.toolbar.set((t) => ({ ...t, isLoading: e }))
80
80
  })
81
81
  };
82
- return t.toolbar.pipe(w((e) => e.search.input ?? ""), G(), V(300)).forEach((e) => o.value = e), n;
82
+ return s.toolbar.pipe(x((e) => e.search.input ?? ""), V(), q(300)).forEach((e) => o.value = e), n;
83
83
  }
84
- function N(t, o, n) {
85
- const e = M(), s = e.ctrl ?? u(() => !1), r = e.shift ?? u(() => !1), i = new T(), m = i.pipe(
86
- S(n ?? ((c) => Promise.resolve(c))),
87
- S((c) => t(c))
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(m), m.add(g(s, () => i.next({ hotkeys: { ctrl: !0 } }))), m.add(g(r, () => i.next({ hotkeys: { shift: !0 } }))), m;
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 ne(t) {
92
- const { context: o } = t, n = new j({}), e = (a) => n.next(a(n.value)), s = d(), r = new j(void 0), i = h(s, (a) => r.next(a), { immediate: !0 }), m = r.asObservable().pipe(
93
- w((a) => a?.contentWindow),
94
- q((a) => !!a)
95
- ), c = K({ ...t, contextChanges: n, windowChanges: m });
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
- (A) => e((k) => ({ ...k, [a]: A })),
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 = t.toolbar;
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 f = O(
105
- t.toolbar.search,
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(i), c.scope.add(f);
110
- const p = d(c.appState.get()), l = u({
111
- get: () => p.value,
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) => p.value = 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 { unsubscribe: x, signal: y, closed: _ } = c;
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
- ...t,
120
- client: s,
121
- appState: l,
121
+ ...s,
122
+ client: t,
123
+ appState: m,
122
124
  isConnectionInitialized: v,
123
- unsubscribe: x,
124
- signal: y,
125
- closed: _
125
+ manifest: g,
126
+ unsubscribe: y,
127
+ signal: _,
128
+ closed: A
126
129
  };
127
130
  }
128
- function oe(t) {
129
- const o = u(() => t.value?.user), n = u(() => t.value?.license), e = u(() => t.value?.project), s = u(() => !!o.value?.is_admin), r = u(() => !!n.value?.user_is_admin), i = u(() => !!e.value?.user_is_admin);
130
- function m(l) {
131
- return !o.value || !n.value ? !1 : s.value || r.value ? !0 : (n.value.user_roles ?? []).some((v) => v.name === l);
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(l) {
134
- return !o.value || !n.value ? !1 : s.value || r.value ? !0 : !!n.value.user_permissions?.[String(l)];
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 f(l) {
137
- return !o.value || !e.value ? !1 : s.value || r.value || i.value ? !0 : (e.value.user_roles ?? []).some((v) => v.name === l);
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 p(l) {
140
- return !o.value || !e.value ? !1 : s.value || r.value ? !0 : !!e.value.user_permissions?.[String(l)];
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: s, isLicenseAdmin: r, isProjectAdmin: i, hasLicenseRole: m, hasLicensePermission: c, hasProjectRole: f, hasProjectPermission: p };
145
+ return { isGlobalAdmin: t, isLicenseAdmin: r, isProjectAdmin: l, hasLicenseRole: i, hasLicensePermission: c, hasProjectRole: p, hasProjectPermission: f };
143
146
  }
144
- function ae(t = "comms") {
145
- const [o, n] = Q(
146
- t,
147
- () => F(),
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 Q(t, o, n) {
155
+ function X(s, o, n) {
153
156
  let e;
154
- const s = () => (!e && (e = o()), e);
157
+ const t = () => (!e && (e = o()), e);
155
158
  return [
156
- (r) => (r.onUnmount(() => n && e && n(e)), r.provide(t, s)),
157
- () => W(t)()
159
+ (r) => (r.onUnmount(() => n && e && n(e)), r.provide(s, t)),
160
+ () => z(s)()
158
161
  ];
159
162
  }
160
- function re(t, o, n) {
161
- const s = I(t, o, { immediate: !1, ...n });
162
- return Object.assign(C(s, ["execute"]), {
163
- execute: (...r) => s.execute(void 0, ...r),
164
- executeDelayed: s.execute
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 ue(t) {
170
+ function ce(s) {
168
171
  let o;
169
172
  const n = d(void 0);
170
- return U(() => o = t.signal.receive((e) => n.value = e)), D(() => o?.()), [H(n), () => o?.()];
173
+ return D(() => o = s.signal.receive((e) => n.value = e)), H(() => o?.()), [W(n), () => o?.()];
171
174
  }
172
175
  export {
173
- te as useAntColorMode,
174
- se as useAntI18n,
175
- re as useApi,
176
- F as useCommsClient,
177
- ne as useCommsHost,
178
- ae as useCommsInjection,
179
- oe as usePermissions,
180
- ue as useSignal,
181
- Q as useSingleton
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.12-rc.64ce643",
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": "workspace:*"
34
+ "@antcde/connect-ts": "0.4.17-rc.0c67d53"
35
35
  },
36
36
  "devDependencies": {
37
- "@tsconfig/node22": "^22.0.2",
38
- "@types/node": "^22.0.0",
39
- "@vitejs/plugin-vue": "^6.0.1",
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.1.10",
42
+ "vite": "^7.3.2",
43
43
  "vite-plugin-dts": "^4.5.4",
44
- "vue-tsc": "^3.1.1"
44
+ "vue-tsc": "^3.2.6"
45
45
  }
46
46
  }