@tb-dev/vue 0.1.0 → 0.1.2

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
@@ -29,12 +29,19 @@ 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);
43
+ } else if (options?.rethrow ?? true) {
44
+ throw err;
38
45
  }
39
46
  }
40
47
  return { get, set, handle };
@@ -113,8 +120,6 @@ function onKeyDown(key, handler, options = {}) {
113
120
  stop = scope.run(() => on());
114
121
  } else {
115
122
  stop = on();
116
- }
117
- if (!detached) {
118
123
  tryOnScopeDispose(() => stop());
119
124
  }
120
125
  return stop;
@@ -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 declare const getErrorHandler: () => Option<ErrorHandler>, setErrorHandler: (fn: ErrorHandler) => void, handleError: (err: unknown) => void;
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;
@@ -1,2 +1,2 @@
1
- export { maybe } from './maybe';
2
- export { type ErrorHandler, getErrorHandler, handleError, setErrorHandler } from './error';
1
+ export * from './error';
2
+ export * from './maybe';
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "private": false,
8
- "packageManager": "pnpm@10.7.0",
9
8
  "funding": "https://github.com/sponsors/ferreira-tb",
10
9
  "author": {
11
10
  "name": "Andrew Ferreira",
@@ -14,7 +13,7 @@
14
13
  },
15
14
  "repository": {
16
15
  "type": "git",
17
- "url": "https://github.com/ferreira-tb/vue-utils.git"
16
+ "url": "git+https://github.com/ferreira-tb/vue-utils.git"
18
17
  },
19
18
  "bugs": {
20
19
  "url": "https://github.com/ferreira-tb/vue-utils/issues"
@@ -25,12 +24,6 @@
25
24
  "components",
26
25
  "composables"
27
26
  ],
28
- "scripts": {
29
- "build": "vite build",
30
- "format": "prettier . --write",
31
- "lint": "eslint . --config eslint.config.js",
32
- "type-check": "vue-tsc --noEmit"
33
- },
34
27
  "dependencies": {
35
28
  "@tb-dev/utils": "^5.1.4",
36
29
  "@vueuse/core": "^13.0.0",
@@ -64,5 +57,12 @@
64
57
  "types": "./dist/index.d.ts",
65
58
  "import": "./dist/index.js"
66
59
  }
60
+ },
61
+ "scripts": {
62
+ "build": "vite build",
63
+ "format": "prettier . --write",
64
+ "lint": "eslint . --config eslint.config.js",
65
+ "release": "pnpm run build && pnpm publish",
66
+ "type-check": "vue-tsc --noEmit"
67
67
  }
68
- }
68
+ }