@parallelworks/ui 0.19.0 → 0.19.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/dist/{chunks/memoryStore-CC91S5LP.js → ai/adapter/memoryStore.js} +2 -2
- package/dist/ai/adapter/mock/index.js +2 -80
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.js +5 -333
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/{chunks/types-Yy0NrerF.js → ai/adapter/types.js} +1 -1
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.js +144 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.js +338 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.js +45 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.js +43 -6644
- package/dist/ai/strings.js +175 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.js +23 -0
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.js +83 -0
- package/dist/components/Button.js +83 -0
- package/dist/components/Callout.js +23 -0
- package/dist/components/Card.js +31 -0
- package/dist/components/CollapsiblePanel.js +77 -0
- package/dist/{chunks/ConfirmModal-aOR4O1QE.js → components/ConfirmModal.js} +4 -9
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/Markdown-CM-FenNE.js → components/CreateModal.js} +9 -116
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.js +27 -0
- package/dist/components/Filter.js +32 -0
- package/dist/components/FilterPill.js +13 -0
- package/dist/components/IconButton.js +34 -0
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.js +13 -0
- package/dist/components/Listbox.js +123 -0
- package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
- package/dist/components/Markdown.js +15 -0
- package/dist/components/MultiSelect.js +171 -0
- package/dist/components/Overview.js +39 -0
- package/dist/components/PageHeader.js +194 -0
- package/dist/components/Pagination.js +35 -0
- package/dist/{chunks/Provider-CDYurraE.js → components/Provider.js} +1 -1
- package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
- package/dist/components/SectionHeader.js +11 -0
- package/dist/components/SettingModeOption.js +30 -0
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.js +17 -0
- package/dist/components/Sort.js +42 -0
- package/dist/components/StatusBadge.js +63 -0
- package/dist/components/SwitchToggle.js +59 -0
- package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
- package/dist/{chunks/Table-DU2MW8xz.js → components/Table.js} +3 -3
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-K5HJr4_p.js → components/Tooltip.js} +2 -27
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/{chunks/focus-D_iZJTW1.js → components/focus.js} +1 -1
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.js +27 -0
- package/dist/components/relativeTime.js +32 -0
- package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
- package/dist/{chunks/duration-BOv8Phl8.js → duration.js} +1 -1
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/{chunks/Monaco-DJ8MW-Dq.js → editor/Monaco.js} +4 -2
- package/dist/editor/index.js +6 -1
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.js +29 -0
- package/dist/editor/yaml.js +15 -0
- package/dist/file-explorer/FileExplorer.js +1402 -0
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/{chunks/CodePreviewEditor-YqQBz1YL.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
- package/dist/file-explorer/FilePreview/Inline.js +45 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
- package/dist/file-explorer/FilePreview/Viewer.js +526 -0
- package/dist/file-explorer/FilePreview/index.js +266 -0
- package/dist/file-explorer/FilePreview/parse.js +63 -0
- package/dist/file-explorer/FilePreview/previewCache.js +98 -0
- package/dist/file-explorer/FilePreview/previewType.js +151 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
- package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
- package/dist/file-explorer/FileRow.js +165 -0
- package/dist/file-explorer/FileRowsWindow.js +92 -0
- package/dist/file-explorer/FileTable.js +172 -0
- package/dist/file-explorer/FileTableHeaders.js +49 -0
- package/dist/file-explorer/LoadMoreRow.js +46 -0
- package/dist/file-explorer/TreeView.js +376 -0
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.js +7 -5671
- package/dist/file-explorer/lib/batch.js +39 -0
- package/dist/file-explorer/lib/errors.js +9 -0
- package/dist/file-explorer/lib/paging.js +124 -0
- package/dist/file-explorer/lib/utils.js +322 -0
- package/dist/file-explorer/toasts.js +400 -0
- package/dist/file-explorer/treeRows.js +73 -0
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.js +54 -0
- package/dist/form/Fields/BooleanField.js +51 -0
- package/dist/form/Fields/CheckboxGroupField.js +72 -0
- package/dist/form/Fields/ColorField.js +33 -0
- package/dist/form/Fields/DropdownField.js +49 -0
- package/dist/form/Fields/DurationField.js +130 -0
- package/dist/form/Fields/LabelField.js +19 -0
- package/dist/form/Fields/MultiDropdownField.js +40 -0
- package/dist/form/Fields/NumberField.js +51 -0
- package/dist/form/Fields/ObjectField.js +54 -0
- package/dist/form/Fields/RadioField.js +49 -0
- package/dist/form/Fields/RangeField.js +58 -0
- package/dist/form/Fields/ResourceOptionIcon.js +21 -0
- package/dist/form/Fields/StepField.js +6 -0
- package/dist/form/Fields/StringField.js +37 -0
- package/dist/form/Fields/TextAreaField.js +31 -0
- package/dist/form/Fields/durationValidity.js +11 -0
- package/dist/form/Form.js +643 -0
- package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
- package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
- package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
- package/dist/form/Wizard/WizardContainer.js +138 -0
- package/dist/form/Wizard/WizardNavigation.js +92 -0
- package/dist/form/Wizard/WizardStepContent.js +35 -0
- package/dist/form/Wizard/WizardStepIndicator.js +108 -0
- package/dist/form/Wizard/useWizardState.js +118 -0
- package/dist/form/Wizard/utils.js +34 -0
- package/dist/form/fieldContext.js +26 -0
- package/dist/form/fieldRegistry.js +50 -0
- package/dist/form/index.js +17 -2321
- package/dist/{chunks/FieldWrapper-Cszwg-4B.js → form/lib.js} +2 -97
- package/dist/form/useParsedOpts.js +62 -0
- package/dist/form/usePrevious.js +11 -0
- package/dist/form/utils/checkShowIfObject.js +14 -0
- package/dist/form/utils/duration.js +69 -0
- package/dist/form/utils/getParentValue.js +23 -0
- package/dist/form/utils/getPlaceholder.js +9 -0
- package/dist/form/utils/getValueUsingPath.js +23 -0
- package/dist/form/utils/secondaryField.js +22 -0
- package/dist/graph/AnnotationBanner.js +141 -0
- package/dist/graph/Collapse.js +41 -0
- package/dist/graph/DependencyGraph.js +1398 -0
- package/dist/graph/JobSummary.js +104 -0
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/graph/index.js +1 -2519
- package/dist/graph/types.js +6 -0
- package/dist/index.js +46 -599
- package/dist/list/ActionToolbar.js +184 -0
- package/dist/list/HoverCard.js +73 -0
- package/dist/list/ListPage.js +145 -0
- package/dist/list/ListPager.js +59 -0
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.js +372 -0
- package/dist/list/RowContextMenu.js +350 -0
- package/dist/list/UserHoverCard.js +117 -0
- package/dist/list/index.js +11 -2
- package/dist/list/listSearch.js +137 -0
- package/dist/list/listView.js +210 -0
- package/dist/list/textEntry.js +10 -0
- package/dist/{chunks/logviewer-BTKuQWzw.js → logviewer/LogViewer.js} +4 -82
- package/dist/logviewer/index.js +2 -1
- package/dist/logviewer/segments.js +80 -0
- package/package.json +1 -1
- package/dist/chunks/PageHeader-0kG_iypP.js +0 -692
- package/dist/chunks/SwitchToggle-DShNdcao.js +0 -758
- package/dist/chunks/editor-Dk1rbV75.js +0 -361
- package/dist/chunks/list-CJm875m7.js +0 -1418
- /package/dist/{chunks/MarkdownImpl-CyeTVvSt.js → components/MarkdownImpl.js} +0 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { useNotify, useStrings } from "../components/Provider.js";
|
|
2
|
+
import { keyedByContent } from "../components/keys.js";
|
|
3
|
+
import { getUploadSessionETA, removeLeadingSlash } from "./lib/utils.js";
|
|
4
|
+
import { UploadSessionToast } from "./toasts.js";
|
|
5
|
+
import { createContext, use, useRef } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/file-explorer/FileExplorerContext.tsx
|
|
8
|
+
var FileExplorerContext = createContext(void 0);
|
|
9
|
+
var permissionMessagePattern = /not authorized|access denied|status code 403/i;
|
|
10
|
+
function isPermissionDenied(reason) {
|
|
11
|
+
if (!(reason instanceof Error)) return false;
|
|
12
|
+
if ("statusCode" in reason && reason.statusCode === 403) return true;
|
|
13
|
+
if ("status" in reason && reason.status === 403) return true;
|
|
14
|
+
if ("$metadata" in reason && typeof reason.$metadata === "object" && reason.$metadata !== null && "httpStatusCode" in reason.$metadata && reason.$metadata.httpStatusCode === 403) return true;
|
|
15
|
+
return permissionMessagePattern.test(reason.message);
|
|
16
|
+
}
|
|
17
|
+
function FileExplorerProvider({ children }) {
|
|
18
|
+
const notify = useNotify();
|
|
19
|
+
const t = useStrings().fileExplorer;
|
|
20
|
+
const uploadSessionMapRef = useRef(/* @__PURE__ */ new Map());
|
|
21
|
+
const uploadQueueRef = useRef([]);
|
|
22
|
+
const isProcessingRef = useRef(false);
|
|
23
|
+
const uploadSessionIdCounter = useRef(0);
|
|
24
|
+
const uploadSessionIdPrefix = "upload-session";
|
|
25
|
+
const generateUploadSessionId = () => {
|
|
26
|
+
return `${uploadSessionIdPrefix}-${Date.now()}-${uploadSessionIdCounter.current++}`;
|
|
27
|
+
};
|
|
28
|
+
const calculateWeightedProgress = (session) => {
|
|
29
|
+
if (!session.progress?.allFiles || session.progress.allFiles.size === 0) return 0;
|
|
30
|
+
let totalWeightedProgress = 0;
|
|
31
|
+
let totalWeight = 0;
|
|
32
|
+
session.progress.allFiles.forEach((fileProgress) => {
|
|
33
|
+
const fileSize = fileProgress.fileSizeBytes || 0;
|
|
34
|
+
const filePercentage = fileProgress?.percentage || 0;
|
|
35
|
+
totalWeightedProgress += filePercentage / 100 * fileSize;
|
|
36
|
+
totalWeight += fileSize;
|
|
37
|
+
});
|
|
38
|
+
return totalWeight > 0 ? totalWeightedProgress / totalWeight * 100 : 0;
|
|
39
|
+
};
|
|
40
|
+
const calculateOverallLoadedBytes = (session) => {
|
|
41
|
+
if (!session.progress?.allFiles) return {
|
|
42
|
+
loaded: 0,
|
|
43
|
+
total: session.progress?.totalSizeBytes || 0
|
|
44
|
+
};
|
|
45
|
+
let totalLoaded = 0;
|
|
46
|
+
let totalSize = 0;
|
|
47
|
+
session.progress.allFiles.forEach((fileProgress) => {
|
|
48
|
+
totalLoaded += fileProgress.loadedBytes || 0;
|
|
49
|
+
totalSize += fileProgress.fileSizeBytes || 0;
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
loaded: totalLoaded,
|
|
53
|
+
total: totalSize
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const updateFileProgressInUploadSession = (session, relativePath, updates) => {
|
|
57
|
+
if (!session.progress?.allFiles) return;
|
|
58
|
+
const fileProgress = session.progress.allFiles.get(relativePath);
|
|
59
|
+
if (!fileProgress) return;
|
|
60
|
+
const updatedFileProgress = {
|
|
61
|
+
...fileProgress,
|
|
62
|
+
...updates
|
|
63
|
+
};
|
|
64
|
+
session.progress.allFiles.set(relativePath, updatedFileProgress);
|
|
65
|
+
};
|
|
66
|
+
const addUploadSession = (storageName, targetPath, uploadNodes, client, provider, targetNode, refreshTargetNode) => {
|
|
67
|
+
const sessionId = generateUploadSessionId();
|
|
68
|
+
const newSession = {
|
|
69
|
+
id: sessionId,
|
|
70
|
+
storageName,
|
|
71
|
+
targetPath,
|
|
72
|
+
uploadNodes,
|
|
73
|
+
status: "queued",
|
|
74
|
+
queueIndex: uploadQueueRef.current.length,
|
|
75
|
+
client,
|
|
76
|
+
provider,
|
|
77
|
+
progress: {
|
|
78
|
+
completedFiles: 0,
|
|
79
|
+
totalFiles: uploadNodes.length,
|
|
80
|
+
totalSizeBytes: uploadNodes.reduce((sum, node) => sum + (node.file?.size || 0), 0),
|
|
81
|
+
allFiles: new Map(uploadNodes.map((file) => [file.relativePath, {
|
|
82
|
+
fileKey: file.relativePath,
|
|
83
|
+
fileSizeBytes: file.file?.size || 0,
|
|
84
|
+
abortController: new AbortController(),
|
|
85
|
+
status: "pending",
|
|
86
|
+
percentage: 0
|
|
87
|
+
}]))
|
|
88
|
+
},
|
|
89
|
+
toastId: sessionId,
|
|
90
|
+
abortController: new AbortController(),
|
|
91
|
+
targetNode,
|
|
92
|
+
refreshTargetNode
|
|
93
|
+
};
|
|
94
|
+
uploadSessionMapRef.current.set(sessionId, newSession);
|
|
95
|
+
uploadQueueRef.current.push(sessionId);
|
|
96
|
+
notify.loading(/* @__PURE__ */ jsx(UploadSessionToast, {
|
|
97
|
+
session: newSession,
|
|
98
|
+
queueLength: uploadQueueRef.current.length
|
|
99
|
+
}), {
|
|
100
|
+
toastId: sessionId,
|
|
101
|
+
icon: false,
|
|
102
|
+
closeButton: false
|
|
103
|
+
});
|
|
104
|
+
processNextUploadSessionInQueue();
|
|
105
|
+
return sessionId;
|
|
106
|
+
};
|
|
107
|
+
const getUploadSessionById = (sessionId) => {
|
|
108
|
+
return uploadSessionMapRef.current.get(sessionId);
|
|
109
|
+
};
|
|
110
|
+
const getUploadQueueIndex = (sessionId) => {
|
|
111
|
+
return uploadQueueRef.current.indexOf(sessionId);
|
|
112
|
+
};
|
|
113
|
+
const cancelFileInSession = (sessionId, relativePath) => {
|
|
114
|
+
const session = getUploadSessionById(sessionId);
|
|
115
|
+
if (!session?.progress?.allFiles) return;
|
|
116
|
+
const fileProgress = session.progress.allFiles.get(relativePath);
|
|
117
|
+
if (fileProgress?.abortController && (fileProgress.status === "pending" || fileProgress.status === "uploading")) {
|
|
118
|
+
fileProgress.abortController.abort();
|
|
119
|
+
updateFileProgressInUploadSession(session, relativePath, { status: "cancelled" });
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const handleSessionCancel = (session) => {
|
|
123
|
+
if (session.progress?.allFiles) session.progress.allFiles.forEach((fileProgress, relativePath) => {
|
|
124
|
+
if (fileProgress.abortController && (fileProgress.status === "pending" || fileProgress.status === "uploading")) {
|
|
125
|
+
fileProgress.abortController.abort();
|
|
126
|
+
session.progress?.allFiles?.set(relativePath, {
|
|
127
|
+
...fileProgress,
|
|
128
|
+
status: "cancelled"
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
session.abortController?.abort();
|
|
133
|
+
session.status = "cancelled";
|
|
134
|
+
};
|
|
135
|
+
const startUploadSession = async (sessionId) => {
|
|
136
|
+
const session = getUploadSessionById(sessionId);
|
|
137
|
+
if (!session) {
|
|
138
|
+
notify.update(sessionId, {
|
|
139
|
+
render: t.messages.uploadInitFailed,
|
|
140
|
+
type: "error",
|
|
141
|
+
isLoading: false,
|
|
142
|
+
closeButton: null
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (session.status !== "queued") {
|
|
147
|
+
notify.update(sessionId, {
|
|
148
|
+
render: t.upload.sessionNotQueued(sessionId, session.status),
|
|
149
|
+
type: "error",
|
|
150
|
+
isLoading: false,
|
|
151
|
+
closeButton: null
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
session.status = "uploading";
|
|
156
|
+
isProcessingRef.current = true;
|
|
157
|
+
try {
|
|
158
|
+
notify.update(sessionId, {
|
|
159
|
+
render: /* @__PURE__ */ jsx(UploadSessionToast, {
|
|
160
|
+
session,
|
|
161
|
+
queueLength: uploadQueueRef.current.length,
|
|
162
|
+
onCancel: () => handleSessionCancel(session),
|
|
163
|
+
onCancelFile: (path) => cancelFileInSession(sessionId, path)
|
|
164
|
+
}),
|
|
165
|
+
icon: false,
|
|
166
|
+
isLoading: false,
|
|
167
|
+
closeButton: false,
|
|
168
|
+
autoClose: false
|
|
169
|
+
});
|
|
170
|
+
const results = await Promise.allSettled(session.uploadNodes.map(async (node) => {
|
|
171
|
+
if (node && node.file) {
|
|
172
|
+
const fileProgress = session.progress?.allFiles?.get(node.relativePath);
|
|
173
|
+
if (!fileProgress) return;
|
|
174
|
+
if (fileProgress.status === "cancelled") return {
|
|
175
|
+
reason: "Upload cancelled by user",
|
|
176
|
+
status: "rejected"
|
|
177
|
+
};
|
|
178
|
+
updateFileProgressInUploadSession(session, node.relativePath, {
|
|
179
|
+
status: "uploading",
|
|
180
|
+
loadedBytes: 0,
|
|
181
|
+
totalBytes: node.file.size,
|
|
182
|
+
percentage: 0
|
|
183
|
+
});
|
|
184
|
+
const objectPath = session.targetPath ? `${session.targetPath}/${removeLeadingSlash(node.relativePath)}` : removeLeadingSlash(node.relativePath);
|
|
185
|
+
const uploadFileInput = session.provider.uploadFileInput;
|
|
186
|
+
if (!uploadFileInput) return {
|
|
187
|
+
reason: "Upload is not supported for this storage provider",
|
|
188
|
+
status: "rejected"
|
|
189
|
+
};
|
|
190
|
+
const input = uploadFileInput(session.storageName, objectPath, node.file);
|
|
191
|
+
const onProgress = (progress) => {
|
|
192
|
+
if (session.status === "cancelled") return;
|
|
193
|
+
if (session.progress?.allFiles) {
|
|
194
|
+
const currentFileProgress = session.progress.allFiles.get(node.relativePath);
|
|
195
|
+
if (!currentFileProgress) return;
|
|
196
|
+
if ([
|
|
197
|
+
"failed",
|
|
198
|
+
"cancelled",
|
|
199
|
+
"complete"
|
|
200
|
+
].includes(currentFileProgress.status ?? "")) return;
|
|
201
|
+
const wasCompleted = currentFileProgress.percentage === 100;
|
|
202
|
+
updateFileProgressInUploadSession(session, node.relativePath, {
|
|
203
|
+
loadedBytes: progress.loadedBytes,
|
|
204
|
+
totalBytes: progress.totalBytes,
|
|
205
|
+
percentage: progress.percentage,
|
|
206
|
+
status: progress.percentage === 100 ? "completed" : "uploading"
|
|
207
|
+
});
|
|
208
|
+
if (progress.percentage === 100 && !wasCompleted) session.progress.completedFiles += 1;
|
|
209
|
+
const overallProgress = calculateWeightedProgress(session);
|
|
210
|
+
const { loaded: totalLoadedBytes } = calculateOverallLoadedBytes(session);
|
|
211
|
+
session.progress.overallProgress = overallProgress;
|
|
212
|
+
session.progress.totalLoadedBytes = totalLoadedBytes;
|
|
213
|
+
const { estimatedSecondsLeft, lastProgressTime, lastProgressBytes, shouldUpdateETA } = getUploadSessionETA(totalLoadedBytes, session.progress.totalSizeBytes, session.progress.lastProgressTime, session.progress.lastProgressBytes);
|
|
214
|
+
session.progress.lastProgressTime = lastProgressTime;
|
|
215
|
+
session.progress.lastProgressBytes = lastProgressBytes;
|
|
216
|
+
if (shouldUpdateETA) session.progress.estimatedSecondsLeft = estimatedSecondsLeft;
|
|
217
|
+
notify.update(sessionId, {
|
|
218
|
+
render: /* @__PURE__ */ jsx(UploadSessionToast, {
|
|
219
|
+
session,
|
|
220
|
+
queueLength: uploadQueueRef.current.length,
|
|
221
|
+
onCancel: () => handleSessionCancel(session),
|
|
222
|
+
onCancelFile: (path) => cancelFileInSession(sessionId, path)
|
|
223
|
+
}),
|
|
224
|
+
icon: false,
|
|
225
|
+
isLoading: false,
|
|
226
|
+
closeButton: false,
|
|
227
|
+
autoClose: false
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
await session.client.uploadFile(input, onProgress, fileProgress.abortController);
|
|
233
|
+
updateFileProgressInUploadSession(session, node.relativePath, { status: "completed" });
|
|
234
|
+
} catch (error) {
|
|
235
|
+
const errorMessage = error instanceof Error ? error.message : String(error ?? "");
|
|
236
|
+
const isCancelled = errorMessage.toLowerCase().includes("abort") || errorMessage.toLowerCase().includes("cancel");
|
|
237
|
+
updateFileProgressInUploadSession(session, node.relativePath, { status: isCancelled ? "cancelled" : "failed" });
|
|
238
|
+
notify.update(sessionId, {
|
|
239
|
+
render: /* @__PURE__ */ jsx(UploadSessionToast, {
|
|
240
|
+
session: {
|
|
241
|
+
...session,
|
|
242
|
+
progress: {
|
|
243
|
+
completedFiles: 0,
|
|
244
|
+
totalFiles: 0,
|
|
245
|
+
totalSizeBytes: 0,
|
|
246
|
+
...session.progress
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
queueLength: uploadQueueRef.current.length,
|
|
250
|
+
onCancel: () => handleSessionCancel(session),
|
|
251
|
+
onCancelFile: (path) => cancelFileInSession(sessionId, path)
|
|
252
|
+
}),
|
|
253
|
+
icon: false,
|
|
254
|
+
isLoading: false,
|
|
255
|
+
closeButton: session.status === "failed" || session.status === "cancelled",
|
|
256
|
+
autoClose: false
|
|
257
|
+
});
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}));
|
|
262
|
+
try {
|
|
263
|
+
await session.refreshTargetNode(session.targetNode);
|
|
264
|
+
} catch (err) {
|
|
265
|
+
notify.error(t.upload.refreshFailed(session.storageName, err instanceof Error ? err.message : t.upload.unknownError));
|
|
266
|
+
}
|
|
267
|
+
const failedResults = results.filter((r) => r.status === "rejected");
|
|
268
|
+
const actualFailedResults = failedResults.filter((result) => {
|
|
269
|
+
if (result.status === "rejected") {
|
|
270
|
+
const reason = result.reason?.message || result.reason?.toString() || "";
|
|
271
|
+
return !reason.toLowerCase().includes("abort") && !reason.toLowerCase().includes("cancel");
|
|
272
|
+
}
|
|
273
|
+
return false;
|
|
274
|
+
});
|
|
275
|
+
const abortedCount = failedResults?.length - actualFailedResults?.length;
|
|
276
|
+
const failedFileNames = actualFailedResults.map((result) => {
|
|
277
|
+
const originalIndex = results.findIndex((r) => r === result);
|
|
278
|
+
return session.uploadNodes[originalIndex]?.name || `File #${originalIndex + 1}`;
|
|
279
|
+
}).filter(Boolean);
|
|
280
|
+
const successfulCount = results?.length - failedResults?.length;
|
|
281
|
+
if (actualFailedResults?.length > 0) notify.update(sessionId, {
|
|
282
|
+
render: /* @__PURE__ */ jsxs("div", {
|
|
283
|
+
className: "text-md",
|
|
284
|
+
children: [
|
|
285
|
+
/* @__PURE__ */ jsx("div", {
|
|
286
|
+
className: "font-medium mb-2",
|
|
287
|
+
children: t.upload.failedSummary(actualFailedResults.length, results.length)
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ jsx("ul", {
|
|
290
|
+
className: "text-sm space-y-1 max-h-32 overflow-y-auto",
|
|
291
|
+
children: keyedByContent(failedFileNames, (n) => n).map(({ key, item: name }, i) => /* @__PURE__ */ jsxs("li", { children: [
|
|
292
|
+
"• ",
|
|
293
|
+
name,
|
|
294
|
+
actualFailedResults[i]?.reason ? `: ${actualFailedResults[i].reason}` : ""
|
|
295
|
+
] }, key))
|
|
296
|
+
}),
|
|
297
|
+
/* @__PURE__ */ jsx("div", {
|
|
298
|
+
className: "mt-2 text-sm",
|
|
299
|
+
children: actualFailedResults.every((result) => isPermissionDenied(result.reason)) ? t.messages.noWriteAccess : t.upload.failReasonGeneric
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
}),
|
|
303
|
+
type: "error",
|
|
304
|
+
icon: null,
|
|
305
|
+
isLoading: false,
|
|
306
|
+
closeButton: null
|
|
307
|
+
});
|
|
308
|
+
else if (abortedCount > 0 && successfulCount > 0) notify.update(sessionId, {
|
|
309
|
+
render: /* @__PURE__ */ jsxs("div", {
|
|
310
|
+
className: "w-full flex flex-col gap-1",
|
|
311
|
+
children: [/* @__PURE__ */ jsx("div", { children: t.upload.someUploaded(successfulCount) }), /* @__PURE__ */ jsx("div", { children: t.upload.someCancelled(abortedCount) })]
|
|
312
|
+
}),
|
|
313
|
+
type: "success",
|
|
314
|
+
icon: null,
|
|
315
|
+
isLoading: false,
|
|
316
|
+
closeButton: null,
|
|
317
|
+
autoClose: null
|
|
318
|
+
});
|
|
319
|
+
else if (abortedCount > 0 && successfulCount === 0) notify.update(sessionId, {
|
|
320
|
+
render: t.upload.allCancelled(abortedCount),
|
|
321
|
+
type: "info",
|
|
322
|
+
icon: null,
|
|
323
|
+
isLoading: false,
|
|
324
|
+
closeButton: null,
|
|
325
|
+
autoClose: null
|
|
326
|
+
});
|
|
327
|
+
else notify.update(sessionId, {
|
|
328
|
+
render: t.upload.allUploaded,
|
|
329
|
+
type: "success",
|
|
330
|
+
icon: null,
|
|
331
|
+
isLoading: false,
|
|
332
|
+
closeButton: null,
|
|
333
|
+
autoClose: null
|
|
334
|
+
});
|
|
335
|
+
session.status = actualFailedResults.length > 0 ? "failed" : "completed";
|
|
336
|
+
const queueIndex = getUploadQueueIndex(sessionId);
|
|
337
|
+
if (queueIndex !== -1) uploadQueueRef.current.splice(queueIndex, 1);
|
|
338
|
+
uploadSessionMapRef.current.delete(sessionId);
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
processNextUploadSessionInQueue();
|
|
341
|
+
}, 1e3);
|
|
342
|
+
} finally {
|
|
343
|
+
isProcessingRef.current = false;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const processNextUploadSessionInQueue = async () => {
|
|
347
|
+
if (isProcessingRef.current || uploadQueueRef.current.length === 0) return;
|
|
348
|
+
const nextSessionId = uploadQueueRef.current[0];
|
|
349
|
+
await startUploadSession(nextSessionId);
|
|
350
|
+
};
|
|
351
|
+
const contextValue = {
|
|
352
|
+
uploadSessionMap: uploadSessionMapRef.current,
|
|
353
|
+
uploadQueue: uploadQueueRef.current,
|
|
354
|
+
addUploadSession,
|
|
355
|
+
getUploadSessionById,
|
|
356
|
+
getUploadQueueIndex,
|
|
357
|
+
startUploadSession
|
|
358
|
+
};
|
|
359
|
+
return /* @__PURE__ */ jsx(FileExplorerContext.Provider, {
|
|
360
|
+
value: contextValue,
|
|
361
|
+
children
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function useFileExplorer() {
|
|
365
|
+
const context = use(FileExplorerContext);
|
|
366
|
+
if (!context) throw new Error("useFileExplorer must be used within a FileExplorerProvider");
|
|
367
|
+
return context;
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
370
|
+
export { FileExplorerProvider, useFileExplorer };
|
package/dist/{chunks/CodePreviewEditor-YqQBz1YL.js → file-explorer/FilePreview/CodePreviewEditor.js}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCssIsDark } from "../../components/useCssIsDark.js";
|
|
2
|
+
import { defineEditorThemes, getThemeName } from "../../editor/themes.js";
|
|
3
|
+
import { setupMonacoWorkers } from "../../editor/workers.js";
|
|
3
4
|
import { useEffect, useRef } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import * as monaco from "monaco-editor";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useStrings } from "../../components/Provider.js";
|
|
2
|
+
import { ExpandIcon } from "../../icons.js";
|
|
3
|
+
import { formatFileSize } from "../lib/utils.js";
|
|
4
|
+
import { getPreviewKind } from "./previewType.js";
|
|
5
|
+
import { StreamedBadge } from "./StreamedBadge.js";
|
|
6
|
+
import { usePresignedUrl } from "./usePresignedUrl.js";
|
|
7
|
+
import { FilePreviewViewer } from "./Viewer.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/file-explorer/FilePreview/Inline.tsx
|
|
10
|
+
function FilePreviewInline({ node, storage, getPresignedUrl, onOpenFull, onDownload, active = true, showSecurityIndicator = true }) {
|
|
11
|
+
const t = useStrings().fileExplorer;
|
|
12
|
+
const { url, loading, error } = usePresignedUrl(node, getPresignedUrl, {
|
|
13
|
+
enabled: active,
|
|
14
|
+
linkErrorMessage: t.preview.linkError
|
|
15
|
+
});
|
|
16
|
+
const kind = getPreviewKind(node);
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: "flex h-full min-h-0 flex-col",
|
|
19
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "min-h-0 flex-1 overflow-hidden",
|
|
21
|
+
children: /* @__PURE__ */ jsx(FilePreviewViewer, {
|
|
22
|
+
node,
|
|
23
|
+
kind,
|
|
24
|
+
url,
|
|
25
|
+
urlLoading: loading,
|
|
26
|
+
urlError: error,
|
|
27
|
+
storage,
|
|
28
|
+
onDownload: () => onDownload(node)
|
|
29
|
+
}, node.path)
|
|
30
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
31
|
+
className: "flex shrink-0 items-center justify-between gap-3 border-t theme-border px-4 py-2.5",
|
|
32
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
33
|
+
className: "flex items-center gap-2 text-xs theme-muted-text",
|
|
34
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [typeof node.size === "number" && formatFileSize(node.size), node.contentType && ` · ${node.contentType}`] }), showSecurityIndicator && url && /* @__PURE__ */ jsx(StreamedBadge, {})]
|
|
35
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
36
|
+
type: "button",
|
|
37
|
+
className: "btn btn-neutral cursor-pointer",
|
|
38
|
+
onClick: () => onOpenFull(node),
|
|
39
|
+
children: [/* @__PURE__ */ jsx(ExpandIcon, { className: "mr-2 h-4 w-4" }), t.preview.openFullPreview]
|
|
40
|
+
})]
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { FilePreviewInline };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useStrings } from "../../components/Provider.js";
|
|
2
|
+
import { LockIcon } from "../../icons.js";
|
|
3
|
+
import { TOOLTIP_ID } from "../../components/Tooltip.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/file-explorer/FilePreview/StreamedBadge.tsx
|
|
6
|
+
function StreamedBadge() {
|
|
7
|
+
const t = useStrings().fileExplorer;
|
|
8
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
9
|
+
className: "inline-flex shrink-0 items-center gap-1 rounded-full border border-green-500/40 bg-green-500/15 px-2 py-0.5 text-[11px] text-green-600",
|
|
10
|
+
"data-tooltip-id": TOOLTIP_ID,
|
|
11
|
+
"data-tooltip-content": t.preview.streamedTooltip,
|
|
12
|
+
children: [/* @__PURE__ */ jsx(LockIcon, { className: "h-2.5 w-2.5" }), t.preview.streamed]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { StreamedBadge };
|