Updated mooncore dependencies
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MoonCore" Version="1.8.4" />
|
<PackageReference Include="MoonCore" Version="1.8.5" />
|
||||||
<PackageReference Include="MoonCore.Extended" Version="1.3.1" />
|
<PackageReference Include="MoonCore.Extended" Version="1.3.1" />
|
||||||
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.5" />
|
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.5" />
|
||||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
<PackageReference Include="Blazor-ApexCharts" Version="4.0.1" />
|
<PackageReference Include="Blazor-ApexCharts" Version="4.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10"/>
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.10" PrivateAssets="all"/>
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.10" PrivateAssets="all"/>
|
||||||
<PackageReference Include="MoonCore" Version="1.8.4" />
|
<PackageReference Include="MoonCore" Version="1.8.5" />
|
||||||
<PackageReference Include="MoonCore.Blazor" Version="1.2.9" />
|
<PackageReference Include="MoonCore.Blazor" Version="1.2.9" />
|
||||||
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.5"/>
|
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.5"/>
|
||||||
<PackageReference Include="MoonCore.Blazor.Tailwind" Version="1.3.2" />
|
<PackageReference Include="MoonCore.Blazor.Tailwind" Version="1.3.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -7,10 +7,8 @@
|
|||||||
"-m-3",
|
"-m-3",
|
||||||
"-mx-2",
|
"-mx-2",
|
||||||
"-mx-4",
|
"-mx-4",
|
||||||
"-rotate-90",
|
|
||||||
"-translate-x-1/2",
|
"-translate-x-1/2",
|
||||||
"-translate-x-full",
|
"-translate-x-full",
|
||||||
"-translate-y-1/2",
|
|
||||||
"absolute",
|
"absolute",
|
||||||
"align-middle",
|
"align-middle",
|
||||||
"animate-spin",
|
"animate-spin",
|
||||||
@@ -134,6 +132,7 @@
|
|||||||
"gap-y-8",
|
"gap-y-8",
|
||||||
"grid",
|
"grid",
|
||||||
"grid-cols-1",
|
"grid-cols-1",
|
||||||
|
"grid-cols-2",
|
||||||
"grid-cols-3",
|
"grid-cols-3",
|
||||||
"grid-cols-6",
|
"grid-cols-6",
|
||||||
"grid-flow-col",
|
"grid-flow-col",
|
||||||
@@ -332,8 +331,6 @@
|
|||||||
"shadow-sm",
|
"shadow-sm",
|
||||||
"shadow-xl",
|
"shadow-xl",
|
||||||
"shrink-0",
|
"shrink-0",
|
||||||
"size-52",
|
|
||||||
"size-full",
|
|
||||||
"sm:-mx-6",
|
"sm:-mx-6",
|
||||||
"sm:auto-cols-max",
|
"sm:auto-cols-max",
|
||||||
"sm:block",
|
"sm:block",
|
||||||
@@ -380,10 +377,8 @@
|
|||||||
"space-y-4",
|
"space-y-4",
|
||||||
"space-y-8",
|
"space-y-8",
|
||||||
"sr-only",
|
"sr-only",
|
||||||
"start-1/2",
|
|
||||||
"static",
|
"static",
|
||||||
"sticky",
|
"sticky",
|
||||||
"stroke-current",
|
|
||||||
"table",
|
"table",
|
||||||
"table-auto",
|
"table-auto",
|
||||||
"text-2xl",
|
"text-2xl",
|
||||||
@@ -425,7 +420,6 @@
|
|||||||
"to-gray-800",
|
"to-gray-800",
|
||||||
"to-primary-600",
|
"to-primary-600",
|
||||||
"top-0",
|
"top-0",
|
||||||
"top-1/2",
|
|
||||||
"transform",
|
"transform",
|
||||||
"transition",
|
"transition",
|
||||||
"transition-all",
|
"transition-all",
|
||||||
|
|||||||
@@ -1,13 +1,46 @@
|
|||||||
window.moonCoreDownloadService = {
|
window.moonCoreDownloadService = {
|
||||||
download: async function (fileName, contentStreamReference) {
|
download: async function (fileName, contentStreamReference, id, reportRef) {
|
||||||
const arrayBuffer = await contentStreamReference.arrayBuffer();
|
|
||||||
const blob = new Blob([arrayBuffer]);
|
const stream = await contentStreamReference.stream();
|
||||||
|
const reader = stream.getReader();
|
||||||
|
|
||||||
|
let lastReportTime = 0;
|
||||||
|
let receivedLength = 0; // Track downloaded size
|
||||||
|
let chunks = []; // Store downloaded chunks
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
|
||||||
|
chunks.push(value);
|
||||||
|
receivedLength += value.length;
|
||||||
|
|
||||||
|
if(reportRef)
|
||||||
|
{
|
||||||
|
const now = Date.now();
|
||||||
|
|
||||||
|
if (now - lastReportTime >= 500) { // Only log once per second
|
||||||
|
await reportRef.invokeMethodAsync("ReceiveReport", id, receivedLength, false);
|
||||||
|
lastReportTime = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine chunks into a single Blob
|
||||||
|
const blob = new Blob(chunks);
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const anchorElement = document.createElement('a');
|
|
||||||
anchorElement.href = url;
|
// Trigger file download
|
||||||
anchorElement.download = fileName ?? '';
|
const anchor = document.createElement("a");
|
||||||
anchorElement.click();
|
anchor.href = url;
|
||||||
anchorElement.remove();
|
anchor.download = fileName;
|
||||||
|
document.body.appendChild(anchor);
|
||||||
|
anchor.click();
|
||||||
|
|
||||||
|
document.body.removeChild(anchor);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
|
|
||||||
|
if(reportRef)
|
||||||
|
await reportRef.invokeMethodAsync("ReceiveReport", id, receivedLength, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,82 @@
|
|||||||
window.moonCoreFileManager = {
|
window.moonCoreFileManager = {
|
||||||
uploadCache: [],
|
uploadCache: [],
|
||||||
|
addFilesToCache: async function(id) {
|
||||||
|
let files = document.getElementById(id).files;
|
||||||
|
|
||||||
|
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
this.uploadCache.push(files[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.ref.invokeMethodAsync("TriggerUpload", this.uploadCache.length);
|
||||||
|
},
|
||||||
|
getNextFromCache: async function() {
|
||||||
|
if(this.uploadCache.length === 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
let nextItem = this.uploadCache.pop();
|
||||||
|
|
||||||
|
if(!nextItem)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
let file;
|
||||||
|
let path;
|
||||||
|
|
||||||
|
if(nextItem instanceof File)
|
||||||
|
{
|
||||||
|
file = nextItem;
|
||||||
|
path = file.name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file = await this.openFileEntry(nextItem);
|
||||||
|
path = nextItem.fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(file.size === 0)
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
path: null,
|
||||||
|
stream: null,
|
||||||
|
left: this.uploadCache.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let stream = await this.createStreamRef(file);
|
||||||
|
|
||||||
|
return {
|
||||||
|
path: path,
|
||||||
|
stream: stream,
|
||||||
|
left: this.uploadCache.length
|
||||||
|
};
|
||||||
|
},
|
||||||
readCache: async function (index) {
|
readCache: async function (index) {
|
||||||
const item = this.uploadCache.at(index);
|
const item = this.uploadCache.pop();
|
||||||
const streamRef = await this.createStreamRef(item);
|
console.log(item);
|
||||||
|
const streamRefData = await this.createStreamRef(item);
|
||||||
|
|
||||||
|
if(streamRefData == null)
|
||||||
|
return {path: item.fullPath, streamRef: null};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
path: item.fullPath,
|
path: item.fullPath,
|
||||||
streamRef: streamRef
|
streamRef: streamRefData.stream,
|
||||||
|
size: streamRefData.size
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
createStreamRef: async function (fileEntry) {
|
openFileEntry: async function (fileEntry) {
|
||||||
const promise = new Promise(resolve => {
|
const promise = new Promise(resolve => {
|
||||||
fileEntry.file(file => {
|
fileEntry.file(file => {
|
||||||
resolve(file);
|
resolve(file);
|
||||||
}, err => console.log(err));
|
}, err => console.log(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
const processedFile = await promise;
|
return await promise;
|
||||||
|
},
|
||||||
|
createStreamRef: async function (processedFile) {
|
||||||
// Prevent uploads of empty files
|
// Prevent uploads of empty files
|
||||||
if (processedFile.size <= 0) {
|
if (processedFile.size <= 0) {
|
||||||
console.log("Skipping upload of '" + fileEntry.fullPath + "' as its empty");
|
console.log("Skipping upload of '" + processedFile.name + "' as its empty");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +95,8 @@ window.moonCoreFileManager = {
|
|||||||
return DotNet.createJSStreamReference(arrayBuffer);
|
return DotNet.createJSStreamReference(arrayBuffer);
|
||||||
},
|
},
|
||||||
setup: function (id, callbackRef) {
|
setup: function (id, callbackRef) {
|
||||||
|
this.ref = callbackRef;
|
||||||
|
|
||||||
// Check which features are supported by the browser
|
// Check which features are supported by the browser
|
||||||
const supportsFileSystemAccessAPI =
|
const supportsFileSystemAccessAPI =
|
||||||
'getAsFileSystemHandle' in DataTransferItem.prototype;
|
'getAsFileSystemHandle' in DataTransferItem.prototype;
|
||||||
@@ -64,8 +122,8 @@ window.moonCoreFileManager = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.getAllWebkitFileEntries(e.dataTransfer.items).then(async value => {
|
this.getAllWebkitFileEntries(e.dataTransfer.items).then(async value => {
|
||||||
this.uploadCache = value;
|
value.forEach(a => this.uploadCache.push(a));
|
||||||
await callbackRef.invokeMethodAsync("OnFilesDropped", this.uploadCache.length);
|
await this.ref.invokeMethodAsync("TriggerUpload", this.uploadCache.length);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user