@tb-dev/vue 4.0.13 → 4.0.15
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 +37 -37
- package/package.json +6 -6
- package/dist/{composables → src/composables}/asyncComputed/index.d.ts +0 -0
- package/dist/{composables → src/composables}/asyncRef/index.d.ts +0 -0
- package/dist/{composables → src/composables}/console/index.d.ts +0 -0
- package/dist/{composables → src/composables}/index.d.ts +2 -2
- package/dist/{composables → src/composables}/localRef/index.d.ts +0 -0
- package/dist/{composables → src/composables}/onKeyDown/index.d.ts +0 -0
- package/dist/{composables → src/composables}/sessionRef/index.d.ts +0 -0
- package/dist/{composables → src/composables}/useBreakpoints/index.d.ts +0 -0
- package/dist/{composables → src/composables}/useElementSize/index.d.ts +0 -0
- package/dist/{composables → src/composables}/useMutex/index.d.ts +0 -0
- package/dist/{composables → src/composables}/useWindowSize/index.d.ts +0 -0
- package/dist/{index.d.ts → src/index.d.ts} +0 -0
- package/dist/{types → src/types}/index.d.ts +0 -0
- package/dist/{types → src/types}/ref.d.ts +1 -1
- /package/dist/{types → src/types}/symbol.d.ts +0 -0
- /package/dist/{utils → src/utils}/app.d.ts +0 -0
- /package/dist/{utils → src/utils}/error.d.ts +0 -0
- /package/dist/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/maybe.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -97,35 +97,6 @@ function warn(source) {
|
|
|
97
97
|
return watchImmediate(toRef(source), (value) => globalThis.console.warn(value));
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
|
-
//#region src/composables/useMutex/index.ts
|
|
101
|
-
function useMutex(options) {
|
|
102
|
-
const mutex = new Mutex();
|
|
103
|
-
const locked = ref(mutex.isLocked);
|
|
104
|
-
let onError;
|
|
105
|
-
if (typeof options?.onError === "function") onError = options.onError;
|
|
106
|
-
else if (options?.onError !== false) onError = handleError;
|
|
107
|
-
async function acquire() {
|
|
108
|
-
await mutex.acquire();
|
|
109
|
-
locked.value = mutex.isLocked;
|
|
110
|
-
}
|
|
111
|
-
function release() {
|
|
112
|
-
mutex.release();
|
|
113
|
-
locked.value = mutex.isLocked;
|
|
114
|
-
}
|
|
115
|
-
function lock(fn) {
|
|
116
|
-
const { resolve, reject, promise } = Promise.withResolvers();
|
|
117
|
-
acquire().then(() => fn()).then((value) => resolve(value)).catch(reject).finally(release);
|
|
118
|
-
if (onError) return promise.catch(onError);
|
|
119
|
-
return promise;
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
locked: readonly(locked),
|
|
123
|
-
acquire,
|
|
124
|
-
release,
|
|
125
|
-
lock
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
100
|
//#region src/composables/asyncRef/index.ts
|
|
130
101
|
function asyncRef(initial, fn, options = {}) {
|
|
131
102
|
const value = useAsyncState(fn, initial, {
|
|
@@ -164,6 +135,35 @@ function localRef(key, initial, options) {
|
|
|
164
135
|
});
|
|
165
136
|
}
|
|
166
137
|
//#endregion
|
|
138
|
+
//#region src/composables/useMutex/index.ts
|
|
139
|
+
function useMutex(options) {
|
|
140
|
+
const mutex = new Mutex();
|
|
141
|
+
const locked = ref(mutex.isLocked);
|
|
142
|
+
let onError;
|
|
143
|
+
if (typeof options?.onError === "function") onError = options.onError;
|
|
144
|
+
else if (options?.onError !== false) onError = handleError;
|
|
145
|
+
async function acquire() {
|
|
146
|
+
await mutex.acquire();
|
|
147
|
+
locked.value = mutex.isLocked;
|
|
148
|
+
}
|
|
149
|
+
function release() {
|
|
150
|
+
mutex.release();
|
|
151
|
+
locked.value = mutex.isLocked;
|
|
152
|
+
}
|
|
153
|
+
function lock(fn) {
|
|
154
|
+
const { resolve, reject, promise } = Promise.withResolvers();
|
|
155
|
+
acquire().then(() => fn()).then((value) => resolve(value)).catch(reject).finally(release);
|
|
156
|
+
if (onError) return promise.catch(onError);
|
|
157
|
+
return promise;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
locked: readonly(locked),
|
|
161
|
+
acquire,
|
|
162
|
+
release,
|
|
163
|
+
lock
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
167
|
//#region src/composables/onKeyDown/index.ts
|
|
168
168
|
function onKeyDown(key, handler, options = {}) {
|
|
169
169
|
const { altKey = false, ctrlKey = false, dedupe = true, detached = false, enabled = true, metaKey = false, prevent = true, shiftKey = false, stopPropagation = false } = options;
|
|
@@ -249,6 +249,14 @@ function useWindowWidth() {
|
|
|
249
249
|
return useWindowSize().width;
|
|
250
250
|
}
|
|
251
251
|
//#endregion
|
|
252
|
+
//#region src/composables/useBreakpoints/index.ts
|
|
253
|
+
var breakpointsKey = Symbol();
|
|
254
|
+
function useBreakpoints() {
|
|
255
|
+
return tryInjectOrElse(breakpointsKey, () => {
|
|
256
|
+
return useBreakpoints$1(breakpointsTailwind);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
252
260
|
//#region src/composables/useElementSize/index.ts
|
|
253
261
|
function useElementSize(element) {
|
|
254
262
|
return useElementSize$1(toRef(element), {
|
|
@@ -273,14 +281,6 @@ function useWidthDiff(element, lhs) {
|
|
|
273
281
|
return computed(() => lhsRef.value - width.value);
|
|
274
282
|
}
|
|
275
283
|
//#endregion
|
|
276
|
-
//#region src/composables/useBreakpoints/index.ts
|
|
277
|
-
var breakpointsKey = Symbol();
|
|
278
|
-
function useBreakpoints() {
|
|
279
|
-
return tryInjectOrElse(breakpointsKey, () => {
|
|
280
|
-
return useBreakpoints$1(breakpointsTailwind);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
//#endregion
|
|
284
284
|
//#region src/index.ts
|
|
285
285
|
if (!Object.hasOwn(globalThis, "__VUEUTILS__")) Object.defineProperty(globalThis, "__VUEUTILS__", {
|
|
286
286
|
configurable: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/vue",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.15",
|
|
4
4
|
"description": "Vue utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"composables"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tb-dev/utils": "^7.3.
|
|
27
|
+
"@tb-dev/utils": "^7.3.13",
|
|
28
28
|
"@vueuse/core": "^14.2.1",
|
|
29
29
|
"es-toolkit": "^1.45.1",
|
|
30
30
|
"vue": "^3.5.31"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tb-dev/eslint-config": "^9.1.
|
|
33
|
+
"@tb-dev/eslint-config": "^9.1.2",
|
|
34
34
|
"@types/node": "^25.5.0",
|
|
35
35
|
"eslint": "^10.1.0",
|
|
36
36
|
"tslib": "^2.8.1",
|
|
37
37
|
"typedoc": "^0.28.18",
|
|
38
38
|
"typedoc-plugin-mdn-links": "^5.1.1",
|
|
39
|
-
"typescript": "~
|
|
39
|
+
"typescript": "~6.0.2",
|
|
40
40
|
"vite": "^8.0.3",
|
|
41
41
|
"vite-plugin-dts": "^4.5.4"
|
|
42
42
|
},
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dist"
|
|
45
45
|
],
|
|
46
46
|
"main": "./dist/index.js",
|
|
47
|
-
"types": "./dist/index.d.ts",
|
|
47
|
+
"types": "./dist/src/index.d.ts",
|
|
48
48
|
"exports": {
|
|
49
49
|
".": {
|
|
50
|
-
"types": "./dist/index.d.ts",
|
|
50
|
+
"types": "./dist/src/index.d.ts",
|
|
51
51
|
"import": "./dist/index.js"
|
|
52
52
|
}
|
|
53
53
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './console';
|
|
2
|
-
export * from './useMutex';
|
|
3
2
|
export * from './asyncRef';
|
|
4
3
|
export * from './localRef';
|
|
4
|
+
export * from './useMutex';
|
|
5
5
|
export * from './onKeyDown';
|
|
6
6
|
export * from './sessionRef';
|
|
7
7
|
export * from './asyncComputed';
|
|
8
8
|
export * from './useWindowSize';
|
|
9
|
-
export * from './useElementSize';
|
|
10
9
|
export * from './useBreakpoints';
|
|
10
|
+
export * from './useElementSize';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|