@omerdlw/base-framework 1.0.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 +21 -0
- package/README.md +117 -0
- package/dist/atoms/button.d.ts +11 -0
- package/dist/atoms/button.d.ts.map +1 -0
- package/dist/atoms/icon.d.ts +15 -0
- package/dist/atoms/icon.d.ts.map +1 -0
- package/dist/atoms/index.d.ts +6 -0
- package/dist/atoms/index.d.ts.map +1 -0
- package/dist/atoms/index.js +169 -0
- package/dist/atoms/index.js.map +1 -0
- package/dist/atoms/spinner.d.ts +9 -0
- package/dist/atoms/spinner.d.ts.map +1 -0
- package/dist/atoms/tooltip.d.ts +18 -0
- package/dist/atoms/tooltip.d.ts.map +1 -0
- package/dist/error/boundary.d.ts +14 -0
- package/dist/error/boundary.d.ts.map +1 -0
- package/dist/error/constants.d.ts +18 -0
- package/dist/error/constants.d.ts.map +1 -0
- package/dist/error/index.d.ts +9 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/index.js +688 -0
- package/dist/error/index.js.map +1 -0
- package/dist/error/listener.d.ts +2 -0
- package/dist/error/listener.d.ts.map +1 -0
- package/dist/error/reporter.d.ts +32 -0
- package/dist/error/reporter.d.ts.map +1 -0
- package/dist/error/theme.d.ts +3 -0
- package/dist/error/theme.d.ts.map +1 -0
- package/dist/error/types.d.ts +91 -0
- package/dist/error/types.d.ts.map +1 -0
- package/dist/error/utils.d.ts +21 -0
- package/dist/error/utils.d.ts.map +1 -0
- package/dist/events.d.ts +51 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +88 -0
- package/dist/events.js.map +1 -0
- package/dist/hooks/index.d.ts +17 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +804 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +58 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/use-async-action.d.ts +3 -0
- package/dist/hooks/use-async-action.d.ts.map +1 -0
- package/dist/hooks/use-click-outside.d.ts +3 -0
- package/dist/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/hooks/use-controllable-state.d.ts +3 -0
- package/dist/hooks/use-controllable-state.d.ts.map +1 -0
- package/dist/hooks/use-debounce.d.ts +2 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-fullscreen-state.d.ts +4 -0
- package/dist/hooks/use-fullscreen-state.d.ts.map +1 -0
- package/dist/hooks/use-global-event.d.ts +7 -0
- package/dist/hooks/use-global-event.d.ts.map +1 -0
- package/dist/hooks/use-hotkey.d.ts +4 -0
- package/dist/hooks/use-hotkey.d.ts.map +1 -0
- package/dist/hooks/use-intersection-observer.d.ts +4 -0
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts.map +1 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-mounted.d.ts +2 -0
- package/dist/hooks/use-mounted.d.ts.map +1 -0
- package/dist/hooks/use-required-context.d.ts +3 -0
- package/dist/hooks/use-required-context.d.ts.map +1 -0
- package/dist/hooks/use-server-action.d.ts +4 -0
- package/dist/hooks/use-server-action.d.ts.map +1 -0
- package/dist/hooks/use-storage-state.d.ts +5 -0
- package/dist/hooks/use-storage-state.d.ts.map +1 -0
- package/dist/hooks/use-store.d.ts +3 -0
- package/dist/hooks/use-store.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20415 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/adapters.d.ts +5 -0
- package/dist/kernel/adapters.d.ts.map +1 -0
- package/dist/kernel/compose.d.ts +15 -0
- package/dist/kernel/compose.d.ts.map +1 -0
- package/dist/kernel/constants.d.ts +12 -0
- package/dist/kernel/constants.d.ts.map +1 -0
- package/dist/kernel/context-registry.d.ts +3 -0
- package/dist/kernel/context-registry.d.ts.map +1 -0
- package/dist/kernel/handlers.d.ts +3 -0
- package/dist/kernel/handlers.d.ts.map +1 -0
- package/dist/kernel/hooks.d.ts +7 -0
- package/dist/kernel/hooks.d.ts.map +1 -0
- package/dist/kernel/index.d.ts +14 -0
- package/dist/kernel/index.d.ts.map +1 -0
- package/dist/kernel/index.js +2109 -0
- package/dist/kernel/index.js.map +1 -0
- package/dist/kernel/installed.d.ts +21 -0
- package/dist/kernel/installed.d.ts.map +1 -0
- package/dist/kernel/module.d.ts +32 -0
- package/dist/kernel/module.d.ts.map +1 -0
- package/dist/kernel/operations.d.ts +21 -0
- package/dist/kernel/operations.d.ts.map +1 -0
- package/dist/kernel/page-controller.d.ts +8 -0
- package/dist/kernel/page-controller.d.ts.map +1 -0
- package/dist/kernel/provider.d.ts +18 -0
- package/dist/kernel/provider.d.ts.map +1 -0
- package/dist/kernel/runtime.d.ts +30 -0
- package/dist/kernel/runtime.d.ts.map +1 -0
- package/dist/kernel/schema.d.ts +13 -0
- package/dist/kernel/schema.d.ts.map +1 -0
- package/dist/kernel/store.d.ts +4 -0
- package/dist/kernel/store.d.ts.map +1 -0
- package/dist/kernel/types.d.ts +233 -0
- package/dist/kernel/types.d.ts.map +1 -0
- package/dist/kernel/utils.d.ts +20 -0
- package/dist/kernel/utils.d.ts.map +1 -0
- package/dist/modules/ambient/constants.d.ts +23 -0
- package/dist/modules/ambient/constants.d.ts.map +1 -0
- package/dist/modules/ambient/context.d.ts +10 -0
- package/dist/modules/ambient/context.d.ts.map +1 -0
- package/dist/modules/ambient/index.d.ts +6 -0
- package/dist/modules/ambient/index.d.ts.map +1 -0
- package/dist/modules/ambient/index.js +896 -0
- package/dist/modules/ambient/index.js.map +1 -0
- package/dist/modules/ambient/module.d.ts +12 -0
- package/dist/modules/ambient/module.d.ts.map +1 -0
- package/dist/modules/ambient/types.d.ts +84 -0
- package/dist/modules/ambient/types.d.ts.map +1 -0
- package/dist/modules/ambient/utils.d.ts +18 -0
- package/dist/modules/ambient/utils.d.ts.map +1 -0
- package/dist/modules/background/constants.d.ts +12 -0
- package/dist/modules/background/constants.d.ts.map +1 -0
- package/dist/modules/background/context.d.ts +13 -0
- package/dist/modules/background/context.d.ts.map +1 -0
- package/dist/modules/background/hooks.d.ts +119 -0
- package/dist/modules/background/hooks.d.ts.map +1 -0
- package/dist/modules/background/index.d.ts +7 -0
- package/dist/modules/background/index.d.ts.map +1 -0
- package/dist/modules/background/index.js +3195 -0
- package/dist/modules/background/index.js.map +1 -0
- package/dist/modules/background/module.d.ts +14 -0
- package/dist/modules/background/module.d.ts.map +1 -0
- package/dist/modules/background/motion.d.ts +13 -0
- package/dist/modules/background/motion.d.ts.map +1 -0
- package/dist/modules/background/overlay.d.ts +49 -0
- package/dist/modules/background/overlay.d.ts.map +1 -0
- package/dist/modules/background/types.d.ts +153 -0
- package/dist/modules/background/types.d.ts.map +1 -0
- package/dist/modules/background/utils.d.ts +56 -0
- package/dist/modules/background/utils.d.ts.map +1 -0
- package/dist/modules/background/youtube/iframe.d.ts +52 -0
- package/dist/modules/background/youtube/iframe.d.ts.map +1 -0
- package/dist/modules/background/youtube/parse.d.ts +17 -0
- package/dist/modules/background/youtube/parse.d.ts.map +1 -0
- package/dist/modules/context-menu/constants.d.ts +8 -0
- package/dist/modules/context-menu/constants.d.ts.map +1 -0
- package/dist/modules/context-menu/context.d.ts +16 -0
- package/dist/modules/context-menu/context.d.ts.map +1 -0
- package/dist/modules/context-menu/hooks.d.ts +31 -0
- package/dist/modules/context-menu/hooks.d.ts.map +1 -0
- package/dist/modules/context-menu/index.d.ts +6 -0
- package/dist/modules/context-menu/index.d.ts.map +1 -0
- package/dist/modules/context-menu/index.js +2008 -0
- package/dist/modules/context-menu/index.js.map +1 -0
- package/dist/modules/context-menu/module.d.ts +12 -0
- package/dist/modules/context-menu/module.d.ts.map +1 -0
- package/dist/modules/context-menu/motion.d.ts +9 -0
- package/dist/modules/context-menu/motion.d.ts.map +1 -0
- package/dist/modules/context-menu/overlay.d.ts +15 -0
- package/dist/modules/context-menu/overlay.d.ts.map +1 -0
- package/dist/modules/context-menu/resolver.d.ts +7 -0
- package/dist/modules/context-menu/resolver.d.ts.map +1 -0
- package/dist/modules/context-menu/state.d.ts +4 -0
- package/dist/modules/context-menu/state.d.ts.map +1 -0
- package/dist/modules/context-menu/types.d.ts +171 -0
- package/dist/modules/context-menu/types.d.ts.map +1 -0
- package/dist/modules/context-menu/utils.d.ts +16 -0
- package/dist/modules/context-menu/utils.d.ts.map +1 -0
- package/dist/modules/controls/constants.d.ts +7 -0
- package/dist/modules/controls/constants.d.ts.map +1 -0
- package/dist/modules/controls/hooks.d.ts +15 -0
- package/dist/modules/controls/hooks.d.ts.map +1 -0
- package/dist/modules/controls/index.d.ts +6 -0
- package/dist/modules/controls/index.d.ts.map +1 -0
- package/dist/modules/controls/index.js +1242 -0
- package/dist/modules/controls/index.js.map +1 -0
- package/dist/modules/controls/module.d.ts +12 -0
- package/dist/modules/controls/module.d.ts.map +1 -0
- package/dist/modules/controls/overlay.d.ts +2 -0
- package/dist/modules/controls/overlay.d.ts.map +1 -0
- package/dist/modules/controls/types.d.ts +86 -0
- package/dist/modules/controls/types.d.ts.map +1 -0
- package/dist/modules/controls/utils.d.ts +9 -0
- package/dist/modules/controls/utils.d.ts.map +1 -0
- package/dist/modules/dock/cards.d.ts +1035 -0
- package/dist/modules/dock/cards.d.ts.map +1 -0
- package/dist/modules/dock/constants.d.ts +157 -0
- package/dist/modules/dock/constants.d.ts.map +1 -0
- package/dist/modules/dock/context.d.ts +26 -0
- package/dist/modules/dock/context.d.ts.map +1 -0
- package/dist/modules/dock/hooks.d.ts +957 -0
- package/dist/modules/dock/hooks.d.ts.map +1 -0
- package/dist/modules/dock/hud.d.ts +43 -0
- package/dist/modules/dock/hud.d.ts.map +1 -0
- package/dist/modules/dock/index.d.ts +27 -0
- package/dist/modules/dock/index.d.ts.map +1 -0
- package/dist/modules/dock/index.js +12111 -0
- package/dist/modules/dock/index.js.map +1 -0
- package/dist/modules/dock/module.d.ts +71 -0
- package/dist/modules/dock/module.d.ts.map +1 -0
- package/dist/modules/dock/motion.d.ts +986 -0
- package/dist/modules/dock/motion.d.ts.map +1 -0
- package/dist/modules/dock/overlay.d.ts +79 -0
- package/dist/modules/dock/overlay.d.ts.map +1 -0
- package/dist/modules/dock/provider.d.ts +3 -0
- package/dist/modules/dock/provider.d.ts.map +1 -0
- package/dist/modules/dock/routing/breadcrumbs.d.ts +43 -0
- package/dist/modules/dock/routing/breadcrumbs.d.ts.map +1 -0
- package/dist/modules/dock/routing/continuity.d.ts +19 -0
- package/dist/modules/dock/routing/continuity.d.ts.map +1 -0
- package/dist/modules/dock/routing/guards.d.ts +21 -0
- package/dist/modules/dock/routing/guards.d.ts.map +1 -0
- package/dist/modules/dock/routing/navigation.d.ts +37 -0
- package/dist/modules/dock/routing/navigation.d.ts.map +1 -0
- package/dist/modules/dock/routing/transactions.d.ts +21 -0
- package/dist/modules/dock/routing/transactions.d.ts.map +1 -0
- package/dist/modules/dock/runtime/commands.d.ts +18 -0
- package/dist/modules/dock/runtime/commands.d.ts.map +1 -0
- package/dist/modules/dock/runtime/display.d.ts +36 -0
- package/dist/modules/dock/runtime/display.d.ts.map +1 -0
- package/dist/modules/dock/runtime/dock.d.ts +123 -0
- package/dist/modules/dock/runtime/dock.d.ts.map +1 -0
- package/dist/modules/dock/state.d.ts +22 -0
- package/dist/modules/dock/state.d.ts.map +1 -0
- package/dist/modules/dock/status/events.d.ts +37 -0
- package/dist/modules/dock/status/events.d.ts.map +1 -0
- package/dist/modules/dock/status/hooks.d.ts +6 -0
- package/dist/modules/dock/status/hooks.d.ts.map +1 -0
- package/dist/modules/dock/status/model.d.ts +65 -0
- package/dist/modules/dock/status/model.d.ts.map +1 -0
- package/dist/modules/dock/surface/context.d.ts +43 -0
- package/dist/modules/dock/surface/context.d.ts.map +1 -0
- package/dist/modules/dock/surface/definition.d.ts +38 -0
- package/dist/modules/dock/surface/definition.d.ts.map +1 -0
- package/dist/modules/dock/surface/hooks.d.ts +123 -0
- package/dist/modules/dock/surface/hooks.d.ts.map +1 -0
- package/dist/modules/dock/surface/machine.d.ts +75 -0
- package/dist/modules/dock/surface/machine.d.ts.map +1 -0
- package/dist/modules/dock/surface/stack.d.ts +38 -0
- package/dist/modules/dock/surface/stack.d.ts.map +1 -0
- package/dist/modules/dock/surface/view-model.d.ts +3 -0
- package/dist/modules/dock/surface/view-model.d.ts.map +1 -0
- package/dist/modules/dock/types.d.ts +1158 -0
- package/dist/modules/dock/types.d.ts.map +1 -0
- package/dist/modules/dock/utils.d.ts +93 -0
- package/dist/modules/dock/utils.d.ts.map +1 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +18020 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/loading/constants.d.ts +5 -0
- package/dist/modules/loading/constants.d.ts.map +1 -0
- package/dist/modules/loading/context.d.ts +13 -0
- package/dist/modules/loading/context.d.ts.map +1 -0
- package/dist/modules/loading/hooks.d.ts +6 -0
- package/dist/modules/loading/hooks.d.ts.map +1 -0
- package/dist/modules/loading/index.d.ts +7 -0
- package/dist/modules/loading/index.d.ts.map +1 -0
- package/dist/modules/loading/index.js +1256 -0
- package/dist/modules/loading/index.js.map +1 -0
- package/dist/modules/loading/module.d.ts +14 -0
- package/dist/modules/loading/module.d.ts.map +1 -0
- package/dist/modules/loading/overlay.d.ts +2 -0
- package/dist/modules/loading/overlay.d.ts.map +1 -0
- package/dist/modules/loading/types.d.ts +47 -0
- package/dist/modules/loading/types.d.ts.map +1 -0
- package/dist/modules/loading/utils.d.ts +4 -0
- package/dist/modules/loading/utils.d.ts.map +1 -0
- package/dist/modules/media/constants.d.ts +7 -0
- package/dist/modules/media/constants.d.ts.map +1 -0
- package/dist/modules/media/context.d.ts +6 -0
- package/dist/modules/media/context.d.ts.map +1 -0
- package/dist/modules/media/hooks.d.ts +3 -0
- package/dist/modules/media/hooks.d.ts.map +1 -0
- package/dist/modules/media/index.d.ts +8 -0
- package/dist/modules/media/index.d.ts.map +1 -0
- package/dist/modules/media/index.js +728 -0
- package/dist/modules/media/index.js.map +1 -0
- package/dist/modules/media/module.d.ts +11 -0
- package/dist/modules/media/module.d.ts.map +1 -0
- package/dist/modules/media/overlay.d.ts +9 -0
- package/dist/modules/media/overlay.d.ts.map +1 -0
- package/dist/modules/media/types.d.ts +77 -0
- package/dist/modules/media/types.d.ts.map +1 -0
- package/dist/modules/media/utils.d.ts +17 -0
- package/dist/modules/media/utils.d.ts.map +1 -0
- package/dist/modules/modal/constants.d.ts +20 -0
- package/dist/modules/modal/constants.d.ts.map +1 -0
- package/dist/modules/modal/context.d.ts +20 -0
- package/dist/modules/modal/context.d.ts.map +1 -0
- package/dist/modules/modal/hooks.d.ts +41 -0
- package/dist/modules/modal/hooks.d.ts.map +1 -0
- package/dist/modules/modal/index.d.ts +7 -0
- package/dist/modules/modal/index.d.ts.map +1 -0
- package/dist/modules/modal/index.js +2672 -0
- package/dist/modules/modal/index.js.map +1 -0
- package/dist/modules/modal/module.d.ts +12 -0
- package/dist/modules/modal/module.d.ts.map +1 -0
- package/dist/modules/modal/motion.d.ts +16 -0
- package/dist/modules/modal/motion.d.ts.map +1 -0
- package/dist/modules/modal/overlay.d.ts +4 -0
- package/dist/modules/modal/overlay.d.ts.map +1 -0
- package/dist/modules/modal/state.d.ts +4 -0
- package/dist/modules/modal/state.d.ts.map +1 -0
- package/dist/modules/modal/types.d.ts +109 -0
- package/dist/modules/modal/types.d.ts.map +1 -0
- package/dist/modules/modal/utils.d.ts +31 -0
- package/dist/modules/modal/utils.d.ts.map +1 -0
- package/dist/modules/notification/constants.d.ts +9 -0
- package/dist/modules/notification/constants.d.ts.map +1 -0
- package/dist/modules/notification/context.d.ts +7 -0
- package/dist/modules/notification/context.d.ts.map +1 -0
- package/dist/modules/notification/hooks.d.ts +10 -0
- package/dist/modules/notification/hooks.d.ts.map +1 -0
- package/dist/modules/notification/index.d.ts +7 -0
- package/dist/modules/notification/index.d.ts.map +1 -0
- package/dist/modules/notification/index.js +905 -0
- package/dist/modules/notification/index.js.map +1 -0
- package/dist/modules/notification/module.d.ts +11 -0
- package/dist/modules/notification/module.d.ts.map +1 -0
- package/dist/modules/notification/motion.d.ts +15 -0
- package/dist/modules/notification/motion.d.ts.map +1 -0
- package/dist/modules/notification/overlay.d.ts +3 -0
- package/dist/modules/notification/overlay.d.ts.map +1 -0
- package/dist/modules/notification/types.d.ts +57 -0
- package/dist/modules/notification/types.d.ts.map +1 -0
- package/dist/modules/notification/utils.d.ts +9 -0
- package/dist/modules/notification/utils.d.ts.map +1 -0
- package/dist/modules/theme.d.ts +3 -0
- package/dist/modules/theme.d.ts.map +1 -0
- package/dist/provider.d.ts +23 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1973 -0
- package/dist/provider.js.map +1 -0
- package/dist/result.d.ts +50 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +163 -0
- package/dist/result.js.map +1 -0
- package/dist/theme.d.ts +25 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +44 -0
- package/dist/theme.js.map +1 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +325 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/motion.d.ts +315 -0
- package/dist/tokens/motion.d.ts.map +1 -0
- package/dist/tokens/tokens.d.ts +34 -0
- package/dist/tokens/tokens.d.ts.map +1 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +5 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +485 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/number.d.ts.map +1 -0
- package/dist/utils/object.d.ts +7 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/report.d.ts +5 -0
- package/dist/utils/report.d.ts.map +1 -0
- package/dist/utils/scheduler.d.ts +34 -0
- package/dist/utils/scheduler.d.ts.map +1 -0
- package/dist/utils/store.d.ts +11 -0
- package/dist/utils/store.d.ts.map +1 -0
- package/dist/utils/string.d.ts +8 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/timing.d.ts +8 -0
- package/dist/utils/timing.d.ts.map +1 -0
- package/dist/utils/user-message.d.ts +20 -0
- package/dist/utils/user-message.d.ts.map +1 -0
- package/package.json +113 -0
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { createContext, useContext, useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { usePathname } from 'next/navigation';
|
|
4
|
+
import { Icon as Icon$1 } from '@iconify-icon/react';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
import '@radix-ui/react-tooltip';
|
|
7
|
+
import 'clsx';
|
|
8
|
+
import 'tailwind-merge';
|
|
9
|
+
|
|
10
|
+
// src/error/constants.ts
|
|
11
|
+
var ERROR_MESSAGES = Object.freeze({
|
|
12
|
+
GLOBAL_TITLE: "Something went wrong",
|
|
13
|
+
GLOBAL_MSG: "We ran into an unexpected problem. Please try again",
|
|
14
|
+
MODULE_TITLE: "Something went wrong",
|
|
15
|
+
MODULE_MSG: "This part of the app isn't working right now. Please try again",
|
|
16
|
+
COMPONENT_MSG: "This section couldn't be loaded. Please try again",
|
|
17
|
+
FALLBACK_TITLE: "Something went wrong",
|
|
18
|
+
FALLBACK_MSG: "This section couldn't be loaded. Please try again"
|
|
19
|
+
});
|
|
20
|
+
var MAX_CONTEXT = 10;
|
|
21
|
+
var MAX_FINGERPRINTS = 100;
|
|
22
|
+
var DEFAULT_DEDUPE_WINDOW = 6e4;
|
|
23
|
+
var ERROR_LISTENER_CONFIG = Object.freeze({
|
|
24
|
+
maxErrors: 10,
|
|
25
|
+
throttle: 2e3,
|
|
26
|
+
ignored: Object.freeze([
|
|
27
|
+
/ResizeObserver loop/i,
|
|
28
|
+
/Network request failed/i,
|
|
29
|
+
/Loading chunk/i,
|
|
30
|
+
/Unexpected end of input/i,
|
|
31
|
+
/Failed to fetch/i,
|
|
32
|
+
/Script error/i,
|
|
33
|
+
/HTTP\s*404/i
|
|
34
|
+
])
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// src/error/utils.ts
|
|
38
|
+
var IS_BROWSER = typeof window !== "undefined";
|
|
39
|
+
var HAS_NAVIGATOR = typeof navigator !== "undefined";
|
|
40
|
+
var getRuntimePath = () => typeof window !== "undefined" ? window.location.pathname : null;
|
|
41
|
+
var getUserAgent = () => typeof navigator !== "undefined" ? navigator.userAgent : null;
|
|
42
|
+
function createErrorContext({
|
|
43
|
+
errorInfo,
|
|
44
|
+
name,
|
|
45
|
+
title,
|
|
46
|
+
variant
|
|
47
|
+
}) {
|
|
48
|
+
return {
|
|
49
|
+
componentStack: errorInfo?.componentStack || null,
|
|
50
|
+
route: getRuntimePath(),
|
|
51
|
+
userAgent: getUserAgent(),
|
|
52
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
53
|
+
name: name || title || "ErrorBoundary",
|
|
54
|
+
variant: variant || "default",
|
|
55
|
+
source: "ErrorBoundary"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function normalizeSampleRate(value) {
|
|
59
|
+
const sampleRate = Number(value);
|
|
60
|
+
return Number.isFinite(sampleRate) ? Math.min(1, Math.max(0, sampleRate)) : 1;
|
|
61
|
+
}
|
|
62
|
+
function normalizeDedupeWindow(value) {
|
|
63
|
+
const dedupeWindow = Number(value);
|
|
64
|
+
return Number.isFinite(dedupeWindow) ? Math.max(0, dedupeWindow) : DEFAULT_DEDUPE_WINDOW;
|
|
65
|
+
}
|
|
66
|
+
function getBrowserEnvironment(route) {
|
|
67
|
+
return {
|
|
68
|
+
route: route || (IS_BROWSER ? window.location.pathname : null),
|
|
69
|
+
userAgent: HAS_NAVIGATOR ? navigator.userAgent : null,
|
|
70
|
+
platform: HAS_NAVIGATOR ? navigator.platform : null,
|
|
71
|
+
language: HAS_NAVIGATOR ? navigator.language : null,
|
|
72
|
+
online: HAS_NAVIGATOR ? navigator.onLine : true,
|
|
73
|
+
url: IS_BROWSER ? window.location.href : null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function fingerprint(error, context = {}) {
|
|
77
|
+
const stackTop = typeof context.componentStack === "string" ? context.componentStack.split("\n").find(Boolean) || "" : "";
|
|
78
|
+
const errObj = error;
|
|
79
|
+
const errorMessage = (errObj?.message || String(error || "")).slice(0, 100);
|
|
80
|
+
const errorName = errObj?.name || "UnknownError";
|
|
81
|
+
const route = context.route || "";
|
|
82
|
+
return [stackTop, errorMessage, errorName, route].filter(Boolean).join("::");
|
|
83
|
+
}
|
|
84
|
+
function createReport(error, {
|
|
85
|
+
context = {},
|
|
86
|
+
tags = {}
|
|
87
|
+
} = {}) {
|
|
88
|
+
const errObj = error;
|
|
89
|
+
return {
|
|
90
|
+
error: {
|
|
91
|
+
message: errObj?.message || String(error),
|
|
92
|
+
stack: errObj?.stack || null,
|
|
93
|
+
name: errObj?.name || "UnknownError"
|
|
94
|
+
},
|
|
95
|
+
fingerprint: fingerprint(error, context),
|
|
96
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
97
|
+
environment: getBrowserEnvironment(context.route),
|
|
98
|
+
componentStack: context.componentStack || null,
|
|
99
|
+
context,
|
|
100
|
+
tags
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function getErrorMessage(error) {
|
|
104
|
+
if (!error) return "";
|
|
105
|
+
if (typeof error === "string") return error.trim();
|
|
106
|
+
if (error instanceof Error) return error.message.trim();
|
|
107
|
+
const errObj = error;
|
|
108
|
+
return String(errObj?.message || errObj?.toString?.() || error).trim();
|
|
109
|
+
}
|
|
110
|
+
function shouldIgnoreError(error) {
|
|
111
|
+
if (!error) return true;
|
|
112
|
+
const errWithNotFound = error;
|
|
113
|
+
if (typeof errWithNotFound?.isNotFound === "function" && errWithNotFound.isNotFound()) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const message = getErrorMessage(error);
|
|
117
|
+
return ERROR_LISTENER_CONFIG.ignored.some((pattern) => pattern.test(message));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/error/reporter.ts
|
|
121
|
+
var IS_PRODUCTION = process.env.NODE_ENV === "production";
|
|
122
|
+
var IS_BROWSER2 = typeof window !== "undefined";
|
|
123
|
+
var ErrorReporter = class {
|
|
124
|
+
handlers = [];
|
|
125
|
+
context = {};
|
|
126
|
+
tags = {};
|
|
127
|
+
seen = /* @__PURE__ */ new Set();
|
|
128
|
+
enabled;
|
|
129
|
+
sampleRate;
|
|
130
|
+
beforeSend;
|
|
131
|
+
dedupeWindow;
|
|
132
|
+
constructor(options = {}) {
|
|
133
|
+
this.enabled = options.enabled ?? true;
|
|
134
|
+
this.sampleRate = normalizeSampleRate(options.sampleRate ?? 1);
|
|
135
|
+
this.beforeSend = options.beforeSend || null;
|
|
136
|
+
this.dedupeWindow = normalizeDedupeWindow(
|
|
137
|
+
options.deduplicateWindow ?? DEFAULT_DEDUPE_WINDOW
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
addHandler(handler) {
|
|
141
|
+
if (typeof handler?.handle === "function") {
|
|
142
|
+
this.handlers.push(handler);
|
|
143
|
+
}
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
removeHandler(name) {
|
|
147
|
+
this.handlers = this.handlers.filter((handler) => handler.name !== name);
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
setContext(key, value) {
|
|
151
|
+
if (Object.hasOwn(this.context, key) || Object.keys(this.context).length < MAX_CONTEXT) {
|
|
152
|
+
this.context[key] = value;
|
|
153
|
+
}
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
setTag(key, value) {
|
|
157
|
+
this.tags[key] = String(value);
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
captureError(error, extraContext = {}) {
|
|
161
|
+
if (!this.enabled || Math.random() > this.sampleRate) return;
|
|
162
|
+
this.ensureDefaultHandlers();
|
|
163
|
+
const context = { ...this.context, ...extraContext };
|
|
164
|
+
let report2 = createReport(error, { context, tags: { ...this.tags } });
|
|
165
|
+
const dedupeKey = report2.fingerprint;
|
|
166
|
+
if (this.seen.has(dedupeKey)) return;
|
|
167
|
+
if (this.seen.size >= MAX_FINGERPRINTS) {
|
|
168
|
+
const first = this.seen.keys().next().value;
|
|
169
|
+
if (first) this.seen.delete(first);
|
|
170
|
+
}
|
|
171
|
+
this.seen.add(dedupeKey);
|
|
172
|
+
setTimeout(() => this.seen.delete(dedupeKey), this.dedupeWindow);
|
|
173
|
+
if (typeof this.beforeSend === "function") {
|
|
174
|
+
try {
|
|
175
|
+
const transformed = this.beforeSend(report2);
|
|
176
|
+
if (!transformed) return;
|
|
177
|
+
report2 = transformed;
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
this.handlers.forEach((handler) => {
|
|
182
|
+
try {
|
|
183
|
+
handler.handle(report2);
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return report2;
|
|
188
|
+
}
|
|
189
|
+
captureMessage(message, level = "info", context = {}) {
|
|
190
|
+
const error = new Error(message);
|
|
191
|
+
error.name = "Message";
|
|
192
|
+
return this.captureError(error, { ...context, level });
|
|
193
|
+
}
|
|
194
|
+
ensureDefaultHandlers() {
|
|
195
|
+
if (this.handlers.length || !IS_BROWSER2) return;
|
|
196
|
+
this.handlers.push(createConsoleHandler());
|
|
197
|
+
if (window.Sentry) {
|
|
198
|
+
const sentryHandler = createSentryHandler(window.Sentry);
|
|
199
|
+
if (sentryHandler.name === "sentry") {
|
|
200
|
+
this.handlers.push(sentryHandler);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
var instance = null;
|
|
206
|
+
function getErrorReporter(options = {}) {
|
|
207
|
+
if (!instance) {
|
|
208
|
+
instance = new ErrorReporter(options);
|
|
209
|
+
}
|
|
210
|
+
return instance;
|
|
211
|
+
}
|
|
212
|
+
function createConsoleHandler() {
|
|
213
|
+
return {
|
|
214
|
+
name: "console",
|
|
215
|
+
handle(report2) {
|
|
216
|
+
if (IS_PRODUCTION) return;
|
|
217
|
+
console.error("[ErrorReporter]", {
|
|
218
|
+
error: report2.error.message,
|
|
219
|
+
fingerprint: report2.fingerprint,
|
|
220
|
+
route: report2.environment.route
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function createSentryHandler(Sentry) {
|
|
226
|
+
const sentryObj = Sentry;
|
|
227
|
+
if (!sentryObj || typeof sentryObj.captureException !== "function" || typeof sentryObj.withScope !== "function") {
|
|
228
|
+
return createConsoleHandler();
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
name: "sentry",
|
|
232
|
+
handle(report2) {
|
|
233
|
+
sentryObj.withScope((scope) => {
|
|
234
|
+
if (report2.fingerprint) scope.setFingerprint([report2.fingerprint]);
|
|
235
|
+
if (report2.user) scope.setUser(report2.user);
|
|
236
|
+
if (report2.tags && typeof report2.tags === "object") {
|
|
237
|
+
Object.entries(report2.tags).forEach(
|
|
238
|
+
([key, value]) => scope.setTag(key, String(value))
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
if (report2.environment)
|
|
242
|
+
scope.setContext("environment", report2.environment);
|
|
243
|
+
if (report2.context) scope.setContext("custom", report2.context);
|
|
244
|
+
if (report2.componentStack)
|
|
245
|
+
scope.setExtra("componentStack", report2.componentStack);
|
|
246
|
+
const error = new Error(report2.error.message);
|
|
247
|
+
error.name = report2.error.name || "Error";
|
|
248
|
+
error.stack = report2.error.stack || void 0;
|
|
249
|
+
sentryObj.captureException(error);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/utils/report.ts
|
|
256
|
+
var sink = null;
|
|
257
|
+
function report(scope, error, level = "error") {
|
|
258
|
+
if (sink) {
|
|
259
|
+
try {
|
|
260
|
+
sink(scope, error, level);
|
|
261
|
+
return;
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (process.env.NODE_ENV === "production" && typeof window !== "undefined") {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
console[level](`[${scope}]`, error);
|
|
269
|
+
}
|
|
270
|
+
function setReportSink(next) {
|
|
271
|
+
sink = next;
|
|
272
|
+
return () => {
|
|
273
|
+
if (sink === next) sink = null;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/events.ts
|
|
278
|
+
var EVENT_TYPES = Object.freeze({
|
|
279
|
+
API_UNAUTHORIZED: "API_UNAUTHORIZED",
|
|
280
|
+
STATE_CHANGE: "STATE_CHANGE",
|
|
281
|
+
API_ERROR: "API_ERROR",
|
|
282
|
+
APP_ERROR: "APP_ERROR"
|
|
283
|
+
});
|
|
284
|
+
var EventEmitter = class {
|
|
285
|
+
events = /* @__PURE__ */ new Map();
|
|
286
|
+
debounceTimers = /* @__PURE__ */ new Map();
|
|
287
|
+
subscribe(event, callback) {
|
|
288
|
+
if (typeof event !== "string" || !event || typeof callback !== "function") {
|
|
289
|
+
return () => {
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const listeners = this.events.get(event) || /* @__PURE__ */ new Set();
|
|
293
|
+
listeners.add(callback);
|
|
294
|
+
this.events.set(event, listeners);
|
|
295
|
+
return () => {
|
|
296
|
+
listeners.delete(callback);
|
|
297
|
+
if (listeners.size === 0) this.events.delete(event);
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
emit(event, payload) {
|
|
301
|
+
const listeners = this.events.get(event);
|
|
302
|
+
if (!listeners || listeners.size === 0) return;
|
|
303
|
+
const snapshot = Array.from(listeners);
|
|
304
|
+
for (const callback of snapshot) {
|
|
305
|
+
try {
|
|
306
|
+
callback(payload);
|
|
307
|
+
} catch (error) {
|
|
308
|
+
report(`Event listener (${String(event)})`, error);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
emitDebounced(event, payload, waitMs = 100) {
|
|
313
|
+
const existing = this.debounceTimers.get(event);
|
|
314
|
+
if (existing) clearTimeout(existing);
|
|
315
|
+
const timer = setTimeout(() => {
|
|
316
|
+
this.debounceTimers.delete(event);
|
|
317
|
+
this.emit(event, payload);
|
|
318
|
+
}, waitMs);
|
|
319
|
+
this.debounceTimers.set(event, timer);
|
|
320
|
+
}
|
|
321
|
+
cancelDebounced(event) {
|
|
322
|
+
if (event) {
|
|
323
|
+
const timer = this.debounceTimers.get(event);
|
|
324
|
+
if (timer) {
|
|
325
|
+
clearTimeout(timer);
|
|
326
|
+
this.debounceTimers.delete(event);
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
for (const timer of this.debounceTimers.values()) {
|
|
330
|
+
clearTimeout(timer);
|
|
331
|
+
}
|
|
332
|
+
this.debounceTimers.clear();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
unsubscribeAll(event) {
|
|
336
|
+
this.cancelDebounced(event);
|
|
337
|
+
if (event) this.events.delete(event);
|
|
338
|
+
else this.events.clear();
|
|
339
|
+
}
|
|
340
|
+
hasListeners(event) {
|
|
341
|
+
return Boolean(this.events.get(event)?.size);
|
|
342
|
+
}
|
|
343
|
+
getListenerCount(event) {
|
|
344
|
+
return this.events.get(event)?.size || 0;
|
|
345
|
+
}
|
|
346
|
+
getAllEvents() {
|
|
347
|
+
return [...this.events.keys()];
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
var GLOBAL_EVENTS_KEY = /* @__PURE__ */ Symbol.for("__base_framework_global_events__");
|
|
351
|
+
var _global = globalThis;
|
|
352
|
+
var globalEvents = _global[GLOBAL_EVENTS_KEY] ?? (_global[GLOBAL_EVENTS_KEY] = new EventEmitter());
|
|
353
|
+
function Icon({
|
|
354
|
+
className = "center",
|
|
355
|
+
color,
|
|
356
|
+
icon,
|
|
357
|
+
onClick,
|
|
358
|
+
size = 20,
|
|
359
|
+
style,
|
|
360
|
+
...props
|
|
361
|
+
}) {
|
|
362
|
+
return /* @__PURE__ */ jsx(
|
|
363
|
+
Icon$1,
|
|
364
|
+
{
|
|
365
|
+
className,
|
|
366
|
+
height: size,
|
|
367
|
+
icon,
|
|
368
|
+
onClick,
|
|
369
|
+
style: { color, ...style },
|
|
370
|
+
width: size,
|
|
371
|
+
...props
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
Icon.displayName = "Icon";
|
|
376
|
+
function Button({
|
|
377
|
+
ref,
|
|
378
|
+
children,
|
|
379
|
+
className,
|
|
380
|
+
disabled = false,
|
|
381
|
+
loading = false,
|
|
382
|
+
type = "button",
|
|
383
|
+
...props
|
|
384
|
+
}) {
|
|
385
|
+
return /* @__PURE__ */ jsx(
|
|
386
|
+
"button",
|
|
387
|
+
{
|
|
388
|
+
ref,
|
|
389
|
+
type,
|
|
390
|
+
disabled: disabled || loading,
|
|
391
|
+
"aria-busy": loading ? true : void 0,
|
|
392
|
+
className,
|
|
393
|
+
...props,
|
|
394
|
+
children
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
Button.displayName = "Button";
|
|
399
|
+
function getOrCreateGlobalContext(name, defaultValue) {
|
|
400
|
+
const sym = /* @__PURE__ */ Symbol.for(`@omerdlw/base-framework/context/${name}`);
|
|
401
|
+
const store = globalThis;
|
|
402
|
+
if (!store[sym]) {
|
|
403
|
+
store[sym] = createContext(defaultValue);
|
|
404
|
+
}
|
|
405
|
+
return store[sym];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// src/theme.tsx
|
|
409
|
+
function defineThemeSpec(id) {
|
|
410
|
+
return Object.freeze({ id });
|
|
411
|
+
}
|
|
412
|
+
var EMPTY = /* @__PURE__ */ new Map();
|
|
413
|
+
var ThemeContext = getOrCreateGlobalContext("ThemeContext", EMPTY);
|
|
414
|
+
function useTheme(spec) {
|
|
415
|
+
const config = useContext(ThemeContext).get(spec.id);
|
|
416
|
+
if (!config) {
|
|
417
|
+
throw new Error(
|
|
418
|
+
`Theme "${spec.id}" is missing. Add its theme file to src/config/ and list it in src/config/index.ts.`
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
slots: config.slots,
|
|
423
|
+
styles: config.styles ?? {}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/error/theme.ts
|
|
428
|
+
var errorTheme = defineThemeSpec("error");
|
|
429
|
+
|
|
430
|
+
// src/utils/user-message.ts
|
|
431
|
+
var USER_MESSAGES = Object.freeze({
|
|
432
|
+
generic: "Something went wrong. Please try again",
|
|
433
|
+
network: "You appear to be offline. Check your connection and try again",
|
|
434
|
+
timeout: "That took too long. Please try again",
|
|
435
|
+
unauthorized: "Your session has expired. Please sign in again",
|
|
436
|
+
forbidden: "You don't have permission to do that",
|
|
437
|
+
notFound: "We couldn't find what you were looking for",
|
|
438
|
+
rateLimited: "Too many attempts. Please wait a moment and try again",
|
|
439
|
+
server: "We're having trouble on our end. Please try again in a moment"
|
|
440
|
+
});
|
|
441
|
+
var UserError = class extends Error {
|
|
442
|
+
status;
|
|
443
|
+
constructor(message, status) {
|
|
444
|
+
super(message);
|
|
445
|
+
this.name = "UserError";
|
|
446
|
+
this.status = status;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var NETWORK_FAILURE = /failed to fetch|network|load failed|fetch failed/i;
|
|
450
|
+
function readField(source, field, type) {
|
|
451
|
+
const value = source?.[field];
|
|
452
|
+
return typeof value === type ? value : void 0;
|
|
453
|
+
}
|
|
454
|
+
function readPayloadMessage(error) {
|
|
455
|
+
const payload = error?.payload;
|
|
456
|
+
const message = readField(payload, "error", "string")?.trim();
|
|
457
|
+
return message || void 0;
|
|
458
|
+
}
|
|
459
|
+
function toUserMessage(error, { codes, fallback = USER_MESSAGES.generic } = {}) {
|
|
460
|
+
if (typeof error === "string") return error.trim() || fallback;
|
|
461
|
+
if (!error || typeof error !== "object") return fallback;
|
|
462
|
+
if (error instanceof UserError) {
|
|
463
|
+
if (error.status === 401) return USER_MESSAGES.unauthorized;
|
|
464
|
+
return error.message || fallback;
|
|
465
|
+
}
|
|
466
|
+
if (error.name === "AbortError") return fallback;
|
|
467
|
+
const code = readField(error, "code", "string");
|
|
468
|
+
if (code && codes?.[code]) return codes[code];
|
|
469
|
+
const status = readField(error, "status", "number");
|
|
470
|
+
if (status === 401) return USER_MESSAGES.unauthorized;
|
|
471
|
+
if (status === 429) return USER_MESSAGES.rateLimited;
|
|
472
|
+
if (status === 408 || status === 504) return USER_MESSAGES.timeout;
|
|
473
|
+
if (status !== void 0 && status >= 500) return USER_MESSAGES.server;
|
|
474
|
+
if (status !== void 0 && status >= 400) {
|
|
475
|
+
const authored = readPayloadMessage(error);
|
|
476
|
+
if (authored) return authored;
|
|
477
|
+
if (status === 403) return USER_MESSAGES.forbidden;
|
|
478
|
+
if (status === 404) return USER_MESSAGES.notFound;
|
|
479
|
+
return fallback;
|
|
480
|
+
}
|
|
481
|
+
const isOffline = typeof navigator !== "undefined" && navigator.onLine === false;
|
|
482
|
+
if (isOffline || NETWORK_FAILURE.test(error.message ?? "") && (error instanceof TypeError || /fetch/i.test(error.name))) {
|
|
483
|
+
return USER_MESSAGES.network;
|
|
484
|
+
}
|
|
485
|
+
return fallback;
|
|
486
|
+
}
|
|
487
|
+
var ActionButton = Button;
|
|
488
|
+
function DefaultErrorFallback({
|
|
489
|
+
error,
|
|
490
|
+
message,
|
|
491
|
+
resetError,
|
|
492
|
+
title
|
|
493
|
+
}) {
|
|
494
|
+
const theme = useTheme(errorTheme);
|
|
495
|
+
return /* @__PURE__ */ jsxs("div", { className: theme.slots.screen, children: [
|
|
496
|
+
/* @__PURE__ */ jsx("div", { className: theme.slots.icon, children: /* @__PURE__ */ jsx(Icon, { icon: "solar:danger-circle-bold", size: 30 }) }),
|
|
497
|
+
/* @__PURE__ */ jsx("h3", { className: theme.slots.title, children: message || toUserMessage(error, { fallback: ERROR_MESSAGES.FALLBACK_MSG }) }),
|
|
498
|
+
/* @__PURE__ */ jsx(
|
|
499
|
+
ActionButton,
|
|
500
|
+
{
|
|
501
|
+
className: theme.slots.retryButton,
|
|
502
|
+
onClick: resetError,
|
|
503
|
+
type: "button",
|
|
504
|
+
children: "Try again"
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
] });
|
|
508
|
+
}
|
|
509
|
+
var ErrorBoundaryCore = class extends React.Component {
|
|
510
|
+
constructor(props) {
|
|
511
|
+
super(props);
|
|
512
|
+
this.state = {
|
|
513
|
+
error: null,
|
|
514
|
+
errorInfo: null,
|
|
515
|
+
hasError: false,
|
|
516
|
+
lastResetKey: props.resetKey
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
static getDerivedStateFromError(error) {
|
|
520
|
+
return { error, hasError: true };
|
|
521
|
+
}
|
|
522
|
+
static getDerivedStateFromProps(props, state) {
|
|
523
|
+
if (props.resetKey !== state.lastResetKey) {
|
|
524
|
+
return {
|
|
525
|
+
error: null,
|
|
526
|
+
errorInfo: null,
|
|
527
|
+
hasError: false,
|
|
528
|
+
lastResetKey: props.resetKey
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
componentDidCatch(error, errorInfo) {
|
|
534
|
+
this.setState({ errorInfo });
|
|
535
|
+
const { message, name, onError, silent, title, variant } = this.props;
|
|
536
|
+
const context = createErrorContext({ errorInfo, name, title, variant });
|
|
537
|
+
try {
|
|
538
|
+
onError?.(error, errorInfo, context);
|
|
539
|
+
} catch (callbackError) {
|
|
540
|
+
report("ErrorBoundary onError callback", callbackError, "warn");
|
|
541
|
+
}
|
|
542
|
+
if (!silent) {
|
|
543
|
+
globalEvents.emit(EVENT_TYPES.APP_ERROR, {
|
|
544
|
+
error,
|
|
545
|
+
errorInfo,
|
|
546
|
+
message: message || toUserMessage(error),
|
|
547
|
+
resetError: this.resetError
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
try {
|
|
551
|
+
const reporter = getErrorReporter();
|
|
552
|
+
reporter?.captureError?.(error, context);
|
|
553
|
+
} catch (reportingError) {
|
|
554
|
+
report("ErrorBoundary reporting", reportingError, "warn");
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
resetError = () => {
|
|
558
|
+
this.setState({
|
|
559
|
+
error: null,
|
|
560
|
+
errorInfo: null,
|
|
561
|
+
hasError: false
|
|
562
|
+
});
|
|
563
|
+
this.props.onReset?.();
|
|
564
|
+
};
|
|
565
|
+
render() {
|
|
566
|
+
if (!this.state.hasError) return this.props.children;
|
|
567
|
+
const { fallback, message, title } = this.props;
|
|
568
|
+
const { error } = this.state;
|
|
569
|
+
if (typeof fallback === "function") {
|
|
570
|
+
return fallback({ error, resetError: this.resetError });
|
|
571
|
+
}
|
|
572
|
+
if (fallback) {
|
|
573
|
+
return fallback;
|
|
574
|
+
}
|
|
575
|
+
return /* @__PURE__ */ jsx(
|
|
576
|
+
DefaultErrorFallback,
|
|
577
|
+
{
|
|
578
|
+
error,
|
|
579
|
+
message,
|
|
580
|
+
resetError: this.resetError,
|
|
581
|
+
title
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
function GlobalError({ children, fallback, onReset }) {
|
|
587
|
+
const pathname = usePathname();
|
|
588
|
+
return /* @__PURE__ */ jsx(
|
|
589
|
+
ErrorBoundaryCore,
|
|
590
|
+
{
|
|
591
|
+
fallback,
|
|
592
|
+
message: ERROR_MESSAGES.GLOBAL_MSG,
|
|
593
|
+
onReset,
|
|
594
|
+
resetKey: pathname,
|
|
595
|
+
title: ERROR_MESSAGES.GLOBAL_TITLE,
|
|
596
|
+
variant: "full",
|
|
597
|
+
children
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
function ModuleError({
|
|
602
|
+
children,
|
|
603
|
+
fallback,
|
|
604
|
+
name,
|
|
605
|
+
onReset
|
|
606
|
+
}) {
|
|
607
|
+
return /* @__PURE__ */ jsx(
|
|
608
|
+
ErrorBoundaryCore,
|
|
609
|
+
{
|
|
610
|
+
fallback,
|
|
611
|
+
message: ERROR_MESSAGES.MODULE_MSG,
|
|
612
|
+
name,
|
|
613
|
+
onReset,
|
|
614
|
+
title: name ? `${name} Error` : ERROR_MESSAGES.MODULE_TITLE,
|
|
615
|
+
variant: "module",
|
|
616
|
+
children
|
|
617
|
+
}
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
function ComponentError({
|
|
621
|
+
children,
|
|
622
|
+
fallback,
|
|
623
|
+
message,
|
|
624
|
+
onReset
|
|
625
|
+
}) {
|
|
626
|
+
return /* @__PURE__ */ jsx(
|
|
627
|
+
ErrorBoundaryCore,
|
|
628
|
+
{
|
|
629
|
+
fallback,
|
|
630
|
+
message: message || ERROR_MESSAGES.COMPONENT_MSG,
|
|
631
|
+
onReset,
|
|
632
|
+
variant: "inline",
|
|
633
|
+
children
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
function GlobalErrorListener() {
|
|
638
|
+
const lastError = useRef(0);
|
|
639
|
+
const count = useRef(0);
|
|
640
|
+
const shown = useRef(/* @__PURE__ */ new Set());
|
|
641
|
+
const handleError = useCallback((error, source = "runtime") => {
|
|
642
|
+
if (shouldIgnoreError(error)) return;
|
|
643
|
+
const now = Date.now();
|
|
644
|
+
if (count.current >= ERROR_LISTENER_CONFIG.maxErrors) return;
|
|
645
|
+
if (now - lastError.current < ERROR_LISTENER_CONFIG.throttle) return;
|
|
646
|
+
const message = getErrorMessage(error);
|
|
647
|
+
const key = message || String(error);
|
|
648
|
+
if (shown.current.has(key)) return;
|
|
649
|
+
shown.current.add(key);
|
|
650
|
+
lastError.current = now;
|
|
651
|
+
count.current += 1;
|
|
652
|
+
try {
|
|
653
|
+
const reporter = getErrorReporter();
|
|
654
|
+
reporter?.captureError?.(error, {
|
|
655
|
+
globalListener: true,
|
|
656
|
+
source
|
|
657
|
+
});
|
|
658
|
+
} catch (reportingError) {
|
|
659
|
+
report("GlobalError reporting", reportingError, "warn");
|
|
660
|
+
}
|
|
661
|
+
globalEvents.emit(EVENT_TYPES.APP_ERROR, {
|
|
662
|
+
error,
|
|
663
|
+
message: toUserMessage(error)
|
|
664
|
+
});
|
|
665
|
+
}, []);
|
|
666
|
+
useEffect(() => {
|
|
667
|
+
const removeSink = setReportSink((scope, error, level) => {
|
|
668
|
+
try {
|
|
669
|
+
getErrorReporter().captureError(error, { level, scope });
|
|
670
|
+
} catch {
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
const onError = (event) => handleError(event.error || event.message, "window.onerror");
|
|
674
|
+
const onRejection = (event) => handleError(event.reason, "unhandledrejection");
|
|
675
|
+
window.addEventListener("error", onError);
|
|
676
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
677
|
+
return () => {
|
|
678
|
+
removeSink();
|
|
679
|
+
window.removeEventListener("error", onError);
|
|
680
|
+
window.removeEventListener("unhandledrejection", onRejection);
|
|
681
|
+
};
|
|
682
|
+
}, [handleError]);
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
export { ComponentError, DEFAULT_DEDUPE_WINDOW, ERROR_LISTENER_CONFIG, ERROR_MESSAGES, ErrorBoundaryCore, GlobalError, GlobalErrorListener, MAX_CONTEXT, MAX_FINGERPRINTS, ModuleError, createConsoleHandler, createErrorContext, createReport, createSentryHandler, errorTheme, fingerprint, getBrowserEnvironment, getErrorMessage, getErrorReporter, getRuntimePath, getUserAgent, normalizeDedupeWindow, normalizeSampleRate, shouldIgnoreError };
|
|
687
|
+
//# sourceMappingURL=index.js.map
|
|
688
|
+
//# sourceMappingURL=index.js.map
|