initial commit

This commit is contained in:
Brandon4466
2025-03-31 04:45:14 -07:00
commit ff59c4c0b8
2298 changed files with 478992 additions and 0 deletions

6
node_modules/atomically/dist/utils/lang.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/// <reference types="node" />
declare const isException: (value: unknown) => value is NodeJS.ErrnoException;
declare const isFunction: (value: unknown) => value is Function;
declare const isString: (value: unknown) => value is string;
declare const isUndefined: (value: unknown) => value is undefined;
export { isException, isFunction, isString, isUndefined };

16
node_modules/atomically/dist/utils/lang.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/* IMPORT */
/* MAIN */
const isException = (value) => {
return (value instanceof Error) && ('code' in value);
};
const isFunction = (value) => {
return (typeof value === 'function');
};
const isString = (value) => {
return (typeof value === 'string');
};
const isUndefined = (value) => {
return (value === undefined);
};
/* EXPORT */
export { isException, isFunction, isString, isUndefined };

6
node_modules/atomically/dist/utils/scheduler.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import type { Disposer } from '../types';
declare const Scheduler: {
next: (id: string) => void;
schedule: (id: string) => Promise<Disposer>;
};
export default Scheduler;

34
node_modules/atomically/dist/utils/scheduler.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
/* IMPORT */
/* HELPERS */
const Queues = {};
/* MAIN */
//TODO: Maybe publish this as a standalone package
const Scheduler = {
/* API */
next: (id) => {
const queue = Queues[id];
if (!queue)
return;
queue.shift();
const job = queue[0];
if (job) {
job(() => Scheduler.next(id));
}
else {
delete Queues[id];
}
},
schedule: (id) => {
return new Promise(resolve => {
let queue = Queues[id];
if (!queue)
queue = Queues[id] = [];
queue.push(resolve);
if (queue.length > 1)
return;
resolve(() => Scheduler.next(id));
});
}
};
/* EXPORT */
export default Scheduler;

11
node_modules/atomically/dist/utils/temp.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import type { Disposer } from '../types';
declare const Temp: {
store: Record<string, boolean>;
create: (filePath: string) => string;
get: (filePath: string, creator: (filePath: string) => string, purge?: boolean) => [string, Disposer];
purge: (filePath: string) => void;
purgeSync: (filePath: string) => void;
purgeSyncAll: () => void;
truncate: (filePath: string) => string;
};
export default Temp;

59
node_modules/atomically/dist/utils/temp.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
/* IMPORT */
import path from 'node:path';
import fs from 'stubborn-fs';
import whenExit from 'when-exit';
import { LIMIT_BASENAME_LENGTH } from '../constants.js';
/* MAIN */
//TODO: Maybe publish this as a standalone package
const Temp = {
/* VARIABLES */
store: {},
/* API */
create: (filePath) => {
const randomness = `000000${Math.floor(Math.random() * 16777215).toString(16)}`.slice(-6); // 6 random-enough hex characters
const timestamp = Date.now().toString().slice(-10); // 10 precise timestamp digits
const prefix = 'tmp-';
const suffix = `.${prefix}${timestamp}${randomness}`;
const tempPath = `${filePath}${suffix}`;
return tempPath;
},
get: (filePath, creator, purge = true) => {
const tempPath = Temp.truncate(creator(filePath));
if (tempPath in Temp.store)
return Temp.get(filePath, creator, purge); // Collision found, try again
Temp.store[tempPath] = purge;
const disposer = () => delete Temp.store[tempPath];
return [tempPath, disposer];
},
purge: (filePath) => {
if (!Temp.store[filePath])
return;
delete Temp.store[filePath];
fs.attempt.unlink(filePath);
},
purgeSync: (filePath) => {
if (!Temp.store[filePath])
return;
delete Temp.store[filePath];
fs.attempt.unlinkSync(filePath);
},
purgeSyncAll: () => {
for (const filePath in Temp.store) {
Temp.purgeSync(filePath);
}
},
truncate: (filePath) => {
const basename = path.basename(filePath);
if (basename.length <= LIMIT_BASENAME_LENGTH)
return filePath; //FIXME: Rough and quick attempt at detecting ok lengths
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename);
if (!truncable)
return filePath; //FIXME: No truncable part detected, can't really do much without also changing the parent path, which is unsafe, hoping for the best here
const truncationLength = basename.length - LIMIT_BASENAME_LENGTH;
return `${filePath.slice(0, -basename.length)}${truncable[1]}${truncable[2].slice(0, -truncationLength)}${truncable[3]}`; //FIXME: The truncable part might be shorter than needed here
}
};
/* INIT */
whenExit(Temp.purgeSyncAll); // Ensuring purgeable temp files are purged on exit
/* EXPORT */
export default Temp;