fix: port to core 4

This commit is contained in:
TrèsAbhi committed 2024-09-08 10:42:34 -05:00
1 parent de6a4d5675
commit 3d23ea1497
68 files changed
+122 -119

No files matched your search

@@ -0,0 +1,64 @@
import { crc32 } from 'crc';
import { compressBlock } from 'lz4js';
/**
* Thanks Maddoxkkm! Modernized heavily.
*
* https://github.com/Maddoxkkm/dvpl_converter/
*/
export function writeDVPL(buffer: Buffer) {
const source = new Uint8Array(buffer);
const destination = new Uint8Array(buffer.length);
const compressedBlockSize = compressBlock(
source,
destination,
0,
source.length,
0,
);
let output = Buffer.from(destination);
if (compressedBlockSize === 0 || compressedBlockSize >= buffer.length) {
const footerBuffer = toDVPLFooter(
buffer.length,
buffer.length,
crc32(buffer),
0,
);
return Buffer.concat(
[new Uint8Array(buffer), new Uint8Array(footerBuffer)],
buffer.length + 20,
);
} else {
output = output.subarray(0, compressedBlockSize);
const footerBuffer = toDVPLFooter(
buffer.length,
compressedBlockSize,
crc32(output),
2,
);
return Buffer.concat(
[new Uint8Array(output), new Uint8Array(footerBuffer)],
compressedBlockSize + 20,
);
}
}
function toDVPLFooter(
inputSize: number,
compressedSize: number,
crc32: number,
type: number,
) {
const result = Buffer.alloc(20);
result.writeUInt32LE(inputSize, 0);
result.writeUInt32LE(compressedSize, 4);
result.writeUInt32LE(crc32, 8);
result.writeUInt32LE(type, 12);
result.write('DVPL', 16, 4, 'utf8');
return result;
}
@@ -1,6 +1,6 @@
import { assertSecret } from '@blitzkit/core';
import { octokit } from '../../../../website/src/core/blitzkit/octokit';
import { GithubChangeBlob, createBlob } from './createBlob';
import { octokit } from './octokit';
export class AssetCommit {
constructor(public message: string) {}
@@ -1,6 +1,6 @@
import ProgressBar from 'progress';
import { octokit } from '../../../../website/src/core/blitzkit/octokit';
import { GithubChangeBlob, createBlob } from './createBlob';
import { octokit } from './octokit';
export interface FileChange {
path: string;
@@ -1,6 +1,6 @@
import { throttle } from 'lodash';
import { octokit } from '../../../../website/src/core/blitzkit/octokit';
import { FileChange } from './commitMultipleFiles';
import { octokit } from './octokit';
export interface GithubChangeBlob {
sha: string;
@@ -1,8 +1,11 @@
import { asset, DidsReadStream } from '@blitzkit/core';
import {
asset,
DidsReadStream,
DiscoveredIdsDefinitions,
} from '@blitzkit/core';
import { times } from 'lodash';
import { decompress } from 'lz4js';
import ProgressBar from 'progress';
import { DiscoveredIdsDefinitions } from '../../../../website/src/core/blitzkit/discoveredIdDefinitions';
export async function fetchPreDiscoveredIds() {
const idChunks: number[][] = [];
@@ -0,0 +1,9 @@
import { assertSecret } from '@blitzkit/core';
import { throttling } from '@octokit/plugin-throttling';
import { Octokit } from '@octokit/rest';
Octokit.plugin(throttling);
export const octokit = new Octokit({
auth: assertSecret(process.env.GH_TOKEN),
});