@tb-dev/vue 0.1.1 → 0.1.3
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.
|
@@ -13,3 +13,5 @@ export type OnKeyDownOptions = Omit<OnKeyStrokeOptions, 'eventName'> & {
|
|
|
13
13
|
export declare function onKeyDown(key: KeyFilter, handler?: KeyDownEventHandler, options?: OnKeyDownOptions): Fn;
|
|
14
14
|
export declare function onAltKeyDown(key: KeyFilter, handler?: KeyDownEventHandler, options?: Omit<OnKeyDownOptions, 'altKey' | 'eventName'>): Fn;
|
|
15
15
|
export declare function onCtrlKeyDown(key: KeyFilter, handler?: KeyDownEventHandler, options?: Omit<OnKeyDownOptions, 'ctrlKey' | 'eventName'>): Fn;
|
|
16
|
+
export declare function onShiftKeyDown(key: KeyFilter, handler?: KeyDownEventHandler, options?: Omit<OnKeyDownOptions, 'eventName' | 'shiftKey'>): Fn;
|
|
17
|
+
export declare function onCtrlShiftKeyDown(key: KeyFilter, handler?: KeyDownEventHandler, options?: Omit<OnKeyDownOptions, 'eventName' | 'ctrlKey' | 'shiftKey'>): Fn;
|
package/dist/index.js
CHANGED
|
@@ -29,13 +29,18 @@ function create() {
|
|
|
29
29
|
function get() {
|
|
30
30
|
return ERROR_HANDLER_FN;
|
|
31
31
|
}
|
|
32
|
-
function set(fn) {
|
|
32
|
+
function set(fn, options) {
|
|
33
33
|
ERROR_HANDLER_FN = fn;
|
|
34
|
+
if (options?.app) {
|
|
35
|
+
options.app.config.errorHandler = (err) => {
|
|
36
|
+
handle(err, { rethrow: true });
|
|
37
|
+
};
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
|
-
function handle(err,
|
|
40
|
+
function handle(err, options) {
|
|
36
41
|
if (ERROR_HANDLER_FN) {
|
|
37
42
|
void Promise.try(ERROR_HANDLER_FN, err);
|
|
38
|
-
} else if (rethrow) {
|
|
43
|
+
} else if (options?.rethrow ?? true) {
|
|
39
44
|
throw err;
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -125,6 +130,12 @@ function onAltKeyDown(key, handler, options) {
|
|
|
125
130
|
function onCtrlKeyDown(key, handler, options) {
|
|
126
131
|
return onKeyDown(key, handler, { ...options, ctrlKey: true });
|
|
127
132
|
}
|
|
133
|
+
function onShiftKeyDown(key, handler, options) {
|
|
134
|
+
return onKeyDown(key, handler, { ...options, shiftKey: true });
|
|
135
|
+
}
|
|
136
|
+
function onCtrlShiftKeyDown(key, handler, options) {
|
|
137
|
+
return onKeyDown(key, handler, { ...options, ctrlKey: true, shiftKey: true });
|
|
138
|
+
}
|
|
128
139
|
|
|
129
140
|
function localRef(key, initial, options) {
|
|
130
141
|
const defaultValue = { inner: initial };
|
|
@@ -158,4 +169,4 @@ function maybe(value, fn) {
|
|
|
158
169
|
return isNil(_value) ? null : fn(_value);
|
|
159
170
|
}
|
|
160
171
|
|
|
161
|
-
export { _sfc_main as Link, asyncComputed, asyncRef, getErrorHandler, handleError, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onKeyDown, setErrorHandler, useElementSize, useHeight, useWidth, useWindowHeight, useWindowWidth };
|
|
172
|
+
export { _sfc_main as Link, asyncComputed, asyncRef, getErrorHandler, handleError, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onCtrlShiftKeyDown, onKeyDown, onShiftKeyDown, setErrorHandler, useElementSize, useHeight, useWidth, useWindowHeight, useWindowWidth };
|
package/dist/utils/error.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
1
2
|
import { MaybePromise, Option } from '@tb-dev/utils';
|
|
2
3
|
export type ErrorHandler = (err: unknown) => MaybePromise<void>;
|
|
3
|
-
export
|
|
4
|
+
export interface SetErrorHandlerOptions {
|
|
5
|
+
app?: App;
|
|
6
|
+
}
|
|
7
|
+
export interface HandleErrorOptions {
|
|
8
|
+
rethrow?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const getErrorHandler: () => Option<ErrorHandler>, setErrorHandler: (fn: ErrorHandler, options?: SetErrorHandlerOptions) => void, handleError: (err: unknown, options?: HandleErrorOptions) => void;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './error';
|
|
2
|
+
export * from './maybe';
|