@kong-ui-public/error-boundary 0.0.2-pr.821.0f34df98.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 Kong, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # @kong-ui-public/error-boundary
2
+
3
+ A Vue error boundary component to capture unhandled errors that allows for providing a fallback UI and error callback function via [Vue's `onErrorCaptured` hook](https://vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured).
4
+
5
+ - [Features](#features)
6
+ - [Requirements](#requirements)
7
+ - [Usage](#usage)
8
+ - [Install](#install)
9
+ - [Register](#register)
10
+ - [Slots](#slots)
11
+ - [Props](#props)
12
+
13
+ ## Features
14
+
15
+ - Renderless (by default) Vue component that **captures** uncaught errors from child components and **prevents the error from propagating further**
16
+ - Allows passing in a list of [tags](#tags) to forward along to the [`onError` callback function](#onerror).
17
+ - Allows providing an error callback function (defined inline or during global Vue plugin initialization)
18
+ - Provides a [`fallback` slot](#fallback) to allow a host app to provide an error UI
19
+ - Allows for **nested** `ErrorBoundary` components in the DOM. Any nested `ErrorBoundary` components will inherit the tags of its ancestors
20
+ - See the package `sandbox` for more examples
21
+
22
+ The `ErrorBoundary` component will **always** capture any unhandled errors and prevent them from further propagating. This is essentially saying "this error has been handled and should be ignored." It will prevent any additional `ErrorBoundary` components from receiving the error and prevent additional `errorCaptured` hooks or `app.config.errorHandler` from being invoked for this error.
23
+
24
+ The `ErrorBoundary` component can be used to wrap a single component or an entire tree of children, tagging any errors that are captured in the DOM tree.
25
+
26
+ When nesting `ErrorBoundary` components, the [`tags`](#tags) from any parent `ErrorBoundary` component will be passed down to its children and included in their `ErrorBoundaryCallbackParams`.
27
+
28
+ ```html
29
+ <template>
30
+ <div class="my-page">
31
+ <!-- 1 -->
32
+ <ErrorBoundary :tags="['team-settings']">
33
+ <SettingsComponent />
34
+ <form>
35
+ <!-- 2 -->
36
+ <ErrorBoundary :tags="['team-billing']">
37
+ <BuggyComponent />
38
+ <!-- 3 -->
39
+ <ErrorBoundary :tags="['team-core-ui']">
40
+ <CreditCardComponent />
41
+ <!-- The fallback slot has access to all params -->
42
+ <template #fallback="{ error, context }">
43
+ <div class="fallback-content">
44
+ <p>This component has custom fallback UI; most likely just an icon, etc.</p>
45
+ <p class="error-message">{{ context.componentName }}: {{ error.message }}</p>
46
+ </div>
47
+ </template>
48
+ </ErrorBoundary>
49
+ <ActionButtonsComponent />
50
+ </ErrorBoundary>
51
+ </form>
52
+ </ErrorBoundary>
53
+ </div>
54
+ </template>
55
+ ```
56
+
57
+ Looking at the numbered examples above:
58
+
59
+ 1. `team-settings` will be tagged if any child of this component throws an uncaught error, including the `<SettingsComponent>` all the way down to the `<CreditCardComponent>`
60
+ 2. `team-settings` and `team-billing` will be tagged for anything inside the `<form>` element
61
+ 3. `team-core-ui` will **only** be tagged if the `<CreditCardComponent>` throws an error, as it is the only DOM child of its error boundary.
62
+
63
+ ## Requirements
64
+
65
+ - `vue` must be initialized in the host application
66
+
67
+ ## Usage
68
+
69
+ ### Install
70
+
71
+ Install the package in your host application
72
+
73
+ ```sh
74
+ yarn add @kong-ui-public/error-boundary
75
+ ```
76
+
77
+ ### Register
78
+
79
+ You can register the `ErrorBoundary` component in your app [globally](#global-registration) or [locally](#in-component-registration) in another component.
80
+
81
+ > **Note**: There are no style imports for this package.
82
+
83
+ #### Global Registration
84
+
85
+ When registering the component globally via the default export Vue plugin, you may provide a default [`onError` callback](#onerror) to be used throughout your application for all instances of the `ErrorBoundary` component.
86
+
87
+ You may still override this global callback on individual instances of the component by passing a function to the [`onError` component prop](#onerror). _(This includes providing an empty function to disable the global behavior)_
88
+
89
+ ```typescript
90
+ // Global registration
91
+ import { createApp } from 'vue'
92
+ import ErrorBoundary from '@kong-ui-public/error-boundary' // No style imports needed
93
+ // Datadog package example
94
+ import { datadogRum } from '@datadog/browser-rum'
95
+
96
+ const app = createApp(App)
97
+
98
+ app.use(ErrorBoundary, {
99
+ // Provide a global, default `onError` callback for all ErrorBoundary instances
100
+ onError({ error, context }) {
101
+ // Example of sending errors to Datadog
102
+ datadogRum.addError(error, {
103
+ ui: context,
104
+ })
105
+ },
106
+ })
107
+ ```
108
+
109
+ #### In-Component Registration
110
+
111
+ When registering the component locally, you can provide the `onError` callback as a prop.
112
+
113
+ ```html
114
+ <!-- Local registration -->
115
+ <template>
116
+ <ErrorBoundary
117
+ :on-error="customErrorCallback"
118
+ :tags="myTags"
119
+ >
120
+ <BuggyComponent />
121
+ </ErrorBoundary>
122
+ </template>
123
+
124
+ <script setup lang="ts">
125
+ import { ErrorBoundary } from '@kong-ui-public/error-boundary' // No style imports needed
126
+
127
+ const myTags = ['first-tag', 'another-tag']
128
+ const customErrorCallback = ({ error, context }) => {
129
+ // Do something fancy
130
+ }
131
+ </script>
132
+ ```
133
+
134
+ ### Slots
135
+
136
+ #### `default`
137
+
138
+ The `default` slot should be utilized for your "potentially buggy" Vue component(s). The `default` slot can handle a single child, or an entire tree of child components/elements.
139
+
140
+ #### `fallback`
141
+
142
+ The `fallback` slot can optionally be used to provide a fallback UI should any child component (not already wrapped with another `ErrorBoundary` component) thrown an unhandled error. **The default fallback behavior is to render nothing in the UI.**
143
+
144
+ The `fallback` slot has access to all of the `ErrorBoundaryCallbackParams` as slot props:
145
+
146
+ ```html
147
+ <ErrorBoundary :tags="myTags">
148
+ <BuggyComponent />
149
+ <template #fallback="{ error, context }">
150
+ <!-- Your fallback UI here -->
151
+ </template>
152
+ </ErrorBoundary>
153
+ ```
154
+
155
+ ### Props
156
+
157
+ #### `tags`
158
+
159
+ - type: `String[]`
160
+ - required: `false`
161
+ - default: `[]`
162
+
163
+ A list of strings to "tag" the captured error with that are passed along to the `onError` callback.
164
+
165
+ For example, if you want to provide custom attributes to errors on Datadog, you can pass in an array of strings to add to the logged error's custom attributes.
166
+
167
+ #### `onError`
168
+
169
+ - type: `Function as PropType<(params: ErrorBoundaryCallbackParams) => void>`
170
+ - required: `false`
171
+ - default: `[]`
172
+
173
+ A function to be called from the `ErrorBoundary` component when an error in a child component is captured. Receives params of [ErrorBoundaryCallbackParams](src/types/error-boundary.ts).
174
+
175
+ > **Note**: Providing a callback function via the `onError` prop will take precedence over any callback function defined during global registration. You can also provide an empty function in order to prevent the global callback from being executed.
@@ -0,0 +1,62 @@
1
+ import { defineComponent as p, inject as c, ref as i, computed as y, unref as m, provide as v, onErrorCaptured as g, renderSlot as d } from "vue";
2
+ const E = "kong-ui-error-boundary-on-error", f = "kong-ui-error-boundary-tags", O = /* @__PURE__ */ p({
3
+ __name: "ErrorBoundary",
4
+ props: {
5
+ /**
6
+ * An optional array of strings to pass along to the context
7
+ */
8
+ tags: {
9
+ type: Array,
10
+ required: !1,
11
+ default: () => [],
12
+ // Ensure the value is an object, not a string
13
+ validator: (e) => typeof e == "object"
14
+ },
15
+ /**
16
+ * An optional callback function to execute when an error is captured.
17
+ * This prop will take precedence over a plugin-provided onError callback.
18
+ */
19
+ onError: {
20
+ type: Function,
21
+ required: !1,
22
+ default: void 0
23
+ }
24
+ },
25
+ setup(e) {
26
+ const r = e, u = c(E, r.onError), _ = c(f, []), n = i(), s = y(() => {
27
+ const o = /* @__PURE__ */ new Set();
28
+ for (const t of [...m(_), ...r.tags])
29
+ o.add(t);
30
+ return Array.from(o);
31
+ });
32
+ return v(f, s), g((o, t, a) => {
33
+ var l;
34
+ return n.value = {
35
+ error: o,
36
+ context: {
37
+ componentName: ((l = t == null ? void 0 : t.$options) == null ? void 0 : l.__name) || "",
38
+ info: a,
39
+ source: "ErrorBoundary",
40
+ // The name of this ErrorBoundary component
41
+ tags: s.value
42
+ }
43
+ }, typeof r.onError == "function" ? r.onError(n.value) : typeof u == "function" && u(n.value), !1;
44
+ }), (o, t) => {
45
+ var a;
46
+ return (a = n.value) != null && a.error ? d(o.$slots, "fallback", {
47
+ key: 1,
48
+ context: n.value.context,
49
+ error: n.value.error
50
+ }) : d(o.$slots, "default", { key: 0 });
51
+ };
52
+ }
53
+ }), N = {
54
+ // Customize Vue plugin options as desired
55
+ install: (e, r = {}) => {
56
+ e.component(r.name || "ErrorBoundary", O), e.provide(E, r.onError);
57
+ }
58
+ };
59
+ export {
60
+ O as ErrorBoundary,
61
+ N as default
62
+ };
@@ -0,0 +1 @@
1
+ (function(e,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(e=typeof globalThis<"u"?globalThis:e||self,r(e["kong-ui-public-error-boundary"]={},e.Vue))})(this,function(e,r){"use strict";const s="kong-ui-error-boundary-on-error",l="kong-ui-error-boundary-tags",f=r.defineComponent({__name:"ErrorBoundary",props:{tags:{type:Array,required:!1,default:()=>[],validator:t=>typeof t=="object"},onError:{type:Function,required:!1,default:void 0}},setup(t){const o=t,i=r.inject(s,o.onError),y=r.inject(l,[]),u=r.ref(),c=r.computed(()=>{const n=new Set;for(const a of[...r.unref(y),...o.tags])n.add(a);return Array.from(n)});return r.provide(l,c),r.onErrorCaptured((n,a,d)=>{var p;return u.value={error:n,context:{componentName:((p=a==null?void 0:a.$options)==null?void 0:p.__name)||"",info:d,source:"ErrorBoundary",tags:c.value}},typeof o.onError=="function"?o.onError(u.value):typeof i=="function"&&i(u.value),!1}),(n,a)=>{var d;return(d=u.value)!=null&&d.error?r.renderSlot(n.$slots,"fallback",{key:1,context:u.value.context,error:u.value.error}):r.renderSlot(n.$slots,"default",{key:0})}}}),_={install:(t,o={})=>{t.component(o.name||"ErrorBoundary",f),t.provide(s,o.onError)}};e.ErrorBoundary=f,e.default=_,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,57 @@
1
+ import type { PropType } from 'vue';
2
+ import type { ErrorBoundaryCallbackParams } from '../types';
3
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
4
+ /**
5
+ * An optional array of strings to pass along to the context
6
+ */
7
+ tags: {
8
+ type: PropType<string[]>;
9
+ required: false;
10
+ default: () => never[];
11
+ validator: (value: any) => boolean;
12
+ };
13
+ /**
14
+ * An optional callback function to execute when an error is captured.
15
+ * This prop will take precedence over a plugin-provided onError callback.
16
+ */
17
+ onError: {
18
+ type: PropType<(params: ErrorBoundaryCallbackParams) => void>;
19
+ required: false;
20
+ default: undefined;
21
+ };
22
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
23
+ /**
24
+ * An optional array of strings to pass along to the context
25
+ */
26
+ tags: {
27
+ type: PropType<string[]>;
28
+ required: false;
29
+ default: () => never[];
30
+ validator: (value: any) => boolean;
31
+ };
32
+ /**
33
+ * An optional callback function to execute when an error is captured.
34
+ * This prop will take precedence over a plugin-provided onError callback.
35
+ */
36
+ onError: {
37
+ type: PropType<(params: ErrorBoundaryCallbackParams) => void>;
38
+ required: false;
39
+ default: undefined;
40
+ };
41
+ }>>, {
42
+ tags: string[];
43
+ onError: (params: ErrorBoundaryCallbackParams) => void;
44
+ }, {}>, {
45
+ default?(_: {}): any;
46
+ fallback?(_: {
47
+ context: import("../types").ErrorBoundaryContext;
48
+ error: {};
49
+ }): any;
50
+ }>;
51
+ export default _default;
52
+ type __VLS_WithTemplateSlots<T, S> = T & {
53
+ new (): {
54
+ $slots: S;
55
+ };
56
+ };
57
+ //# sourceMappingURL=ErrorBoundary.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBoundary.vue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA2B,QAAQ,EAAE,MAAM,KAAK,CAAA;AAK5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAA;;IA+EzD;;OAEG;;;;;;;IAQH;;;OAGG;;;;;;;IAbH;;OAEG;;;;;;;IAQH;;;OAGG;;;;;;;;;;;;;;;;AAyEL,wBAA8G;AAE9G,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAClD,MAAM,EAAE,CAAC,CAAC;KACT,CAAA;CAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** The provide/inject injection key used for the Vue plugin option `onError` callback */
2
+ export declare const KONG_UI_ERROR_BOUNDARY_ON_ERROR_INJECTION_KEY = "kong-ui-error-boundary-on-error";
3
+ /** The provide/inject injection key used for injecting tags from parent ErrorBoundary components */
4
+ export declare const KONG_UI_ERROR_BOUNDARY_TAGS_INJECTION_KEY = "kong-ui-error-boundary-tags";
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,eAAO,MAAM,6CAA6C,oCAAoC,CAAA;AAE9F,oGAAoG;AACpG,eAAO,MAAM,yCAAyC,gCAAgC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { App } from 'vue';
2
+ import ErrorBoundary from './components/ErrorBoundary.vue';
3
+ import type { ErrorBoundaryPluginOptions } from './types';
4
+ declare const _default: {
5
+ install: (app: App, options?: ErrorBoundaryPluginOptions) => void;
6
+ };
7
+ export default _default;
8
+ export { ErrorBoundary };
9
+ export * from './types';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,aAAa,MAAM,gCAAgC,CAAA;AAE1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;;mBAKxC,GAAG,YAAW,0BAA0B,KAAQ,IAAI;;AAFrE,wBAMC;AAED,OAAO,EAAE,aAAa,EAAE,CAAA;AAExB,cAAc,SAAS,CAAA"}
@@ -0,0 +1,15 @@
1
+ export interface ErrorBoundaryContext {
2
+ componentName: string;
3
+ info: string;
4
+ source: string;
5
+ tags: string[];
6
+ }
7
+ export interface ErrorBoundaryCallbackParams {
8
+ error: unknown;
9
+ context: ErrorBoundaryContext;
10
+ }
11
+ export interface ErrorBoundaryPluginOptions {
12
+ name?: string;
13
+ onError?: ({ error, context: { componentName, info, source, tags } }: ErrorBoundaryCallbackParams) => void;
14
+ }
15
+ //# sourceMappingURL=error-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../../src/types/error-boundary.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,oBAAoB,CAAA;CAC9B;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,2BAA2B,KAAK,IAAI,CAAA;CAC3G"}
@@ -0,0 +1,2 @@
1
+ export * from './error-boundary';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAA"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@kong-ui-public/error-boundary",
3
+ "version": "0.0.2-pr.821.0f34df98.0",
4
+ "type": "module",
5
+ "main": "./dist/error-boundary.umd.js",
6
+ "module": "./dist/error-boundary.es.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/error-boundary.es.js",
14
+ "require": "./dist/error-boundary.umd.js"
15
+ },
16
+ "./package.json": "./package.json",
17
+ "./dist/*": "./dist/*"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "devDependencies": {
23
+ "@kong/design-tokens": "^1.11.2",
24
+ "vue": "^3.3.4"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/Kong/public-ui-components.git",
29
+ "directory": "packages/core/error-boundary"
30
+ },
31
+ "homepage": "https://github.com/Kong/public-ui-components/tree/main/packages/core/error-boundary",
32
+ "bugs": {
33
+ "url": "https://github.com/Kong/public-ui-components/issues"
34
+ },
35
+ "author": "Kong, Inc.",
36
+ "license": "Apache-2.0",
37
+ "volta": {
38
+ "extends": "../../../package.json"
39
+ },
40
+ "distSizeChecker": {
41
+ "errorLimit": "200KB"
42
+ },
43
+ "peerDependencies": {
44
+ "vue": "^3.3.4"
45
+ },
46
+ "dependencies": {
47
+ "@kong/icons": "^1.7.3"
48
+ },
49
+ "scripts": {
50
+ "dev": "cross-env USE_SANDBOX=true vite",
51
+ "build": "run-s typecheck build:package build:types",
52
+ "build:package": "vite build -m production",
53
+ "build:analyzer": "BUILD_VISUALIZER='core/error-boundary' vite build -m production",
54
+ "build:types": "vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly",
55
+ "preview:package": "vite preview --port 4173",
56
+ "preview": "cross-env USE_SANDBOX=true PREVIEW_SANDBOX=true run-s build:package preview:package",
57
+ "lint": "eslint '**/*.{js,jsx,ts,tsx,vue}' --ignore-path '../../../.eslintignore'",
58
+ "lint:fix": "eslint '**/*.{js,jsx,ts,tsx,vue}' --ignore-path '../../../.eslintignore' --fix",
59
+ "stylelint": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,less,styl,vue}'",
60
+ "stylelint:fix": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,less,styl,vue}' --fix",
61
+ "typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit",
62
+ "test:component": "BABEL_ENV=cypress cross-env FORCE_COLOR=1 cypress run --component -b chrome --spec './src/**/*.cy.ts' --project '../../../.'",
63
+ "test:component:open": "BABEL_ENV=cypress cross-env FORCE_COLOR=1 cypress open --component -b chrome --project '../../../.'",
64
+ "test:unit": "cross-env FORCE_COLOR=1 vitest run",
65
+ "test:unit:open": "cross-env FORCE_COLOR=1 vitest --ui"
66
+ }
67
+ }