@antcde/vue-utils 0.2.7 → 0.2.11

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,8 +1,8 @@
1
- import { useColorMode as A, objectPick as O, objectOmit as C, useMagicKeys as I, whenever as f, watchDebounced as E, useAsyncState as L } from "@vueuse/core";
2
- import { computed as i, watch as h, ref as b, onBeforeUnmount as w, onMounted as U, onUnmounted as D, readonly as H, inject as z } from "vue";
1
+ import { useColorMode as A, objectPick as O, objectOmit as v, useMagicKeys as I, whenever as h, watchDebounced as E, useAsyncState as L } from "@vueuse/core";
2
+ import { computed as i, watch as d, ref as b, onBeforeUnmount as x, onMounted as U, onUnmounted as D, readonly as H, inject as z } from "vue";
3
3
  import { useI18n as B } from "vue-i18n";
4
4
  import { newCommsClient as K, newCommsHost as P } from "@antcde/connect-ts";
5
- import { concat as T, Subject as _, concatMap as v, map as S, distinctUntilChanged as V, debounceTime as W, tap as q, BehaviorSubject as x, filter as F } from "rxjs";
5
+ import { concat as T, Subject as _, concatMap as g, map as C, distinctUntilChanged as V, debounceTime as W, tap as q, BehaviorSubject as f, filter as F } from "rxjs";
6
6
  function ee(o, s) {
7
7
  const t = A(s), e = i(() => o.context.value.darkMode), a = i(() => {
8
8
  switch (e.value) {
@@ -32,11 +32,8 @@ function ee(o, s) {
32
32
  }
33
33
  function te(o, s) {
34
34
  const t = B(s);
35
- return h(
36
- () => {
37
- var e;
38
- return (e = o.context.value.user) == null ? void 0 : e.language;
39
- },
35
+ return d(
36
+ () => o.context.value.user?.language,
40
37
  (e) => t.locale.value = e ?? "en",
41
38
  { immediate: !0 }
42
39
  ), t;
@@ -46,8 +43,8 @@ function G(o, s) {
46
43
  get: () => a.value,
47
44
  set: (u) => e.appState.set(u)
48
45
  });
49
- return e.context.subscribe((u) => t.value = u), T(e.appState.get(), e.appState).subscribe((u) => a.value = u), N(e.signal, e, s), w(() => e.unsubscribe()), Object.assign(
50
- C(e, ["context", "toolbar", "appState"]),
46
+ return e.context.subscribe((u) => t.value = u), T(e.appState.get(), e.appState).subscribe((u) => a.value = u), N(e.signal, e, s), x(() => e.unsubscribe()), Object.assign(
47
+ v(e, ["context", "toolbar", "appState"]),
51
48
  {
52
49
  context: t,
53
50
  toolbar: J(e),
@@ -75,51 +72,50 @@ function J(o) {
75
72
  set: (t) => o.toolbar.set((e) => ({ ...e, isLoading: t }))
76
73
  })
77
74
  };
78
- return o.toolbar.pipe(S((t) => t.search.input ?? ""), V(), W(300), q(console.log)).forEach((t) => s.search.value = t), s;
75
+ return o.toolbar.pipe(C((t) => t.search.input ?? ""), V(), W(300), q(console.log)).forEach((t) => s.search.value = t), s;
79
76
  }
80
77
  function N(o, s, t) {
81
78
  const e = I(), { ctrl: a, shift: r } = e, u = new _(), c = u.pipe(
82
- v(t ?? ((m) => Promise.resolve(m))),
83
- v((m) => o(m))
79
+ g(t ?? ((m) => Promise.resolve(m))),
80
+ g((m) => o(m))
84
81
  ).subscribe();
85
- return s.add(c), c.add(f(a, () => u.next({ hotkeys: { ctrl: !0 } }))), c.add(f(r, () => u.next({ hotkeys: { shift: !0 } }))), c;
82
+ return s.add(c), c.add(h(a, () => u.next({ hotkeys: { ctrl: !0 } }))), c.add(h(r, () => u.next({ hotkeys: { shift: !0 } }))), c;
86
83
  }
87
84
  function oe(o) {
88
- const { context: s } = o, t = new x({}), e = (n) => t.next(n(t.value)), a = b(), r = new x(void 0);
89
- h(a, (n) => r.next(n), { immediate: !0 });
85
+ const { context: s } = o, t = new f({}), e = (n) => t.next(n(t.value)), a = b(), r = new f(void 0);
86
+ d(a, (n) => r.next(n), { immediate: !0 });
90
87
  const u = r.asObservable().pipe(
91
- S((n) => n == null ? void 0 : n.contentWindow),
88
+ C((n) => n?.contentWindow),
92
89
  F((n) => !!n)
93
90
  ), c = P({ ...o, contextChanges: t, windowChanges: u });
94
- Object.entries(s).map(([n, l]) => h(
91
+ Object.entries(s).map(([n, l]) => d(
95
92
  l,
96
- (d) => e((p) => ({ ...p, [n]: d })),
93
+ (k) => e((M) => ({ ...M, [n]: k })),
97
94
  { immediate: !0 }
98
95
  )).forEach((n) => c.scope.add(n)), c.toolbar.subscribe((n) => {
99
- var d, p;
100
96
  const l = o.toolbar;
101
- l.title.value = n.title, l.searchEnabled.value = ((d = n.search) == null ? void 0 : d.enabled) ?? !1, l.search.value = (p = n.search) == null ? void 0 : p.input, l.menu.value = n.menu, l.isLoading.value = (n == null ? void 0 : n.isLoading) ?? !1;
97
+ l.title.value = n.title, l.searchEnabled.value = n.search?.enabled ?? !1, l.search.value = n.search?.input, l.menu.value = n.menu, l.isLoading.value = n?.isLoading ?? !1;
102
98
  }), E(
103
99
  o.toolbar.search,
104
100
  (n) => c.toolbar.set.search(n),
105
101
  { immediate: !0, debounce: 100 }
106
102
  );
107
- const m = b(c.appState.get()), j = i({
103
+ const m = b(c.appState.get()), w = i({
108
104
  get: () => m.value,
109
105
  set: (n) => c.appState.set(n)
110
106
  });
111
107
  c.appState.changes.subscribe((n) => m.value = n);
112
- const g = b(!1);
113
- c.isConnectionInitialized.subscribe((n) => g.value = n), w(() => c.unsubscribe());
114
- const { unsubscribe: y, signal: k, closed: M } = c;
108
+ const p = b(!1);
109
+ c.isConnectionInitialized.subscribe((n) => p.value = n), x(() => c.unsubscribe());
110
+ const { unsubscribe: S, signal: j, closed: y } = c;
115
111
  return {
116
112
  ...o,
117
113
  client: a,
118
- appState: j,
119
- isConnectionInitialized: g,
120
- unsubscribe: y,
121
- signal: k,
122
- closed: M
114
+ appState: w,
115
+ isConnectionInitialized: p,
116
+ unsubscribe: S,
117
+ signal: j,
118
+ closed: y
123
119
  };
124
120
  }
125
121
  function ne(o = "comms") {
@@ -140,7 +136,7 @@ function Q(o, s, t) {
140
136
  }
141
137
  function se(o, s, t) {
142
138
  const a = L(o, s, { immediate: !1, ...t });
143
- return Object.assign(C(a, ["execute"]), {
139
+ return Object.assign(v(a, ["execute"]), {
144
140
  execute: (...r) => a.execute(void 0, ...r),
145
141
  executeDelayed: a.execute
146
142
  });
@@ -148,7 +144,7 @@ function se(o, s, t) {
148
144
  function ae(o) {
149
145
  let s;
150
146
  const t = b(void 0);
151
- return U(() => s = o.signal.receive((e) => t.value = e)), D(() => s == null ? void 0 : s()), [H(t), () => s == null ? void 0 : s()];
147
+ return U(() => s = o.signal.receive((e) => t.value = e)), D(() => s?.()), [H(t), () => s?.()];
152
148
  }
153
149
  export {
154
150
  ee as useAntColorMode,
@@ -1,7 +1,6 @@
1
1
  import { BasicColorSchema, UseColorModeOptions, UseColorModeReturn } from '@vueuse/core';
2
2
  import { UseCommsClient } from './useCommsClient';
3
3
  import { Ref } from 'vue';
4
-
5
4
  export type UseAntColorModeOptions = UseColorModeOptions<BasicColorSchema>;
6
5
  export type UseAntColorModeReturn = UseColorModeReturn<BasicColorSchema> & {
7
6
  host: Ref<boolean | null | undefined>;
@@ -1,6 +1,5 @@
1
1
  import { Composer, UseI18nOptions } from 'vue-i18n';
2
2
  import { UseCommsClient } from './useCommsClient';
3
-
4
3
  export type UseAntI18nReturn = Composer;
5
4
  /**
6
5
  * Listens to the changing locale received from comms and translations will automatically refresh due to internal watcher.
@@ -1,8 +1,7 @@
1
1
  import { AntConnect, Client, Context, Signal } from '@antcde/connect-ts';
2
2
  import { ObservableInput } from 'rxjs';
3
- import { CommsToolbar } from './utils';
4
3
  import { Ref } from 'vue';
5
-
4
+ import { CommsToolbar } from './utils';
6
5
  export interface UseCommsClient extends Omit<Client, 'context' | 'toolbar' | 'appState'> {
7
6
  context: Ref<Context>;
8
7
  toolbar: CommsToolbar;
@@ -1,8 +1,7 @@
1
- import { AntConnect, License, Notepad, Notification, ProjectShort, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
2
- import { CommsToolbar } from './utils';
1
+ import { AntConnect, Change, ChangeSignal, LabelFilterState, License, Notepad, Notification, ProjectShort, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
3
2
  import { SubscriptionLike } from 'rxjs';
4
3
  import { Ref } from 'vue';
5
-
4
+ import { CommsToolbar } from './utils';
6
5
  type Nullable<T> = NonNullable<T> | null | undefined;
7
6
  export interface CommsHostArgs {
8
7
  connect: AntConnect;
@@ -23,7 +22,9 @@ export interface CommsHostArgs {
23
22
  code: string;
24
23
  }>>;
25
24
  darkMode: Ref<Nullable<boolean>>;
25
+ selectedLabels: Ref<LabelFilterState>;
26
26
  };
27
+ newSignalObserver: <T extends keyof ChangeSignal>(type: T, id: string, actions: Change[], callback: (signal: ChangeSignal) => void) => () => void;
27
28
  }
28
29
  export interface UseCommsHost extends CommsHostArgs, SubscriptionLike {
29
30
  client: Ref<HTMLIFrameElement | null | undefined>;
@@ -2,7 +2,6 @@ import { Signal, ToolbarItem } from '@antcde/connect-ts';
2
2
  import { UseAsyncStateOptions, UseAsyncStateReturn } from '@vueuse/core';
3
3
  import { DeepReadonly, FunctionPlugin, Ref, UnwrapRef, WatchStopHandle } from 'vue';
4
4
  import { UseCommsClient } from './useCommsClient';
5
-
6
5
  type RefObject<T> = {
7
6
  [K in keyof T]: T[K];
8
7
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antcde/vue-utils",
3
3
  "type": "module",
4
- "version": "0.2.7",
4
+ "version": "0.2.11",
5
5
  "description": "Helper to use ANT Comms in Vue 3",
6
6
  "author": "CollaborAll",
7
7
  "repository": {
@@ -26,24 +26,27 @@
26
26
  "dist"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@vueuse/core": "^12.0.0",
29
+ "@vueuse/core": "^13.9.0",
30
30
  "vue": "^3.5.10",
31
- "vue-i18n": "^10.0.1",
31
+ "vue-i18n": "^11.1.12",
32
32
  "rxjs": "^7.0.0"
33
33
  },
34
34
  "dependencies": {
35
- "@antcde/connect-ts": "0.4.9"
35
+ "@antcde/connect-ts": "0.4.14"
36
36
  },
37
37
  "devDependencies": {
38
- "@vitejs/plugin-vue": "^5.0.3",
39
- "@vue/tsconfig": "^0.5.1",
38
+ "@vitejs/plugin-vue": "^6.0.1",
39
+ "@vue/tsconfig": "^0.8.1",
40
40
  "typescript": "~5.3.3",
41
- "vite": "^5.0.11",
42
- "vite-plugin-dts": "^3.7.0",
43
- "vue-tsc": "^1.8.27"
41
+ "vite": "^7.1.10",
42
+ "vite-plugin-dts": "^4.5.4",
43
+ "vue-tsc": "^3.1.1",
44
+ "@tsconfig/node22": "^22.0.2",
45
+ "@types/node": "^22.0.0"
44
46
  },
45
47
  "scripts": {
46
48
  "build": "pnpm clean && vite build",
49
+ "build:watch": "vite build --watch",
47
50
  "type-check": "vue-tsc --noEmit",
48
51
  "clean": "pnpm dlx rimraf dist"
49
52
  }