@harkenapp/sdk-react-native 0.0.1-alpha.1
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/README.md +67 -0
- package/app.plugin.cjs +135 -0
- package/app.plugin.js +1 -0
- package/dist/api/client.d.ts +67 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +163 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/errors.d.ts +46 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +72 -0
- package/dist/api/errors.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +20 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/retry.d.ts +29 -0
- package/dist/api/retry.d.ts.map +1 -0
- package/dist/api/retry.js +74 -0
- package/dist/api/retry.js.map +1 -0
- package/dist/attachments/FeedbackSheet.d.ts +88 -0
- package/dist/attachments/FeedbackSheet.d.ts.map +1 -0
- package/dist/attachments/FeedbackSheet.js +250 -0
- package/dist/attachments/FeedbackSheet.js.map +1 -0
- package/dist/attachments/index.d.ts +20 -0
- package/dist/attachments/index.d.ts.map +1 -0
- package/dist/attachments/index.js +40 -0
- package/dist/attachments/index.js.map +1 -0
- package/dist/components/AttachmentGrid.d.ts +94 -0
- package/dist/components/AttachmentGrid.d.ts.map +1 -0
- package/dist/components/AttachmentGrid.js +132 -0
- package/dist/components/AttachmentGrid.js.map +1 -0
- package/dist/components/AttachmentPicker.d.ts +98 -0
- package/dist/components/AttachmentPicker.d.ts.map +1 -0
- package/dist/components/AttachmentPicker.js +297 -0
- package/dist/components/AttachmentPicker.js.map +1 -0
- package/dist/components/AttachmentPreview.d.ts +78 -0
- package/dist/components/AttachmentPreview.d.ts.map +1 -0
- package/dist/components/AttachmentPreview.js +133 -0
- package/dist/components/AttachmentPreview.js.map +1 -0
- package/dist/components/CategorySelector.d.ts +77 -0
- package/dist/components/CategorySelector.d.ts.map +1 -0
- package/dist/components/CategorySelector.js +117 -0
- package/dist/components/CategorySelector.js.map +1 -0
- package/dist/components/FeedbackForm.d.ts +50 -0
- package/dist/components/FeedbackForm.d.ts.map +1 -0
- package/dist/components/FeedbackForm.js +141 -0
- package/dist/components/FeedbackForm.js.map +1 -0
- package/dist/components/FeedbackSheet.d.ts +75 -0
- package/dist/components/FeedbackSheet.d.ts.map +1 -0
- package/dist/components/FeedbackSheet.js +215 -0
- package/dist/components/FeedbackSheet.js.map +1 -0
- package/dist/components/ThemedButton.d.ts +23 -0
- package/dist/components/ThemedButton.d.ts.map +1 -0
- package/dist/components/ThemedButton.js +77 -0
- package/dist/components/ThemedButton.js.map +1 -0
- package/dist/components/ThemedText.d.ts +16 -0
- package/dist/components/ThemedText.d.ts.map +1 -0
- package/dist/components/ThemedText.js +44 -0
- package/dist/components/ThemedText.js.map +1 -0
- package/dist/components/ThemedTextInput.d.ts +13 -0
- package/dist/components/ThemedTextInput.d.ts.map +1 -0
- package/dist/components/ThemedTextInput.js +76 -0
- package/dist/components/ThemedTextInput.js.map +1 -0
- package/dist/components/UploadStatusOverlay.d.ts +82 -0
- package/dist/components/UploadStatusOverlay.d.ts.map +1 -0
- package/dist/components/UploadStatusOverlay.js +319 -0
- package/dist/components/UploadStatusOverlay.js.map +1 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +28 -0
- package/dist/components/index.js.map +1 -0
- package/dist/context/HarkenContext.d.ts +62 -0
- package/dist/context/HarkenContext.d.ts.map +1 -0
- package/dist/context/HarkenContext.js +128 -0
- package/dist/context/HarkenContext.js.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +7 -0
- package/dist/context/index.js.map +1 -0
- package/dist/domain/index.d.ts +3 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +7 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/upload-queue.d.ts +116 -0
- package/dist/domain/upload-queue.d.ts.map +1 -0
- package/dist/domain/upload-queue.js +34 -0
- package/dist/domain/upload-queue.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAnonymousId.d.ts +28 -0
- package/dist/hooks/useAnonymousId.d.ts.map +1 -0
- package/dist/hooks/useAnonymousId.js +59 -0
- package/dist/hooks/useAnonymousId.js.map +1 -0
- package/dist/hooks/useAttachmentPicker.d.ts +84 -0
- package/dist/hooks/useAttachmentPicker.d.ts.map +1 -0
- package/dist/hooks/useAttachmentPicker.js +181 -0
- package/dist/hooks/useAttachmentPicker.js.map +1 -0
- package/dist/hooks/useAttachmentStatus.d.ts +51 -0
- package/dist/hooks/useAttachmentStatus.d.ts.map +1 -0
- package/dist/hooks/useAttachmentStatus.js +69 -0
- package/dist/hooks/useAttachmentStatus.js.map +1 -0
- package/dist/hooks/useAttachmentUpload.d.ts +101 -0
- package/dist/hooks/useAttachmentUpload.d.ts.map +1 -0
- package/dist/hooks/useAttachmentUpload.js +293 -0
- package/dist/hooks/useAttachmentUpload.js.map +1 -0
- package/dist/hooks/useFeedback.d.ts +55 -0
- package/dist/hooks/useFeedback.d.ts.map +1 -0
- package/dist/hooks/useFeedback.js +96 -0
- package/dist/hooks/useFeedback.js.map +1 -0
- package/dist/hooks/useHarkenContext.d.ts +25 -0
- package/dist/hooks/useHarkenContext.d.ts.map +1 -0
- package/dist/hooks/useHarkenContext.js +35 -0
- package/dist/hooks/useHarkenContext.js.map +1 -0
- package/dist/hooks/useHarkenTheme.d.ts +26 -0
- package/dist/hooks/useHarkenTheme.d.ts.map +1 -0
- package/dist/hooks/useHarkenTheme.js +36 -0
- package/dist/hooks/useHarkenTheme.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +9 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/uploadQueueService.d.ts +193 -0
- package/dist/services/uploadQueueService.d.ts.map +1 -0
- package/dist/services/uploadQueueService.js +623 -0
- package/dist/services/uploadQueueService.js.map +1 -0
- package/dist/services/uploadQueueStorage.d.ts +30 -0
- package/dist/services/uploadQueueStorage.d.ts.map +1 -0
- package/dist/services/uploadQueueStorage.js +77 -0
- package/dist/services/uploadQueueStorage.js.map +1 -0
- package/dist/storage/IdentityStore.d.ts +38 -0
- package/dist/storage/IdentityStore.d.ts.map +1 -0
- package/dist/storage/IdentityStore.js +83 -0
- package/dist/storage/IdentityStore.js.map +1 -0
- package/dist/storage/SecureStoreAdapter.d.ts +28 -0
- package/dist/storage/SecureStoreAdapter.d.ts.map +1 -0
- package/dist/storage/SecureStoreAdapter.js +52 -0
- package/dist/storage/SecureStoreAdapter.js.map +1 -0
- package/dist/storage/defaultStorage.d.ts +20 -0
- package/dist/storage/defaultStorage.d.ts.map +1 -0
- package/dist/storage/defaultStorage.js +131 -0
- package/dist/storage/defaultStorage.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +13 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/types.d.ts +32 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +11 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/theme/defaults.d.ts +43 -0
- package/dist/theme/defaults.d.ts.map +1 -0
- package/dist/theme/defaults.js +128 -0
- package/dist/theme/defaults.js.map +1 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +14 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/types.d.ts +136 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +3 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/types/config.d.ts +100 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/openapi.d.ts +601 -0
- package/dist/types/openapi.d.ts.map +1 -0
- package/dist/types/openapi.js +7 -0
- package/dist/types/openapi.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/uuid.d.ts +10 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +60 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +124 -0
- package/src/@types/expo-file-system-legacy.d.ts +13 -0
- package/src/api/client.ts +250 -0
- package/src/api/errors.ts +84 -0
- package/src/api/index.ts +15 -0
- package/src/api/retry.ts +99 -0
- package/src/attachments/FeedbackSheet.tsx +400 -0
- package/src/attachments/index.ts +70 -0
- package/src/components/AttachmentGrid.tsx +247 -0
- package/src/components/AttachmentPicker.tsx +391 -0
- package/src/components/AttachmentPreview.tsx +210 -0
- package/src/components/CategorySelector.tsx +174 -0
- package/src/components/FeedbackForm.tsx +216 -0
- package/src/components/FeedbackSheet.tsx +321 -0
- package/src/components/ThemedButton.tsx +127 -0
- package/src/components/ThemedText.tsx +65 -0
- package/src/components/ThemedTextInput.tsx +65 -0
- package/src/components/UploadStatusOverlay.tsx +440 -0
- package/src/components/index.ts +39 -0
- package/src/context/HarkenContext.tsx +129 -0
- package/src/context/index.ts +2 -0
- package/src/domain/index.ts +12 -0
- package/src/domain/upload-queue.ts +131 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/useAnonymousId.ts +68 -0
- package/src/hooks/useAttachmentPicker.ts +243 -0
- package/src/hooks/useAttachmentStatus.ts +86 -0
- package/src/hooks/useAttachmentUpload.ts +370 -0
- package/src/hooks/useFeedback.ts +139 -0
- package/src/hooks/useHarkenContext.ts +35 -0
- package/src/hooks/useHarkenTheme.ts +36 -0
- package/src/index.ts +168 -0
- package/src/services/index.ts +11 -0
- package/src/services/uploadQueueService.ts +727 -0
- package/src/services/uploadQueueStorage.ts +78 -0
- package/src/storage/IdentityStore.ts +89 -0
- package/src/storage/SecureStoreAdapter.ts +59 -0
- package/src/storage/defaultStorage.ts +109 -0
- package/src/storage/index.ts +5 -0
- package/src/storage/types.ts +34 -0
- package/src/theme/defaults.ts +151 -0
- package/src/theme/index.ts +23 -0
- package/src/theme/types.ts +157 -0
- package/src/types/config.ts +112 -0
- package/src/types/index.ts +10 -0
- package/src/types/openapi.ts +601 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/uuid.ts +77 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHarkenContext = useHarkenContext;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access the full Harken context.
|
|
8
|
+
*
|
|
9
|
+
* Provides access to theme, config, and SDK state.
|
|
10
|
+
* Must be used within a HarkenProvider.
|
|
11
|
+
*
|
|
12
|
+
* @returns The full HarkenContextValue
|
|
13
|
+
* @throws Error if used outside of HarkenProvider
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* function MyComponent() {
|
|
18
|
+
* const { theme, isDarkMode, config } = useHarkenContext();
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <View>
|
|
22
|
+
* <Text>Dark mode: {isDarkMode ? 'on' : 'off'}</Text>
|
|
23
|
+
* </View>
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function useHarkenContext() {
|
|
29
|
+
const context = (0, react_1.useContext)(context_1.HarkenContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error('useHarkenContext must be used within a HarkenProvider');
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=useHarkenContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHarkenContext.js","sourceRoot":"","sources":["../../src/hooks/useHarkenContext.ts"],"names":[],"mappings":";;AA0BA,4CAQC;AAlCD,iCAAmC;AACnC,wCAA2C;AAG3C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,uBAAa,CAAC,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HarkenTheme } from '../theme';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access the current Harken theme.
|
|
4
|
+
*
|
|
5
|
+
* Must be used within a HarkenProvider.
|
|
6
|
+
*
|
|
7
|
+
* @returns The resolved HarkenTheme object
|
|
8
|
+
* @throws Error if used outside of HarkenProvider
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* function MyComponent() {
|
|
13
|
+
* const theme = useHarkenTheme();
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <View style={{ backgroundColor: theme.colors.background }}>
|
|
17
|
+
* <Text style={{ color: theme.colors.text }}>
|
|
18
|
+
* Hello
|
|
19
|
+
* </Text>
|
|
20
|
+
* </View>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useHarkenTheme(): HarkenTheme;
|
|
26
|
+
//# sourceMappingURL=useHarkenTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHarkenTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useHarkenTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHarkenTheme = useHarkenTheme;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access the current Harken theme.
|
|
8
|
+
*
|
|
9
|
+
* Must be used within a HarkenProvider.
|
|
10
|
+
*
|
|
11
|
+
* @returns The resolved HarkenTheme object
|
|
12
|
+
* @throws Error if used outside of HarkenProvider
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function MyComponent() {
|
|
17
|
+
* const theme = useHarkenTheme();
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <View style={{ backgroundColor: theme.colors.background }}>
|
|
21
|
+
* <Text style={{ color: theme.colors.text }}>
|
|
22
|
+
* Hello
|
|
23
|
+
* </Text>
|
|
24
|
+
* </View>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function useHarkenTheme() {
|
|
30
|
+
const context = (0, react_1.useContext)(context_1.HarkenContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error('useHarkenTheme must be used within a HarkenProvider');
|
|
33
|
+
}
|
|
34
|
+
return context.theme;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useHarkenTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHarkenTheme.js","sourceRoot":"","sources":["../../src/hooks/useHarkenTheme.ts"],"names":[],"mappings":";;AA2BA,wCAQC;AAnCD,iCAAmC;AACnC,wCAA2C;AAG3C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,cAAc;IAC5B,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,uBAAa,CAAC,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harken React Native SDK
|
|
3
|
+
*
|
|
4
|
+
* A mobile-first feedback SDK for React Native and Expo applications.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { HarkenProvider, FeedbackSheet } from '@harkenapp/sdk-react-native';
|
|
9
|
+
*
|
|
10
|
+
* function App() {
|
|
11
|
+
* return (
|
|
12
|
+
* <HarkenProvider config={{ publishableKey: 'pk_live_xxxx' }}>
|
|
13
|
+
* <FeedbackSheet onSuccess={() => console.log('Submitted!')} />
|
|
14
|
+
* </HarkenProvider>
|
|
15
|
+
* );
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
export { HarkenProvider } from './context';
|
|
22
|
+
export type { HarkenContextValue } from './context';
|
|
23
|
+
export { useHarkenTheme, useHarkenContext, useAnonymousId, useFeedback, } from './hooks';
|
|
24
|
+
export type { SubmitFeedbackParams, UseFeedbackResult } from './hooks';
|
|
25
|
+
export { useAttachmentUpload } from './hooks/useAttachmentUpload';
|
|
26
|
+
export type { AttachmentState, UseAttachmentUploadResult, } from './hooks/useAttachmentUpload';
|
|
27
|
+
export { useAttachmentPicker } from './hooks/useAttachmentPicker';
|
|
28
|
+
export type { AttachmentSourceConfig, UseAttachmentPickerResult, } from './hooks/useAttachmentPicker';
|
|
29
|
+
export { useAttachmentStatus } from './hooks/useAttachmentStatus';
|
|
30
|
+
export type { AttachmentStatus } from './hooks/useAttachmentStatus';
|
|
31
|
+
export type { HarkenColors, HarkenTypography, HarkenSpacing, HarkenRadii, HarkenTheme, PartialHarkenTheme, TextWeight, ThemeMode, } from './theme';
|
|
32
|
+
export { lightColors, darkColors, defaultTypography, defaultSpacing, defaultRadii, lightTheme, darkTheme, createTheme, } from './theme';
|
|
33
|
+
export type { SecureStorage } from './storage';
|
|
34
|
+
export { createSecureStoreAdapter, createMemoryStorage, IdentityStore, } from './storage';
|
|
35
|
+
export { generateUUID } from './utils';
|
|
36
|
+
export { ThemedText, ThemedTextInput, ThemedButton, CategorySelector, FeedbackForm, DEFAULT_CATEGORIES, } from './components';
|
|
37
|
+
export type { ThemedTextProps, TextVariant, ThemedTextInputProps, ThemedButtonProps, ButtonVariant, CategorySelectorProps, CategoryOption, FeedbackFormProps, FeedbackFormData, } from './components';
|
|
38
|
+
export { AttachmentPicker, UploadStatusOverlay, AttachmentPreview, AttachmentGrid, } from './components';
|
|
39
|
+
export type { AttachmentPickerProps, AttachmentSource, PickerOptionConfig, UploadStatusOverlayProps, UploadStatusLabels, AttachmentPreviewProps, AttachmentGridProps, } from './components';
|
|
40
|
+
export { FeedbackSheet } from './attachments/FeedbackSheet';
|
|
41
|
+
export type { FeedbackSheetProps } from './attachments/FeedbackSheet';
|
|
42
|
+
export { HarkenClient, createHarkenClient, HarkenError, HarkenApiError, HarkenNetworkError, withRetry, DEFAULT_RETRY_CONFIG, } from './api';
|
|
43
|
+
export type { HarkenClientConfig, RetryConfig } from './api';
|
|
44
|
+
export type { HarkenConfig, HarkenProviderProps, FeedbackCategory, Platform, DeviceMetadata, } from './types';
|
|
45
|
+
export { UploadPhase, DEFAULT_UPLOAD_RETRY_CONFIG } from './domain';
|
|
46
|
+
export type { QueueItem, QueueStatus, UploadProgress, UploadRetryConfig, } from './domain';
|
|
47
|
+
export { UploadQueueService, uploadQueueService, UploadQueueStorage, } from './services';
|
|
48
|
+
export type { UploadQueueServiceConfig, EnqueueParams, } from './services';
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,YAAY,EACV,eAAe,EACf,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,YAAY,EACV,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAA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;AACpB,YAAY,EACV,wBAAwB,EACxB,aAAa,GACd,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Harken React Native SDK
|
|
4
|
+
*
|
|
5
|
+
* A mobile-first feedback SDK for React Native and Expo applications.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { HarkenProvider, FeedbackSheet } from '@harkenapp/sdk-react-native';
|
|
10
|
+
*
|
|
11
|
+
* function App() {
|
|
12
|
+
* return (
|
|
13
|
+
* <HarkenProvider config={{ publishableKey: 'pk_live_xxxx' }}>
|
|
14
|
+
* <FeedbackSheet onSuccess={() => console.log('Submitted!')} />
|
|
15
|
+
* </HarkenProvider>
|
|
16
|
+
* );
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.UploadQueueStorage = exports.uploadQueueService = exports.UploadQueueService = exports.DEFAULT_UPLOAD_RETRY_CONFIG = exports.UploadPhase = exports.DEFAULT_RETRY_CONFIG = exports.withRetry = exports.HarkenNetworkError = exports.HarkenApiError = exports.HarkenError = exports.createHarkenClient = exports.HarkenClient = exports.FeedbackSheet = exports.AttachmentGrid = exports.AttachmentPreview = exports.UploadStatusOverlay = exports.AttachmentPicker = exports.DEFAULT_CATEGORIES = exports.FeedbackForm = exports.CategorySelector = exports.ThemedButton = exports.ThemedTextInput = exports.ThemedText = exports.generateUUID = exports.IdentityStore = exports.createMemoryStorage = exports.createSecureStoreAdapter = exports.createTheme = exports.darkTheme = exports.lightTheme = exports.defaultRadii = exports.defaultSpacing = exports.defaultTypography = exports.darkColors = exports.lightColors = exports.useAttachmentStatus = exports.useAttachmentPicker = exports.useAttachmentUpload = exports.useFeedback = exports.useAnonymousId = exports.useHarkenContext = exports.useHarkenTheme = exports.HarkenProvider = void 0;
|
|
24
|
+
// Provider and context
|
|
25
|
+
var context_1 = require("./context");
|
|
26
|
+
Object.defineProperty(exports, "HarkenProvider", { enumerable: true, get: function () { return context_1.HarkenProvider; } });
|
|
27
|
+
// Hooks (core)
|
|
28
|
+
var hooks_1 = require("./hooks");
|
|
29
|
+
Object.defineProperty(exports, "useHarkenTheme", { enumerable: true, get: function () { return hooks_1.useHarkenTheme; } });
|
|
30
|
+
Object.defineProperty(exports, "useHarkenContext", { enumerable: true, get: function () { return hooks_1.useHarkenContext; } });
|
|
31
|
+
Object.defineProperty(exports, "useAnonymousId", { enumerable: true, get: function () { return hooks_1.useAnonymousId; } });
|
|
32
|
+
Object.defineProperty(exports, "useFeedback", { enumerable: true, get: function () { return hooks_1.useFeedback; } });
|
|
33
|
+
// Hooks (attachments)
|
|
34
|
+
var useAttachmentUpload_1 = require("./hooks/useAttachmentUpload");
|
|
35
|
+
Object.defineProperty(exports, "useAttachmentUpload", { enumerable: true, get: function () { return useAttachmentUpload_1.useAttachmentUpload; } });
|
|
36
|
+
var useAttachmentPicker_1 = require("./hooks/useAttachmentPicker");
|
|
37
|
+
Object.defineProperty(exports, "useAttachmentPicker", { enumerable: true, get: function () { return useAttachmentPicker_1.useAttachmentPicker; } });
|
|
38
|
+
var useAttachmentStatus_1 = require("./hooks/useAttachmentStatus");
|
|
39
|
+
Object.defineProperty(exports, "useAttachmentStatus", { enumerable: true, get: function () { return useAttachmentStatus_1.useAttachmentStatus; } });
|
|
40
|
+
var theme_1 = require("./theme");
|
|
41
|
+
Object.defineProperty(exports, "lightColors", { enumerable: true, get: function () { return theme_1.lightColors; } });
|
|
42
|
+
Object.defineProperty(exports, "darkColors", { enumerable: true, get: function () { return theme_1.darkColors; } });
|
|
43
|
+
Object.defineProperty(exports, "defaultTypography", { enumerable: true, get: function () { return theme_1.defaultTypography; } });
|
|
44
|
+
Object.defineProperty(exports, "defaultSpacing", { enumerable: true, get: function () { return theme_1.defaultSpacing; } });
|
|
45
|
+
Object.defineProperty(exports, "defaultRadii", { enumerable: true, get: function () { return theme_1.defaultRadii; } });
|
|
46
|
+
Object.defineProperty(exports, "lightTheme", { enumerable: true, get: function () { return theme_1.lightTheme; } });
|
|
47
|
+
Object.defineProperty(exports, "darkTheme", { enumerable: true, get: function () { return theme_1.darkTheme; } });
|
|
48
|
+
Object.defineProperty(exports, "createTheme", { enumerable: true, get: function () { return theme_1.createTheme; } });
|
|
49
|
+
var storage_1 = require("./storage");
|
|
50
|
+
Object.defineProperty(exports, "createSecureStoreAdapter", { enumerable: true, get: function () { return storage_1.createSecureStoreAdapter; } });
|
|
51
|
+
Object.defineProperty(exports, "createMemoryStorage", { enumerable: true, get: function () { return storage_1.createMemoryStorage; } });
|
|
52
|
+
Object.defineProperty(exports, "IdentityStore", { enumerable: true, get: function () { return storage_1.IdentityStore; } });
|
|
53
|
+
// Utilities
|
|
54
|
+
var utils_1 = require("./utils");
|
|
55
|
+
Object.defineProperty(exports, "generateUUID", { enumerable: true, get: function () { return utils_1.generateUUID; } });
|
|
56
|
+
// Components (core)
|
|
57
|
+
var components_1 = require("./components");
|
|
58
|
+
Object.defineProperty(exports, "ThemedText", { enumerable: true, get: function () { return components_1.ThemedText; } });
|
|
59
|
+
Object.defineProperty(exports, "ThemedTextInput", { enumerable: true, get: function () { return components_1.ThemedTextInput; } });
|
|
60
|
+
Object.defineProperty(exports, "ThemedButton", { enumerable: true, get: function () { return components_1.ThemedButton; } });
|
|
61
|
+
Object.defineProperty(exports, "CategorySelector", { enumerable: true, get: function () { return components_1.CategorySelector; } });
|
|
62
|
+
Object.defineProperty(exports, "FeedbackForm", { enumerable: true, get: function () { return components_1.FeedbackForm; } });
|
|
63
|
+
Object.defineProperty(exports, "DEFAULT_CATEGORIES", { enumerable: true, get: function () { return components_1.DEFAULT_CATEGORIES; } });
|
|
64
|
+
// Components (attachments)
|
|
65
|
+
var components_2 = require("./components");
|
|
66
|
+
Object.defineProperty(exports, "AttachmentPicker", { enumerable: true, get: function () { return components_2.AttachmentPicker; } });
|
|
67
|
+
Object.defineProperty(exports, "UploadStatusOverlay", { enumerable: true, get: function () { return components_2.UploadStatusOverlay; } });
|
|
68
|
+
Object.defineProperty(exports, "AttachmentPreview", { enumerable: true, get: function () { return components_2.AttachmentPreview; } });
|
|
69
|
+
Object.defineProperty(exports, "AttachmentGrid", { enumerable: true, get: function () { return components_2.AttachmentGrid; } });
|
|
70
|
+
// FeedbackSheet (with full attachment support)
|
|
71
|
+
var FeedbackSheet_1 = require("./attachments/FeedbackSheet");
|
|
72
|
+
Object.defineProperty(exports, "FeedbackSheet", { enumerable: true, get: function () { return FeedbackSheet_1.FeedbackSheet; } });
|
|
73
|
+
// API client
|
|
74
|
+
var api_1 = require("./api");
|
|
75
|
+
Object.defineProperty(exports, "HarkenClient", { enumerable: true, get: function () { return api_1.HarkenClient; } });
|
|
76
|
+
Object.defineProperty(exports, "createHarkenClient", { enumerable: true, get: function () { return api_1.createHarkenClient; } });
|
|
77
|
+
Object.defineProperty(exports, "HarkenError", { enumerable: true, get: function () { return api_1.HarkenError; } });
|
|
78
|
+
Object.defineProperty(exports, "HarkenApiError", { enumerable: true, get: function () { return api_1.HarkenApiError; } });
|
|
79
|
+
Object.defineProperty(exports, "HarkenNetworkError", { enumerable: true, get: function () { return api_1.HarkenNetworkError; } });
|
|
80
|
+
Object.defineProperty(exports, "withRetry", { enumerable: true, get: function () { return api_1.withRetry; } });
|
|
81
|
+
Object.defineProperty(exports, "DEFAULT_RETRY_CONFIG", { enumerable: true, get: function () { return api_1.DEFAULT_RETRY_CONFIG; } });
|
|
82
|
+
// Domain types
|
|
83
|
+
var domain_1 = require("./domain");
|
|
84
|
+
Object.defineProperty(exports, "UploadPhase", { enumerable: true, get: function () { return domain_1.UploadPhase; } });
|
|
85
|
+
Object.defineProperty(exports, "DEFAULT_UPLOAD_RETRY_CONFIG", { enumerable: true, get: function () { return domain_1.DEFAULT_UPLOAD_RETRY_CONFIG; } });
|
|
86
|
+
// Services (for advanced usage)
|
|
87
|
+
var services_1 = require("./services");
|
|
88
|
+
Object.defineProperty(exports, "UploadQueueService", { enumerable: true, get: function () { return services_1.UploadQueueService; } });
|
|
89
|
+
Object.defineProperty(exports, "uploadQueueService", { enumerable: true, get: function () { return services_1.uploadQueueService; } });
|
|
90
|
+
Object.defineProperty(exports, "UploadQueueStorage", { enumerable: true, get: function () { return services_1.UploadQueueStorage; } });
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,uBAAuB;AACvB,qCAA2C;AAAlC,yGAAA,cAAc,OAAA;AAGvB,eAAe;AACf,iCAKiB;AAJf,uGAAA,cAAc,OAAA;AACd,yGAAA,gBAAgB,OAAA;AAChB,uGAAA,cAAc,OAAA;AACd,oGAAA,WAAW,OAAA;AAIb,sBAAsB;AACtB,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA;AAM5B,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA;AAM5B,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA;AAe5B,iCASiB;AARf,oGAAA,WAAW,OAAA;AACX,mGAAA,UAAU,OAAA;AACV,0GAAA,iBAAiB,OAAA;AACjB,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,mGAAA,UAAU,OAAA;AACV,kGAAA,SAAS,OAAA;AACT,oGAAA,WAAW,OAAA;AAKb,qCAImB;AAHjB,mHAAA,wBAAwB,OAAA;AACxB,8GAAA,mBAAmB,OAAA;AACnB,wGAAA,aAAa,OAAA;AAGf,YAAY;AACZ,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AAErB,oBAAoB;AACpB,2CAOsB;AANpB,wGAAA,UAAU,OAAA;AACV,6GAAA,eAAe,OAAA;AACf,0GAAA,YAAY,OAAA;AACZ,8GAAA,gBAAgB,OAAA;AAChB,0GAAA,YAAY,OAAA;AACZ,gHAAA,kBAAkB,OAAA;AAepB,2BAA2B;AAC3B,2CAKsB;AAJpB,8GAAA,gBAAgB,OAAA;AAChB,iHAAA,mBAAmB,OAAA;AACnB,+GAAA,iBAAiB,OAAA;AACjB,4GAAA,cAAc,OAAA;AAahB,+CAA+C;AAC/C,6DAA4D;AAAnD,8GAAA,aAAa,OAAA;AAGtB,aAAa;AACb,6BAQe;AAPb,mGAAA,YAAY,OAAA;AACZ,yGAAA,kBAAkB,OAAA;AAClB,kGAAA,WAAW,OAAA;AACX,qGAAA,cAAc,OAAA;AACd,yGAAA,kBAAkB,OAAA;AAClB,gGAAA,SAAS,OAAA;AACT,2GAAA,oBAAoB,OAAA;AAatB,eAAe;AACf,mCAAoE;AAA3D,qGAAA,WAAW,OAAA;AAAE,qHAAA,2BAA2B,OAAA;AAQjD,gCAAgC;AAChC,uCAIoB;AAHlB,8GAAA,kBAAkB,OAAA;AAClB,8GAAA,kBAAkB,OAAA;AAClB,8GAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,wBAAwB,EACxB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UploadQueueStorage = exports.uploadQueueService = exports.UploadQueueService = void 0;
|
|
4
|
+
var uploadQueueService_1 = require("./uploadQueueService");
|
|
5
|
+
Object.defineProperty(exports, "UploadQueueService", { enumerable: true, get: function () { return uploadQueueService_1.UploadQueueService; } });
|
|
6
|
+
Object.defineProperty(exports, "uploadQueueService", { enumerable: true, get: function () { return uploadQueueService_1.uploadQueueService; } });
|
|
7
|
+
var uploadQueueStorage_1 = require("./uploadQueueStorage");
|
|
8
|
+
Object.defineProperty(exports, "UploadQueueStorage", { enumerable: true, get: function () { return uploadQueueStorage_1.UploadQueueStorage; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAG8B;AAF5B,wHAAA,kBAAkB,OAAA;AAClB,wHAAA,kBAAkB,OAAA;AAQpB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload Queue Service
|
|
3
|
+
*
|
|
4
|
+
* Singleton service that manages background attachment uploads.
|
|
5
|
+
* Uses expo-file-system/legacy for background upload support.
|
|
6
|
+
*
|
|
7
|
+
* Key design decisions (from feature spec):
|
|
8
|
+
* - D1: Uses expo-file-system/legacy with BACKGROUND session type
|
|
9
|
+
* - D2: Initialized once at app startup in HarkenProvider
|
|
10
|
+
* - D3: Persists queue to AsyncStorage
|
|
11
|
+
* - D4: Exponential backoff (2s base, 60s max, 3 attempts, 1s jitter)
|
|
12
|
+
* - D5: Auto-pause when offline via NetInfo
|
|
13
|
+
* - D6: Real progress tracking from expo-file-system
|
|
14
|
+
*/
|
|
15
|
+
import { HarkenClient } from '../api/client';
|
|
16
|
+
import { QueueItem, QueueStatus, UploadProgress, UploadRetryConfig } from '../domain';
|
|
17
|
+
type ProgressCallback = (progress: UploadProgress) => void;
|
|
18
|
+
type CompleteCallback = (attachmentId: string) => void;
|
|
19
|
+
type ErrorCallback = (attachmentId: string, error: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for initializing the upload queue service.
|
|
22
|
+
*/
|
|
23
|
+
export interface UploadQueueServiceConfig {
|
|
24
|
+
/** Configured HarkenClient instance */
|
|
25
|
+
client: HarkenClient;
|
|
26
|
+
/** Override retry configuration */
|
|
27
|
+
retryConfig?: Partial<UploadRetryConfig>;
|
|
28
|
+
/** Enable debug logging */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parameters for enqueuing a new upload.
|
|
33
|
+
*/
|
|
34
|
+
export interface EnqueueParams {
|
|
35
|
+
/** Local file URI (file://) */
|
|
36
|
+
localUri: string;
|
|
37
|
+
/** MIME type (e.g., 'image/png') */
|
|
38
|
+
mimeType: string;
|
|
39
|
+
/** Original filename */
|
|
40
|
+
fileName: string;
|
|
41
|
+
/** File size in bytes */
|
|
42
|
+
fileSize: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Singleton service for managing background attachment uploads.
|
|
46
|
+
*/
|
|
47
|
+
export declare class UploadQueueService {
|
|
48
|
+
private static instance;
|
|
49
|
+
private client;
|
|
50
|
+
private retryConfig;
|
|
51
|
+
private storage;
|
|
52
|
+
private debug;
|
|
53
|
+
private items;
|
|
54
|
+
private isProcessing;
|
|
55
|
+
private isPaused;
|
|
56
|
+
private isInitialized;
|
|
57
|
+
private activeTasks;
|
|
58
|
+
private progressListeners;
|
|
59
|
+
private completeListeners;
|
|
60
|
+
private errorListeners;
|
|
61
|
+
private networkUnsubscribe;
|
|
62
|
+
private retryTimerId;
|
|
63
|
+
private constructor();
|
|
64
|
+
/**
|
|
65
|
+
* Get the singleton instance.
|
|
66
|
+
*/
|
|
67
|
+
static getInstance(): UploadQueueService;
|
|
68
|
+
/**
|
|
69
|
+
* Initialize the queue service.
|
|
70
|
+
*
|
|
71
|
+
* Must be called once at app startup (in HarkenProvider).
|
|
72
|
+
* This prevents the race condition where uploads complete
|
|
73
|
+
* before callbacks are registered.
|
|
74
|
+
*
|
|
75
|
+
* Supports hot reload by updating the client reference on subsequent calls.
|
|
76
|
+
*/
|
|
77
|
+
initialize(config: UploadQueueServiceConfig): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Check if the service is initialized.
|
|
80
|
+
*/
|
|
81
|
+
get initialized(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Enqueue a new attachment for upload.
|
|
84
|
+
*
|
|
85
|
+
* This method:
|
|
86
|
+
* 1. Requests a presigned URL from the server
|
|
87
|
+
* 2. Creates a queue item
|
|
88
|
+
* 3. Persists the queue
|
|
89
|
+
* 4. Triggers queue processing
|
|
90
|
+
*
|
|
91
|
+
* Returns immediately with the attachment ID (upload happens in background).
|
|
92
|
+
*/
|
|
93
|
+
enqueue(params: EnqueueParams): Promise<{
|
|
94
|
+
attachmentId: string;
|
|
95
|
+
queueItemId: string;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Process the upload queue.
|
|
99
|
+
*
|
|
100
|
+
* Processes items sequentially (one at a time) to avoid memory pressure
|
|
101
|
+
* on low-end devices.
|
|
102
|
+
*/
|
|
103
|
+
processQueue(): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Process a single queue item.
|
|
106
|
+
*/
|
|
107
|
+
private processItem;
|
|
108
|
+
/**
|
|
109
|
+
* Upload file using expo-file-system background upload.
|
|
110
|
+
*
|
|
111
|
+
* Uses FileSystemSessionType.BACKGROUND for true background uploads
|
|
112
|
+
* that continue even when the app is backgrounded.
|
|
113
|
+
*/
|
|
114
|
+
private uploadFile;
|
|
115
|
+
/**
|
|
116
|
+
* Handle permanent item failure (max retries exceeded).
|
|
117
|
+
*/
|
|
118
|
+
private handleItemFailure;
|
|
119
|
+
/**
|
|
120
|
+
* Calculate retry delay with exponential backoff and jitter (D4).
|
|
121
|
+
*/
|
|
122
|
+
private calculateRetryDelay;
|
|
123
|
+
/**
|
|
124
|
+
* Get next item that's ready to process.
|
|
125
|
+
*/
|
|
126
|
+
private getNextQueuedItem;
|
|
127
|
+
/**
|
|
128
|
+
* Schedule a timer to wake up processQueue when the next retry is due.
|
|
129
|
+
* This prevents retries from stalling indefinitely.
|
|
130
|
+
*/
|
|
131
|
+
private scheduleNextRetry;
|
|
132
|
+
/**
|
|
133
|
+
* Clear any pending retry timer.
|
|
134
|
+
*/
|
|
135
|
+
private clearRetryTimer;
|
|
136
|
+
private setupNetworkMonitoring;
|
|
137
|
+
private emitProgress;
|
|
138
|
+
private emitComplete;
|
|
139
|
+
private emitError;
|
|
140
|
+
/**
|
|
141
|
+
* Subscribe to progress updates.
|
|
142
|
+
* @returns Unsubscribe function
|
|
143
|
+
*/
|
|
144
|
+
onProgress(callback: ProgressCallback): () => void;
|
|
145
|
+
/**
|
|
146
|
+
* Subscribe to upload completions.
|
|
147
|
+
* @returns Unsubscribe function
|
|
148
|
+
*/
|
|
149
|
+
onComplete(callback: CompleteCallback): () => void;
|
|
150
|
+
/**
|
|
151
|
+
* Subscribe to upload errors.
|
|
152
|
+
* @returns Unsubscribe function
|
|
153
|
+
*/
|
|
154
|
+
onError(callback: ErrorCallback): () => void;
|
|
155
|
+
/**
|
|
156
|
+
* Get current queue status.
|
|
157
|
+
*/
|
|
158
|
+
getQueueStatus(): QueueStatus;
|
|
159
|
+
/**
|
|
160
|
+
* Get a queue item by attachment ID.
|
|
161
|
+
*/
|
|
162
|
+
getItemByAttachmentId(attachmentId: string): QueueItem | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Retry a failed upload.
|
|
165
|
+
*/
|
|
166
|
+
retryItem(attachmentId: string): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Cancel and remove an item from the queue.
|
|
169
|
+
*/
|
|
170
|
+
cancelItem(attachmentId: string): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Clear all completed items from the queue.
|
|
173
|
+
*/
|
|
174
|
+
clearCompleted(): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Clear all failed items from the queue.
|
|
177
|
+
*/
|
|
178
|
+
clearFailed(): Promise<void>;
|
|
179
|
+
private persistQueue;
|
|
180
|
+
private sleep;
|
|
181
|
+
private log;
|
|
182
|
+
/**
|
|
183
|
+
* Destroy the service instance.
|
|
184
|
+
* Used primarily for testing.
|
|
185
|
+
*/
|
|
186
|
+
destroy(): void;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Singleton instance getter.
|
|
190
|
+
*/
|
|
191
|
+
export declare const uploadQueueService: UploadQueueService;
|
|
192
|
+
export {};
|
|
193
|
+
//# sourceMappingURL=uploadQueueService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadQueueService.d.ts","sourceRoot":"","sources":["../../src/services/uploadQueueService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EACL,SAAS,EACT,WAAW,EAEX,cAAc,EACd,iBAAiB,EAElB,MAAM,WAAW,CAAC;AAInB,KAAK,gBAAgB,GAAG,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;AAC3D,KAAK,gBAAgB,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;AACvD,KAAK,aAAa,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,MAAM,EAAE,YAAY,CAAC;IACrB,mCAAmC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;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