@apple-pie/slice 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chunks/{IndexedDB-BxQn7aHU.js → IndexedDB-BaVmQgkK.js} +12 -10
- package/dist/cjs/chunks/{PromptInput-B-Wlfnhx.js → PromptInput-D317oh1e.js} +1 -1
- package/dist/cjs/chunks/{TextArea-D7E8loob.js → TextArea-2w4E6d2H.js} +1 -1
- package/dist/cjs/chunks/{UploadArea-Bfrwzo4O.js → UploadArea-CxYAAs7Q.js} +1 -1
- package/dist/cjs/chunks/localDBStore-BHEk_9fJ.js +257 -0
- package/dist/cjs/components/PromptInput/index.js +1 -1
- package/dist/cjs/components/TextArea/index.js +1 -1
- package/dist/cjs/components/UploadArea/index.js +7 -8
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/stores/LocalDB.js +6 -5
- package/dist/cjs/stores.js +7 -7
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/objects/index.js +1 -1
- package/dist/css/flexBox.module.css +85 -0
- package/dist/css/type.module.css +206 -0
- package/dist/esm/chunks/{IndexedDB-CNOziQ6p.mjs → IndexedDB-CJgzPHPB.mjs} +12 -10
- package/dist/esm/chunks/{TextArea-Ff5hxF1H.mjs → TextArea-DKRF4Irr.mjs} +1 -1
- package/dist/esm/chunks/localDBStore-C-Ch2MFq.mjs +265 -0
- package/dist/esm/components/PromptInput/index.mjs +1 -1
- package/dist/esm/components/TextArea/index.mjs +1 -1
- package/dist/esm/components/UploadArea/index.mjs +6 -6
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/stores/LocalDB.mjs +6 -2
- package/dist/esm/stores.mjs +6 -2
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/objects/index.mjs +1 -1
- package/dist/types/components/Avatar/Avatar.d.ts +3 -0
- package/dist/types/components/Avatar/_types.d.ts +22 -0
- package/dist/types/components/Avatar/index.d.ts +2 -0
- package/dist/types/components/AvatarGroup/AvatarGroup.d.ts +3 -0
- package/dist/types/components/AvatarGroup/_types.d.ts +25 -0
- package/dist/types/components/AvatarGroup/index.d.ts +2 -0
- package/dist/types/components/Badge/Badge.d.ts +3 -0
- package/dist/types/components/Badge/_types.d.ts +8 -0
- package/dist/types/components/Badge/index.d.ts +2 -0
- package/dist/types/components/Button/Button.d.ts +76 -0
- package/dist/types/components/Button/_types.d.ts +45 -0
- package/dist/types/components/Button/index.d.ts +2 -0
- package/dist/types/components/ButtonBar/ButtonBar.d.ts +17 -0
- package/dist/types/components/ButtonBar/_types.d.ts +27 -0
- package/dist/types/components/ButtonBar/index.d.ts +2 -0
- package/dist/types/components/Camera/Camera.d.ts +11 -0
- package/dist/types/components/Camera/_types.d.ts +79 -0
- package/dist/types/components/Camera/index.d.ts +2 -0
- package/dist/types/components/CheckBox/CheckBox.d.ts +3 -0
- package/dist/types/components/CheckBox/_types.d.ts +11 -0
- package/dist/types/components/CheckBox/index.d.ts +2 -0
- package/dist/types/components/Chip/Chip.d.ts +3 -0
- package/dist/types/components/Chip/_types.d.ts +31 -0
- package/dist/types/components/Chip/index.d.ts +3 -0
- package/dist/types/components/DivInput/DivInput.d.ts +3 -0
- package/dist/types/components/DivInput/_types.d.ts +23 -0
- package/dist/types/components/DivInput/index.d.ts +2 -0
- package/dist/types/components/Dot/Dot.d.ts +3 -0
- package/dist/types/components/Dot/_types.d.ts +19 -0
- package/dist/types/components/Dot/index.d.ts +2 -0
- package/dist/types/components/DraggablePanel/DrggablePanel.d.ts +44 -0
- package/dist/types/components/DraggablePanel/_types.d.ts +5 -0
- package/dist/types/components/DraggablePanel/index.d.ts +1 -0
- package/dist/types/components/DropDown/DropDown.d.ts +4 -0
- package/dist/types/components/DropDown/_types.d.ts +34 -0
- package/dist/types/components/DropDown/index.d.ts +2 -0
- package/dist/types/components/ErrorSummary/ErrorSummary.d.ts +4 -0
- package/dist/types/components/ErrorSummary/_types.d.ts +12 -0
- package/dist/types/components/ErrorSummary/index.d.ts +2 -0
- package/dist/types/components/FileIcon/FileIcon.d.ts +3 -0
- package/dist/types/components/FileIcon/_types.d.ts +27 -0
- package/dist/types/components/FileIcon/fileIconRegistry.d.ts +4 -0
- package/dist/types/components/FileIcon/index.d.ts +3 -0
- package/dist/types/components/FileList/FileList.d.ts +3 -0
- package/dist/types/components/FileList/_types.d.ts +24 -0
- package/dist/types/components/FileList/index.d.ts +2 -0
- package/dist/types/components/FlexDiv/FlexDiv.d.ts +60 -0
- package/dist/types/components/FlexDiv/_types.d.ts +34 -0
- package/dist/types/components/FlexDiv/index.d.ts +2 -0
- package/dist/types/components/Grouper/Grouper.d.ts +3 -0
- package/dist/types/components/Grouper/_types.d.ts +20 -0
- package/dist/types/components/Grouper/index.d.ts +2 -0
- package/dist/types/components/Icon/Icon.d.ts +3 -0
- package/dist/types/components/Icon/_types.d.ts +131 -0
- package/dist/types/components/Icon/iconRegistry.d.ts +17 -0
- package/dist/types/components/Icon/index.d.ts +2 -0
- package/dist/types/components/IconButton/IconButton.d.ts +3 -0
- package/dist/types/components/IconButton/_types.d.ts +34 -0
- package/dist/types/components/IconButton/index.d.ts +2 -0
- package/dist/types/components/Label/Label.d.ts +2 -0
- package/dist/types/components/Label/_types.d.ts +16 -0
- package/dist/types/components/Label/index.d.ts +2 -0
- package/dist/types/components/Overlay/Overlay.d.ts +3 -0
- package/dist/types/components/Overlay/_types.d.ts +12 -0
- package/dist/types/components/Overlay/index.d.ts +2 -0
- package/dist/types/components/Pager/Pager.d.ts +3 -0
- package/dist/types/components/Pager/_types.d.ts +13 -0
- package/dist/types/components/Pager/index.d.ts +2 -0
- package/dist/types/components/Progress/DoneCheck/DoneCheck.d.ts +3 -0
- package/dist/types/components/Progress/DoneCheck/_types.d.ts +13 -0
- package/dist/types/components/Progress/ProgressIndicator/ProgressIndicator.d.ts +3 -0
- package/dist/types/components/Progress/ProgressIndicator/_types.d.ts +14 -0
- package/dist/types/components/Progress/index.d.ts +4 -0
- package/dist/types/components/PromptInput/PromptInput.d.ts +63 -0
- package/dist/types/components/PromptInput/_types.d.ts +35 -0
- package/dist/types/components/PromptInput/index.d.ts +2 -0
- package/dist/types/components/RadioButton/RadioButton.d.ts +3 -0
- package/dist/types/components/RadioButton/_types.d.ts +26 -0
- package/dist/types/components/RadioButton/index.d.ts +2 -0
- package/dist/types/components/RadioButtonList/RadioButtonList.d.ts +3 -0
- package/dist/types/components/RadioButtonList/_types.d.ts +24 -0
- package/dist/types/components/RadioButtonList/index.d.ts +2 -0
- package/dist/types/components/Slider/Slider.d.ts +3 -0
- package/dist/types/components/Slider/_types.d.ts +18 -0
- package/dist/types/components/Slider/index.d.ts +2 -0
- package/dist/types/components/Spacer/Spacer.d.ts +3 -0
- package/dist/types/components/Spacer/_types.d.ts +6 -0
- package/dist/types/components/Spacer/index.d.ts +2 -0
- package/dist/types/components/Switch/Switch.d.ts +3 -0
- package/dist/types/components/Switch/Switch.stories.d.ts +5 -0
- package/dist/types/components/Switch/_types.d.ts +13 -0
- package/dist/types/components/Switch/index.d.ts +2 -0
- package/dist/types/components/TabBar/TabBar.d.ts +3 -0
- package/dist/types/components/TabBar/_types.d.ts +52 -0
- package/dist/types/components/TabBar/index.d.ts +2 -0
- package/dist/types/components/TextArea/TextArea.d.ts +3 -0
- package/dist/types/components/TextArea/_types.d.ts +41 -0
- package/dist/types/components/TextArea/index.d.ts +2 -0
- package/dist/types/components/Textfield/TextField.d.ts +3 -0
- package/dist/types/components/Textfield/_types.d.ts +79 -0
- package/dist/types/components/Textfield/index.d.ts +2 -0
- package/dist/types/components/Tip/Tip.d.ts +3 -0
- package/dist/types/components/Tip/_types.d.ts +28 -0
- package/dist/types/components/Tip/index.d.ts +2 -0
- package/dist/types/components/Toast/Toast.d.ts +3 -0
- package/dist/types/components/Toast/_types.d.ts +24 -0
- package/dist/types/components/Toast/index.d.ts +2 -0
- package/dist/types/components/UploadArea/UploadArea.d.ts +54 -0
- package/dist/types/components/UploadArea/_types.d.ts +46 -0
- package/dist/types/components/UploadArea/index.d.ts +3 -0
- package/dist/types/components/playHelpers.d.ts +35 -0
- package/dist/types/components/sharedTypes.d.ts +21 -0
- package/dist/types/hooks/index.d.ts +9 -0
- package/dist/types/hooks/useDoubleClick/useDoubleClick.d.ts +1 -0
- package/dist/types/hooks/useKeyboardShortcuts/useKeyboardShortcuts.d.ts +9 -0
- package/dist/types/hooks/useLastUpdated/useLastUpdated.d.ts +4 -0
- package/dist/types/hooks/useLocalStore/useLocalStore.d.ts +1 -0
- package/dist/types/hooks/useObserveResize/useObserveResize.d.ts +9 -0
- package/dist/types/hooks/useObserveTheme/useObserveTheme.d.ts +2 -0
- package/dist/types/hooks/useTheme/useTheme.d.ts +47 -0
- package/dist/types/hooks/useToolTip/useToolTip.d.ts +6 -0
- package/dist/types/hooks/useTrackRenders/useTrackRenders.d.ts +5 -0
- package/dist/types/hooks/useWindow/useWindow.d.ts +43 -0
- package/dist/types/index.d.ts +74 -0
- package/dist/types/providers/ThemeProvider.d.ts +13 -0
- package/dist/types/providers/index.d.ts +1 -0
- package/dist/types/stores/LocalDB/_types.d.ts +43 -0
- package/dist/types/stores/LocalDB/index.d.ts +2 -0
- package/dist/types/stores/LocalDB/localDBStore.d.ts +18 -0
- package/dist/types/stores/SSE/_types.d.ts +17 -0
- package/dist/types/stores/SSE/index.d.ts +2 -0
- package/dist/types/stores/SSE/sseStore.d.ts +28 -0
- package/dist/types/stores/WS/_types.d.ts +17 -0
- package/dist/types/stores/WS/index.d.ts +2 -0
- package/dist/types/stores/WS/wsStore.d.ts +19 -0
- package/dist/types/stores/index.d.ts +6 -0
- package/dist/types/stores/tip/_types.d.ts +8 -0
- package/dist/types/stores/tip/index.d.ts +2 -0
- package/dist/types/stores/tip/tipStore.d.ts +12 -0
- package/dist/types/stores/toast/_types.d.ts +14 -0
- package/dist/types/stores/toast/index.d.ts +2 -0
- package/dist/types/stores/toast/toastStore.d.ts +12 -0
- package/dist/types/stores/uploads/_types.d.ts +16 -0
- package/dist/types/stores/uploads/index.d.ts +2 -0
- package/dist/types/stores/uploads/uploadsStore.d.ts +22 -0
- package/dist/types/stores/window/_types.d.ts +33 -0
- package/dist/types/stores/window/index.d.ts +3 -0
- package/dist/types/stores/window/windowStore.d.ts +25 -0
- package/dist/types/theme/colors/colors.d.ts +6 -0
- package/dist/types/theme/colors/types.d.ts +174 -0
- package/dist/types/theme/corners/corners.d.ts +2 -0
- package/dist/types/theme/corners/types.d.ts +10 -0
- package/dist/types/theme/elevations/_types.d.ts +10 -0
- package/dist/types/theme/elevations/elevations.d.ts +5 -0
- package/dist/types/theme/index.d.ts +9 -0
- package/dist/types/theme/motion/_types.d.ts +8 -0
- package/dist/types/theme/motion/motion.d.ts +5 -0
- package/dist/types/theme/themes.d.ts +16 -0
- package/dist/types/theme/type/type.d.ts +5 -0
- package/dist/types/theme/type/types.d.ts +25 -0
- package/dist/types/utils/functions/colors.d.ts +8 -0
- package/dist/types/utils/functions/debounce.d.ts +9 -0
- package/dist/types/utils/functions/files.d.ts +15 -0
- package/dist/types/utils/functions/misc.d.ts +61 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/objects/IndexedDB/IndexedDB.d.ts +62 -0
- package/dist/types/utils/objects/SSEConnection/SSEConnection.d.ts +187 -0
- package/dist/types/utils/objects/WSConnection/WSConnection.d.ts +159 -0
- package/dist/types/utils/objects/index.d.ts +6 -0
- package/dist/types/workers/uploads/uploads-worker.d.ts +129 -0
- package/dist/types/workers/uploads/uploads.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/chunks/localDBStore-Cl1YFPIe.js +0 -182
- package/dist/esm/chunks/localDBStore-CbCoeN66.mjs +0 -186
- package/dist/esm/chunks/{PromptInput-Cmist_vy.mjs → PromptInput-C6liKbFf.mjs} +2 -2
- package/dist/esm/chunks/{UploadArea-6z-mVZs3.mjs → UploadArea-DNAH-Bu5.mjs} +2 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export declare enum FileUploadStatus {
|
|
2
|
+
queued = "pending",
|
|
3
|
+
uploading = "uploading",
|
|
4
|
+
completed = "completed",
|
|
5
|
+
failed = "failed"
|
|
6
|
+
}
|
|
7
|
+
export declare enum UploadError {
|
|
8
|
+
SizeExceedsLimit = "size exceed limit",
|
|
9
|
+
TypeNotAllowed = "file type not allowed",
|
|
10
|
+
UploadFailed = "upload failed",
|
|
11
|
+
UploadURLNotFound = "invalid upload url",
|
|
12
|
+
AccessForbidden = "upload access forbidden",
|
|
13
|
+
NotAuthorized = "upload not authorized on server",
|
|
14
|
+
TooLarge = "payload too large for server",
|
|
15
|
+
MediaNotSupported = "server does not supported file type",
|
|
16
|
+
InternalError = "Internal server error",
|
|
17
|
+
Other = "Other server error"
|
|
18
|
+
}
|
|
19
|
+
export type Upload = {
|
|
20
|
+
id: string;
|
|
21
|
+
file: File;
|
|
22
|
+
uploadURL?: string;
|
|
23
|
+
status: FileUploadStatus;
|
|
24
|
+
error?: UploadError;
|
|
25
|
+
progress?: number;
|
|
26
|
+
};
|
|
27
|
+
export type UploadInput = {
|
|
28
|
+
file: File;
|
|
29
|
+
uploadURL?: string;
|
|
30
|
+
};
|
|
31
|
+
export type ConfigurationOptions = {
|
|
32
|
+
uploadURL: string;
|
|
33
|
+
maxQueueSize?: number;
|
|
34
|
+
maxFileSize?: number;
|
|
35
|
+
accepted?: string[];
|
|
36
|
+
maxConcurrentUploads?: number;
|
|
37
|
+
};
|
|
38
|
+
export type UploadStatusMessage = {
|
|
39
|
+
type: 'status';
|
|
40
|
+
uploads: Upload[];
|
|
41
|
+
workerStatus: WorkerStatus;
|
|
42
|
+
};
|
|
43
|
+
export type UploadWorkerErrorMessage = {
|
|
44
|
+
type: 'error';
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
export type UploadWorkerMessage = {
|
|
48
|
+
type: 'initialize';
|
|
49
|
+
options: ConfigurationOptions;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'add-files';
|
|
52
|
+
files: UploadInput[];
|
|
53
|
+
} | {
|
|
54
|
+
type: 'clear-uploads';
|
|
55
|
+
};
|
|
56
|
+
export type UploadWorkerResponse = UploadStatusMessage | UploadWorkerErrorMessage;
|
|
57
|
+
export interface UploadWorkerBridge {
|
|
58
|
+
updateStatus(status: Upload[]): void;
|
|
59
|
+
}
|
|
60
|
+
export declare enum WorkerStatus {
|
|
61
|
+
Idle = "idle",
|
|
62
|
+
Busy = "busy"
|
|
63
|
+
}
|
|
64
|
+
export declare class UploadWorkerClient implements UploadWorkerBridge {
|
|
65
|
+
private readonly target;
|
|
66
|
+
private readonly getWorkerStatus;
|
|
67
|
+
constructor(target: {
|
|
68
|
+
postMessage: (message: UploadWorkerResponse) => void;
|
|
69
|
+
}, getWorkerStatus: () => WorkerStatus);
|
|
70
|
+
updateStatus(status: Upload[]): void;
|
|
71
|
+
}
|
|
72
|
+
type UploadWorkerTarget = {
|
|
73
|
+
onmessage: ((event: MessageEvent<UploadWorkerMessage>) => void) | null;
|
|
74
|
+
postMessage: (message: UploadWorkerResponse) => void;
|
|
75
|
+
};
|
|
76
|
+
export declare class UploadsWorker {
|
|
77
|
+
private readonly uploadURL;
|
|
78
|
+
private readonly maxQueueSize;
|
|
79
|
+
private readonly maxFileSize;
|
|
80
|
+
private readonly accepted;
|
|
81
|
+
private readonly maxConcurrentUploads;
|
|
82
|
+
private readonly worker;
|
|
83
|
+
private readonly queue;
|
|
84
|
+
private readonly active;
|
|
85
|
+
private readonly completed;
|
|
86
|
+
private readonly failed;
|
|
87
|
+
private workerStatus;
|
|
88
|
+
constructor(options: ConfigurationOptions, worker?: UploadWorkerBridge);
|
|
89
|
+
/**
|
|
90
|
+
* Add new files to the upload queue
|
|
91
|
+
*/
|
|
92
|
+
addFiles(file: UploadInput | File | Array<UploadInput | File>): void;
|
|
93
|
+
/**
|
|
94
|
+
* Stop activity and flush all maps / data
|
|
95
|
+
*/
|
|
96
|
+
clearUploads(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Start the processing files in the upload queue
|
|
99
|
+
*/
|
|
100
|
+
process(): void;
|
|
101
|
+
get status(): WorkerStatus;
|
|
102
|
+
private startUpload;
|
|
103
|
+
/**
|
|
104
|
+
* perform the actual upload
|
|
105
|
+
*/
|
|
106
|
+
private uploadFile;
|
|
107
|
+
/**
|
|
108
|
+
* Update the active upload with new data
|
|
109
|
+
*/
|
|
110
|
+
private updateUploadStatus;
|
|
111
|
+
/**
|
|
112
|
+
* Create array with the current state of all uploads
|
|
113
|
+
*/
|
|
114
|
+
private currentStatus;
|
|
115
|
+
/**
|
|
116
|
+
* Push status updates to the web worker
|
|
117
|
+
*/
|
|
118
|
+
private notifyStatus;
|
|
119
|
+
}
|
|
120
|
+
export declare class UploadsWorkerRuntime {
|
|
121
|
+
private readonly target;
|
|
122
|
+
private uploads;
|
|
123
|
+
constructor(target: UploadWorkerTarget);
|
|
124
|
+
private handleMessage;
|
|
125
|
+
private getWorkerStatus;
|
|
126
|
+
private postError;
|
|
127
|
+
}
|
|
128
|
+
export declare function registerUploadsWorker(target?: UploadWorkerTarget): UploadsWorkerRuntime;
|
|
129
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var tslib_es6 = require("./tslib.es6-C8dZW5nY.js"), zustand = require("zustand"), IndexedDB = require("./IndexedDB-BxQn7aHU.js");
|
|
4
|
-
|
|
5
|
-
function isValidIDBKey(key) {
|
|
6
|
-
return "string" == typeof key || "number" == typeof key || key instanceof Date || key instanceof ArrayBuffer || (Array.isArray(key) ? key.every(entry => isValidIDBKey(entry)) : ArrayBuffer.isView(key));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function areKeysEqual(left, right) {
|
|
10
|
-
return left instanceof Date && right instanceof Date ? left.getTime() === right.getTime() : Array.isArray(left) && Array.isArray(right) ? left.length === right.length && left.every((value, index) => areKeysEqual(value, right[index])) : left === right;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function normalizeValues(value) {
|
|
14
|
-
return Array.isArray(value) ? value : [ value ];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function readStoreRecords(connection) {
|
|
18
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function*() {
|
|
19
|
-
const [keys, values] = yield Promise.all([ connection.getAllKeys(), connection.getAll() ]);
|
|
20
|
-
return keys.map((key, index) => {
|
|
21
|
-
var _a;
|
|
22
|
-
return {
|
|
23
|
-
key: key,
|
|
24
|
-
value: null !== (_a = values[index]) && void 0 !== _a ? _a : null
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getConnection(stores, name) {
|
|
31
|
-
const connection = stores.find(entry => entry.name === name);
|
|
32
|
-
if (!connection) throw new Error(`IndexedDB store "${name}" is not registered.`);
|
|
33
|
-
return connection;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function applyConnectionState(name, patch) {
|
|
37
|
-
useLocalDBStore.setState(state => ({
|
|
38
|
-
stores: state.stores.map(entry => entry.name === name ? Object.assign(Object.assign({}, entry), patch) : entry)
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function applyStoreError(name, error) {
|
|
43
|
-
applyConnectionState(name, {
|
|
44
|
-
error: error instanceof Error ? error.message : String(error)
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function deriveRecordKey(store, value) {
|
|
49
|
-
const keyField = function(store) {
|
|
50
|
-
if (!store.key) throw new Error(`IndexedDB store "${store.name}" requires a configured key field for value-driven actions.`);
|
|
51
|
-
return store.key;
|
|
52
|
-
}(store);
|
|
53
|
-
if (!value || "object" != typeof value) throw new Error(`IndexedDB store "${store.name}" expects object values for value-driven actions.`);
|
|
54
|
-
const candidate = value[keyField];
|
|
55
|
-
if (void 0 === candidate) throw new Error(`IndexedDB store "${store.name}" expected field "${keyField}" on the provided value.`);
|
|
56
|
-
if (!isValidIDBKey(candidate)) throw new Error(`IndexedDB store "${store.name}" field "${keyField}" does not contain a valid IndexedDB key.`);
|
|
57
|
-
return candidate;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const useLocalDBStore = zustand.create((set, get) => ({
|
|
61
|
-
stores: [],
|
|
62
|
-
actions: {
|
|
63
|
-
addStore: (name_1, ...args_1) => tslib_es6.__awaiter(void 0, [ name_1, ...args_1 ], void 0, function*(name, options = {}) {
|
|
64
|
-
var _a;
|
|
65
|
-
const existing = get().stores.find(entry => entry.name === name);
|
|
66
|
-
yield null == existing ? void 0 : existing.connection.close();
|
|
67
|
-
const {create: create = !0} = options, connectionOptions = tslib_es6.__rest(options, [ "create" ]), connection = new IndexedDB.IndexedDB(name, connectionOptions);
|
|
68
|
-
yield connection.initialize(create);
|
|
69
|
-
const records = yield readStoreRecords(connection);
|
|
70
|
-
!function(connection) {
|
|
71
|
-
useLocalDBStore.setState(state => ({
|
|
72
|
-
stores: [ ...state.stores.filter(entry => entry.name !== connection.name), connection ]
|
|
73
|
-
}));
|
|
74
|
-
}({
|
|
75
|
-
name: name,
|
|
76
|
-
connection: connection,
|
|
77
|
-
key: null !== (_a = options.key) && void 0 !== _a ? _a : null,
|
|
78
|
-
records: records,
|
|
79
|
-
initialized: !0,
|
|
80
|
-
error: null
|
|
81
|
-
});
|
|
82
|
-
}),
|
|
83
|
-
removeStore: name => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
84
|
-
const existing = get().stores.find(entry => entry.name === name);
|
|
85
|
-
existing && (yield existing.connection.close(), set(state => ({
|
|
86
|
-
stores: state.stores.filter(entry => entry.name !== name)
|
|
87
|
-
})));
|
|
88
|
-
}),
|
|
89
|
-
refreshStore: name => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
90
|
-
const existing = getConnection(get().stores, name), records = yield readStoreRecords(existing.connection);
|
|
91
|
-
applyConnectionState(name, {
|
|
92
|
-
records: records,
|
|
93
|
-
initialized: !0,
|
|
94
|
-
error: null
|
|
95
|
-
});
|
|
96
|
-
}),
|
|
97
|
-
setValue: (name, value) => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
98
|
-
const existing = getConnection(get().stores, name);
|
|
99
|
-
try {
|
|
100
|
-
const values = normalizeValues(value), resolvedKeys = [];
|
|
101
|
-
for (const item of values) {
|
|
102
|
-
const key = deriveRecordKey(existing, item), resolvedKey = yield existing.connection.set(key, item);
|
|
103
|
-
resolvedKeys.push(resolvedKey);
|
|
104
|
-
}
|
|
105
|
-
const records = yield readStoreRecords(existing.connection);
|
|
106
|
-
return applyConnectionState(name, {
|
|
107
|
-
records: records,
|
|
108
|
-
error: null
|
|
109
|
-
}), Array.isArray(value) ? resolvedKeys : resolvedKeys[0];
|
|
110
|
-
} catch (error) {
|
|
111
|
-
throw applyStoreError(name, error), error;
|
|
112
|
-
}
|
|
113
|
-
}),
|
|
114
|
-
addValue: (name, value) => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
115
|
-
const existing = getConnection(get().stores, name);
|
|
116
|
-
try {
|
|
117
|
-
const values = normalizeValues(value), resolvedKeys = [];
|
|
118
|
-
for (const item of values) {
|
|
119
|
-
const resolvedKey = yield existing.connection.add(item);
|
|
120
|
-
resolvedKeys.push(resolvedKey);
|
|
121
|
-
}
|
|
122
|
-
const records = yield readStoreRecords(existing.connection);
|
|
123
|
-
return applyConnectionState(name, {
|
|
124
|
-
records: records,
|
|
125
|
-
error: null
|
|
126
|
-
}), Array.isArray(value) ? resolvedKeys : resolvedKeys[0];
|
|
127
|
-
} catch (error) {
|
|
128
|
-
throw applyStoreError(name, error), error;
|
|
129
|
-
}
|
|
130
|
-
}),
|
|
131
|
-
removeValue: (name, value) => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
132
|
-
const existing = getConnection(get().stores, name);
|
|
133
|
-
try {
|
|
134
|
-
const values = normalizeValues(value);
|
|
135
|
-
for (const item of values) {
|
|
136
|
-
const key = deriveRecordKey(existing, item);
|
|
137
|
-
yield existing.connection.remove(key);
|
|
138
|
-
}
|
|
139
|
-
const records = yield readStoreRecords(existing.connection);
|
|
140
|
-
applyConnectionState(name, {
|
|
141
|
-
records: records,
|
|
142
|
-
error: null
|
|
143
|
-
});
|
|
144
|
-
} catch (error) {
|
|
145
|
-
throw applyStoreError(name, error), error;
|
|
146
|
-
}
|
|
147
|
-
}),
|
|
148
|
-
clearStore: name => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
149
|
-
const existing = getConnection(get().stores, name);
|
|
150
|
-
yield existing.connection.clear(), applyConnectionState(name, {
|
|
151
|
-
records: [],
|
|
152
|
-
error: null
|
|
153
|
-
});
|
|
154
|
-
}),
|
|
155
|
-
destroyStore: name => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
156
|
-
const existing = get().stores.find(entry => entry.name === name);
|
|
157
|
-
existing && (yield existing.connection.destroy(), set(state => ({
|
|
158
|
-
stores: state.stores.filter(entry => entry.name !== name)
|
|
159
|
-
})));
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
}));
|
|
163
|
-
|
|
164
|
-
const localDBActions = useLocalDBStore.getState().actions;
|
|
165
|
-
|
|
166
|
-
exports.localDBActions = localDBActions, exports.useLocalDB = name => useLocalDBStore(state => ({
|
|
167
|
-
refresh: () => state.actions.refreshStore(name),
|
|
168
|
-
set: value => state.actions.setValue(name, value),
|
|
169
|
-
add: value => state.actions.addValue(name, value),
|
|
170
|
-
remove: value => state.actions.removeValue(name, value),
|
|
171
|
-
clear: () => state.actions.clearStore(name),
|
|
172
|
-
destroy: () => state.actions.destroyStore(name)
|
|
173
|
-
})), exports.useLocalDBError = name => useLocalDBStore(state => {
|
|
174
|
-
var _a, _b;
|
|
175
|
-
return null !== (_b = null === (_a = state.stores.find(entry => entry.name === name)) || void 0 === _a ? void 0 : _a.error) && void 0 !== _b ? _b : null;
|
|
176
|
-
}), exports.useLocalDBStore = useLocalDBStore, exports.useLocalDBValues = function(name, fieldOrKey, value) {
|
|
177
|
-
return useLocalDBStore(state => {
|
|
178
|
-
var _a, _b, _c, _d;
|
|
179
|
-
const records = null !== (_b = null === (_a = state.stores.find(entry => entry.name === name)) || void 0 === _a ? void 0 : _a.records) && void 0 !== _b ? _b : [], values = records.map(record => record.value);
|
|
180
|
-
return void 0 === fieldOrKey ? values : void 0 === value ? null !== (_d = null === (_c = records.find(record => areKeysEqual(record.key, fieldOrKey))) || void 0 === _c ? void 0 : _c.value) && void 0 !== _d ? _d : null : values.filter(entry => (null == entry ? void 0 : entry[fieldOrKey]) === value);
|
|
181
|
-
});
|
|
182
|
-
};
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { a as __awaiter, _ as __rest } from "./tslib.es6-c-7TIv71.mjs";
|
|
2
|
-
|
|
3
|
-
import { create } from "zustand";
|
|
4
|
-
|
|
5
|
-
import { I as IndexedDB } from "./IndexedDB-CNOziQ6p.mjs";
|
|
6
|
-
|
|
7
|
-
function isValidIDBKey(key) {
|
|
8
|
-
return "string" == typeof key || "number" == typeof key || key instanceof Date || key instanceof ArrayBuffer || (Array.isArray(key) ? key.every(entry => isValidIDBKey(entry)) : ArrayBuffer.isView(key));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function areKeysEqual(left, right) {
|
|
12
|
-
return left instanceof Date && right instanceof Date ? left.getTime() === right.getTime() : Array.isArray(left) && Array.isArray(right) ? left.length === right.length && left.every((value, index) => areKeysEqual(value, right[index])) : left === right;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function normalizeValues(value) {
|
|
16
|
-
return Array.isArray(value) ? value : [ value ];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function readStoreRecords(connection) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function*() {
|
|
21
|
-
const [keys, values] = yield Promise.all([ connection.getAllKeys(), connection.getAll() ]);
|
|
22
|
-
return keys.map((key, index) => {
|
|
23
|
-
var _a;
|
|
24
|
-
return {
|
|
25
|
-
key: key,
|
|
26
|
-
value: null !== (_a = values[index]) && void 0 !== _a ? _a : null
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getConnection(stores, name) {
|
|
33
|
-
const connection = stores.find(entry => entry.name === name);
|
|
34
|
-
if (!connection) throw new Error(`IndexedDB store "${name}" is not registered.`);
|
|
35
|
-
return connection;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function applyConnectionState(name, patch) {
|
|
39
|
-
useLocalDBStore.setState(state => ({
|
|
40
|
-
stores: state.stores.map(entry => entry.name === name ? Object.assign(Object.assign({}, entry), patch) : entry)
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function applyStoreError(name, error) {
|
|
45
|
-
applyConnectionState(name, {
|
|
46
|
-
error: error instanceof Error ? error.message : String(error)
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function deriveRecordKey(store, value) {
|
|
51
|
-
const keyField = function(store) {
|
|
52
|
-
if (!store.key) throw new Error(`IndexedDB store "${store.name}" requires a configured key field for value-driven actions.`);
|
|
53
|
-
return store.key;
|
|
54
|
-
}(store);
|
|
55
|
-
if (!value || "object" != typeof value) throw new Error(`IndexedDB store "${store.name}" expects object values for value-driven actions.`);
|
|
56
|
-
const candidate = value[keyField];
|
|
57
|
-
if (void 0 === candidate) throw new Error(`IndexedDB store "${store.name}" expected field "${keyField}" on the provided value.`);
|
|
58
|
-
if (!isValidIDBKey(candidate)) throw new Error(`IndexedDB store "${store.name}" field "${keyField}" does not contain a valid IndexedDB key.`);
|
|
59
|
-
return candidate;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const useLocalDBStore = create((set, get) => ({
|
|
63
|
-
stores: [],
|
|
64
|
-
actions: {
|
|
65
|
-
addStore: (name_1, ...args_1) => __awaiter(void 0, [ name_1, ...args_1 ], void 0, function*(name, options = {}) {
|
|
66
|
-
var _a;
|
|
67
|
-
const existing = get().stores.find(entry => entry.name === name);
|
|
68
|
-
yield null == existing ? void 0 : existing.connection.close();
|
|
69
|
-
const {create: create = !0} = options, connectionOptions = __rest(options, [ "create" ]), connection = new IndexedDB(name, connectionOptions);
|
|
70
|
-
yield connection.initialize(create);
|
|
71
|
-
const records = yield readStoreRecords(connection);
|
|
72
|
-
!function(connection) {
|
|
73
|
-
useLocalDBStore.setState(state => ({
|
|
74
|
-
stores: [ ...state.stores.filter(entry => entry.name !== connection.name), connection ]
|
|
75
|
-
}));
|
|
76
|
-
}({
|
|
77
|
-
name: name,
|
|
78
|
-
connection: connection,
|
|
79
|
-
key: null !== (_a = options.key) && void 0 !== _a ? _a : null,
|
|
80
|
-
records: records,
|
|
81
|
-
initialized: !0,
|
|
82
|
-
error: null
|
|
83
|
-
});
|
|
84
|
-
}),
|
|
85
|
-
removeStore: name => __awaiter(void 0, void 0, void 0, function*() {
|
|
86
|
-
const existing = get().stores.find(entry => entry.name === name);
|
|
87
|
-
existing && (yield existing.connection.close(), set(state => ({
|
|
88
|
-
stores: state.stores.filter(entry => entry.name !== name)
|
|
89
|
-
})));
|
|
90
|
-
}),
|
|
91
|
-
refreshStore: name => __awaiter(void 0, void 0, void 0, function*() {
|
|
92
|
-
const existing = getConnection(get().stores, name), records = yield readStoreRecords(existing.connection);
|
|
93
|
-
applyConnectionState(name, {
|
|
94
|
-
records: records,
|
|
95
|
-
initialized: !0,
|
|
96
|
-
error: null
|
|
97
|
-
});
|
|
98
|
-
}),
|
|
99
|
-
setValue: (name, value) => __awaiter(void 0, void 0, void 0, function*() {
|
|
100
|
-
const existing = getConnection(get().stores, name);
|
|
101
|
-
try {
|
|
102
|
-
const values = normalizeValues(value), resolvedKeys = [];
|
|
103
|
-
for (const item of values) {
|
|
104
|
-
const key = deriveRecordKey(existing, item), resolvedKey = yield existing.connection.set(key, item);
|
|
105
|
-
resolvedKeys.push(resolvedKey);
|
|
106
|
-
}
|
|
107
|
-
const records = yield readStoreRecords(existing.connection);
|
|
108
|
-
return applyConnectionState(name, {
|
|
109
|
-
records: records,
|
|
110
|
-
error: null
|
|
111
|
-
}), Array.isArray(value) ? resolvedKeys : resolvedKeys[0];
|
|
112
|
-
} catch (error) {
|
|
113
|
-
throw applyStoreError(name, error), error;
|
|
114
|
-
}
|
|
115
|
-
}),
|
|
116
|
-
addValue: (name, value) => __awaiter(void 0, void 0, void 0, function*() {
|
|
117
|
-
const existing = getConnection(get().stores, name);
|
|
118
|
-
try {
|
|
119
|
-
const values = normalizeValues(value), resolvedKeys = [];
|
|
120
|
-
for (const item of values) {
|
|
121
|
-
const resolvedKey = yield existing.connection.add(item);
|
|
122
|
-
resolvedKeys.push(resolvedKey);
|
|
123
|
-
}
|
|
124
|
-
const records = yield readStoreRecords(existing.connection);
|
|
125
|
-
return applyConnectionState(name, {
|
|
126
|
-
records: records,
|
|
127
|
-
error: null
|
|
128
|
-
}), Array.isArray(value) ? resolvedKeys : resolvedKeys[0];
|
|
129
|
-
} catch (error) {
|
|
130
|
-
throw applyStoreError(name, error), error;
|
|
131
|
-
}
|
|
132
|
-
}),
|
|
133
|
-
removeValue: (name, value) => __awaiter(void 0, void 0, void 0, function*() {
|
|
134
|
-
const existing = getConnection(get().stores, name);
|
|
135
|
-
try {
|
|
136
|
-
const values = normalizeValues(value);
|
|
137
|
-
for (const item of values) {
|
|
138
|
-
const key = deriveRecordKey(existing, item);
|
|
139
|
-
yield existing.connection.remove(key);
|
|
140
|
-
}
|
|
141
|
-
const records = yield readStoreRecords(existing.connection);
|
|
142
|
-
applyConnectionState(name, {
|
|
143
|
-
records: records,
|
|
144
|
-
error: null
|
|
145
|
-
});
|
|
146
|
-
} catch (error) {
|
|
147
|
-
throw applyStoreError(name, error), error;
|
|
148
|
-
}
|
|
149
|
-
}),
|
|
150
|
-
clearStore: name => __awaiter(void 0, void 0, void 0, function*() {
|
|
151
|
-
const existing = getConnection(get().stores, name);
|
|
152
|
-
yield existing.connection.clear(), applyConnectionState(name, {
|
|
153
|
-
records: [],
|
|
154
|
-
error: null
|
|
155
|
-
});
|
|
156
|
-
}),
|
|
157
|
-
destroyStore: name => __awaiter(void 0, void 0, void 0, function*() {
|
|
158
|
-
const existing = get().stores.find(entry => entry.name === name);
|
|
159
|
-
existing && (yield existing.connection.destroy(), set(state => ({
|
|
160
|
-
stores: state.stores.filter(entry => entry.name !== name)
|
|
161
|
-
})));
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
})), useLocalDB = name => useLocalDBStore(state => ({
|
|
165
|
-
refresh: () => state.actions.refreshStore(name),
|
|
166
|
-
set: value => state.actions.setValue(name, value),
|
|
167
|
-
add: value => state.actions.addValue(name, value),
|
|
168
|
-
remove: value => state.actions.removeValue(name, value),
|
|
169
|
-
clear: () => state.actions.clearStore(name),
|
|
170
|
-
destroy: () => state.actions.destroyStore(name)
|
|
171
|
-
}));
|
|
172
|
-
|
|
173
|
-
function useLocalDBValues(name, fieldOrKey, value) {
|
|
174
|
-
return useLocalDBStore(state => {
|
|
175
|
-
var _a, _b, _c, _d;
|
|
176
|
-
const records = null !== (_b = null === (_a = state.stores.find(entry => entry.name === name)) || void 0 === _a ? void 0 : _a.records) && void 0 !== _b ? _b : [], values = records.map(record => record.value);
|
|
177
|
-
return void 0 === fieldOrKey ? values : void 0 === value ? null !== (_d = null === (_c = records.find(record => areKeysEqual(record.key, fieldOrKey))) || void 0 === _c ? void 0 : _c.value) && void 0 !== _d ? _d : null : values.filter(entry => (null == entry ? void 0 : entry[fieldOrKey]) === value);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const useLocalDBError = name => useLocalDBStore(state => {
|
|
182
|
-
var _a, _b;
|
|
183
|
-
return null !== (_b = null === (_a = state.stores.find(entry => entry.name === name)) || void 0 === _a ? void 0 : _a.error) && void 0 !== _b ? _b : null;
|
|
184
|
-
}), localDBActions = useLocalDBStore.getState().actions;
|
|
185
|
-
|
|
186
|
-
export { useLocalDBError as a, useLocalDBStore as b, useLocalDBValues as c, localDBActions as l, useLocalDB as u };
|
|
@@ -10,10 +10,10 @@ import "../hooks/useWindow.mjs";
|
|
|
10
10
|
|
|
11
11
|
import { B as Button } from "./Button-m0XAJsq5.mjs";
|
|
12
12
|
|
|
13
|
-
import { F as FileList } from "./FileList-Ckix8gUY.mjs";
|
|
14
|
-
|
|
15
13
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
16
14
|
|
|
15
|
+
import { F as FileList } from "./FileList-Ckix8gUY.mjs";
|
|
16
|
+
|
|
17
17
|
var css = {
|
|
18
18
|
wrapperBg: "PromptInput-module_wrapperBg__zabZq flexBox-module_columnStart__C7P44",
|
|
19
19
|
bgRotate: "PromptInput-module_bgRotate__Um720",
|
|
@@ -4,14 +4,14 @@ import React, { useState, useRef, useId, useCallback, useMemo } from "react";
|
|
|
4
4
|
|
|
5
5
|
import { s as setStyle, a as accessibleKeyDown } from "./misc-N8KLjOXc.mjs";
|
|
6
6
|
|
|
7
|
-
import { F as FileList } from "./FileList-Ckix8gUY.mjs";
|
|
8
|
-
|
|
9
7
|
import { I as Icon } from "./Icon-C92f63Ib.mjs";
|
|
10
8
|
|
|
11
9
|
import { P as ProgressIndicator } from "./ProgressIndicator-CfM2c4ty.mjs";
|
|
12
10
|
|
|
13
11
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
14
12
|
|
|
13
|
+
import { F as FileList } from "./FileList-Ckix8gUY.mjs";
|
|
14
|
+
|
|
15
15
|
var css = {
|
|
16
16
|
wrapper: "UploadArea-module_wrapper__aircC flexBox-module_column__ezvMq",
|
|
17
17
|
icon: "UploadArea-module_icon__M7n-m flexBox-module_row__z24tF",
|