@tb-dev/vue 3.2.2 → 3.2.4

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.
Files changed (2) hide show
  1. package/dist/index.js +20 -39
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import { unwrap, isNil } from "@tb-dev/utils";
2
- import { inject as inject$1, toValue, toRef, ref, readonly, computed, effectScope } from "vue";
3
- import { watchImmediate, useAsyncState, useLocalStorage, tryOnScopeDispose, onKeyStroke, useSessionStorage, computedAsync, useWindowSize, useElementSize as useElementSize$1 } from "@vueuse/core";
4
- import { useWindowSize as useWindowSize2 } from "@vueuse/core";
5
- import { Mutex } from "es-toolkit";
1
+ import { unwrap, isNil } from '@tb-dev/utils';
2
+ import { inject as inject$1, toValue, toRef, ref, readonly, computed, effectScope } from 'vue';
3
+ import { watchImmediate, useAsyncState, useLocalStorage, tryOnScopeDispose, onKeyStroke, useSessionStorage, computedAsync, useWindowSize, useElementSize as useElementSize$1 } from '@vueuse/core';
4
+ export { useWindowSize } from '@vueuse/core';
5
+ import { Mutex } from 'es-toolkit';
6
+
6
7
  function getCurrentApp() {
7
8
  return unwrap(globalThis.__VUEUTILS__.app, "No active app");
8
9
  }
@@ -39,6 +40,7 @@ function tryInjectOrElse(key, fn) {
39
40
  }
40
41
  return value;
41
42
  }
43
+
42
44
  function getErrorHandler() {
43
45
  return globalThis.__VUEUTILS__.errorHandler;
44
46
  }
@@ -62,10 +64,12 @@ function handleError(err, rethrow = true) {
62
64
  throw err;
63
65
  }
64
66
  }
67
+
65
68
  function maybe(value, fn) {
66
69
  const _value = toValue(value);
67
70
  return isNil(_value) ? null : fn(_value);
68
71
  }
72
+
69
73
  const console = {
70
74
  assert,
71
75
  debug,
@@ -98,6 +102,7 @@ function trace(source) {
98
102
  function warn(source) {
99
103
  return watchImmediate(toRef(source), (value) => globalThis.console.warn(value));
100
104
  }
105
+
101
106
  function useMutex(options) {
102
107
  const mutex = new Mutex();
103
108
  const locked = ref(mutex.isLocked);
@@ -130,6 +135,7 @@ function useMutex(options) {
130
135
  lock
131
136
  };
132
137
  }
138
+
133
139
  function asyncRef(initial, fn, options = {}) {
134
140
  const value = useAsyncState(fn, initial, {
135
141
  immediate: options.immediate ?? true,
@@ -149,6 +155,7 @@ function asyncRef(initial, fn, options = {}) {
149
155
  execute
150
156
  };
151
157
  }
158
+
152
159
  function localRef(key, initial, options) {
153
160
  const defaultValue = { inner: initial };
154
161
  const local = useLocalStorage(key, defaultValue, {
@@ -168,6 +175,7 @@ function localRef(key, initial, options) {
168
175
  }
169
176
  });
170
177
  }
178
+
171
179
  function onKeyDown(key, handler, options = {}) {
172
180
  const {
173
181
  altKey = false,
@@ -226,6 +234,7 @@ function onShiftKeyDown(key, handler, options) {
226
234
  function onCtrlShiftKeyDown(key, handler, options) {
227
235
  return onKeyDown(key, handler, { ...options, ctrlKey: true, shiftKey: true });
228
236
  }
237
+
229
238
  function sessionRef(key, initial, options) {
230
239
  const defaultValue = { inner: initial };
231
240
  const session = useSessionStorage(key, defaultValue, {
@@ -245,6 +254,7 @@ function sessionRef(key, initial, options) {
245
254
  }
246
255
  });
247
256
  }
257
+
248
258
  function asyncComputed(initial, callback, options) {
249
259
  const state = computedAsync(callback, initial, {
250
260
  onError: handleError,
@@ -254,12 +264,14 @@ function asyncComputed(initial, callback, options) {
254
264
  });
255
265
  return state;
256
266
  }
267
+
257
268
  function useWindowHeight() {
258
269
  return useWindowSize().height;
259
270
  }
260
271
  function useWindowWidth() {
261
272
  return useWindowSize().width;
262
273
  }
274
+
263
275
  function useElementSize(element) {
264
276
  return useElementSize$1(toRef(element), { height: 0, width: 0 }, { box: "border-box" });
265
277
  }
@@ -279,6 +291,7 @@ function useWidthDiff(element, lhs) {
279
291
  const lhsRef = lhs ? toRef(lhs) : useWindowWidth();
280
292
  return computed(() => lhsRef.value - width.value);
281
293
  }
294
+
282
295
  if (!Object.hasOwn(globalThis, "__VUEUTILS__")) {
283
296
  Object.defineProperty(globalThis, "__VUEUTILS__", {
284
297
  configurable: false,
@@ -287,37 +300,5 @@ if (!Object.hasOwn(globalThis, "__VUEUTILS__")) {
287
300
  value: {}
288
301
  });
289
302
  }
290
- export {
291
- asyncComputed,
292
- asyncRef,
293
- console,
294
- getCurrentApp,
295
- getErrorHandler,
296
- handleError,
297
- inject,
298
- localRef,
299
- maybe,
300
- onAltKeyDown,
301
- onCtrlKeyDown,
302
- onCtrlShiftKeyDown,
303
- onKeyDown,
304
- onShiftKeyDown,
305
- provide,
306
- runWithContext,
307
- sessionRef,
308
- setCurrentApp,
309
- setErrorHandler,
310
- tryGetCurrentApp,
311
- tryInject,
312
- tryInjectOrElse,
313
- trySetCurrentApp,
314
- useElementSize,
315
- useHeight,
316
- useHeightDiff,
317
- useMutex,
318
- useWidth,
319
- useWidthDiff,
320
- useWindowHeight,
321
- useWindowSize2 as useWindowSize,
322
- useWindowWidth
323
- };
303
+
304
+ export { asyncComputed, asyncRef, console, getCurrentApp, getErrorHandler, handleError, inject, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onCtrlShiftKeyDown, onKeyDown, onShiftKeyDown, provide, runWithContext, sessionRef, setCurrentApp, setErrorHandler, tryGetCurrentApp, tryInject, tryInjectOrElse, trySetCurrentApp, useElementSize, useHeight, useHeightDiff, useMutex, useWidth, useWidthDiff, useWindowHeight, useWindowWidth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,20 +24,20 @@
24
24
  "composables"
25
25
  ],
26
26
  "dependencies": {
27
- "@tb-dev/utils": "^7.0.13",
28
- "@vueuse/core": "^13.7.0",
27
+ "@tb-dev/utils": "^7.0.14",
28
+ "@vueuse/core": "^13.9.0",
29
29
  "es-toolkit": "^1.39.10",
30
- "vue": "^3.5.19"
30
+ "vue": "^3.5.21"
31
31
  },
32
32
  "devDependencies": {
33
- "@tb-dev/eslint-config": "^8.0.7",
34
- "@types/node": "^24.3.0",
33
+ "@tb-dev/eslint-config": "^8.0.8",
34
+ "@types/node": "^24.3.1",
35
35
  "eslint": "^9.34.0",
36
36
  "tslib": "^2.8.1",
37
- "typedoc": "^0.28.10",
38
- "typedoc-plugin-mdn-links": "^5.0.8",
37
+ "typedoc": "^0.28.12",
38
+ "typedoc-plugin-mdn-links": "^5.0.9",
39
39
  "typescript": "~5.9.2",
40
- "vite": "^7.1.3",
40
+ "vite": "^7.1.4",
41
41
  "vite-plugin-dts": "^4.5.4"
42
42
  },
43
43
  "files": [