Add yet-another-react-lightbox package and update .gitignore to exclude node_modules

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-12 18:50:30 +00:00
parent bd2a5570a9
commit c92f4a5edd
9304 changed files with 29 additions and 2008667 deletions

View File

@@ -1,14 +0,0 @@
import type { Task } from './types.js';
export declare class AsapQueue {
private queue;
private pendingErrors;
private flushing;
private requestFlush;
private requestErrorThrow;
private index;
private capacity;
constructor();
enqueueTask(task: Task): void;
private flush;
registerPendingError: (err: any) => void;
}

View File

@@ -1,139 +0,0 @@
/* eslint-disable no-restricted-globals, @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars, @typescript-eslint/no-non-null-assertion */ import { makeRequestCall, makeRequestCallFromTimer } from './makeRequestCall.js';
export class AsapQueue {
// Use the fastest means possible to execute a task in its own turn, with
// priority over other events including IO, animation, reflow, and redraw
// events in browsers.
//
// An exception thrown by a task will permanently interrupt the processing of
// subsequent tasks. The higher level `asap` function ensures that if an
// exception is thrown by a task, that the task queue will continue flushing as
// soon as possible, but if you use `rawAsap` directly, you are responsible to
// either ensure that no exceptions are thrown from your task, or to manually
// call `rawAsap.requestFlush` if an exception is thrown.
enqueueTask(task) {
const { queue: q , requestFlush } = this;
if (!q.length) {
requestFlush();
this.flushing = true;
}
// Equivalent to push, but avoids a function call.
q[q.length] = task;
}
constructor(){
this.queue = [];
// We queue errors to ensure they are thrown in right order (FIFO).
// Array-as-queue is good enough here, since we are just dealing with exceptions.
this.pendingErrors = [];
// Once a flush has been requested, no further calls to `requestFlush` are
// necessary until the next `flush` completes.
// @ts-ignore
this.flushing = false;
// The position of the next task to execute in the task queue. This is
// preserved between calls to `flush` so that it can be resumed if
// a task throws an exception.
this.index = 0;
// If a task schedules additional tasks recursively, the task queue can grow
// unbounded. To prevent memory exhaustion, the task queue will periodically
// truncate already-completed tasks.
this.capacity = 1024;
// The flush function processes all tasks that have been scheduled with
// `rawAsap` unless and until one of those tasks throws an exception.
// If a task throws an exception, `flush` ensures that its state will remain
// consistent and will resume where it left off when called again.
// However, `flush` does not make any arrangements to be called again if an
// exception is thrown.
this.flush = ()=>{
const { queue: q } = this;
while(this.index < q.length){
const currentIndex = this.index;
// Advance the index before calling the task. This ensures that we will
// begin flushing on the next task the task throws an error.
this.index++;
q[currentIndex].call();
// Prevent leaking memory for long chains of recursive calls to `asap`.
// If we call `asap` within tasks scheduled by `asap`, the queue will
// grow, but to avoid an O(n) walk for every task we execute, we don't
// shift tasks off the queue after they have been executed.
// Instead, we periodically shift 1024 tasks off the queue.
if (this.index > this.capacity) {
// Manually shift all values starting at the index back to the
// beginning of the queue.
for(let scan = 0, newLength = q.length - this.index; scan < newLength; scan++){
q[scan] = q[scan + this.index];
}
q.length -= this.index;
this.index = 0;
}
}
q.length = 0;
this.index = 0;
this.flushing = false;
};
// In a web browser, exceptions are not fatal. However, to avoid
// slowing down the queue of pending tasks, we rethrow the error in a
// lower priority turn.
this.registerPendingError = (err)=>{
this.pendingErrors.push(err);
this.requestErrorThrow();
};
// `requestFlush` requests that the high priority event queue be flushed as
// soon as possible.
// This is useful to prevent an error thrown in a task from stalling the event
// queue if the exception handled by Node.jss
// `process.on("uncaughtException")` or by a domain.
// `requestFlush` is implemented using a strategy based on data collected from
// every available SauceLabs Selenium web driver worker at time of writing.
// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
this.requestFlush = makeRequestCall(this.flush);
this.requestErrorThrow = makeRequestCallFromTimer(()=>{
// Throw first error
if (this.pendingErrors.length) {
throw this.pendingErrors.shift();
}
});
}
} // The message channel technique was discovered by Malte Ubl and was the
// original foundation for this library.
// http://www.nonblocking.io/2011/06/windownexttick.html
// Safari 6.0.5 (at least) intermittently fails to create message ports on a
// page's first load. Thankfully, this version of Safari supports
// MutationObservers, so we don't need to fall back in that case.
// function makeRequestCallFromMessageChannel(callback) {
// var channel = new MessageChannel();
// channel.port1.onmessage = callback;
// return function requestCall() {
// channel.port2.postMessage(0);
// };
// }
// For reasons explained above, we are also unable to use `setImmediate`
// under any circumstances.
// Even if we were, there is another bug in Internet Explorer 10.
// It is not sufficient to assign `setImmediate` to `requestFlush` because
// `setImmediate` must be called *by name* and therefore must be wrapped in a
// closure.
// Never forget.
// function makeRequestCallFromSetImmediate(callback) {
// return function requestCall() {
// setImmediate(callback);
// };
// }
// Safari 6.0 has a problem where timers will get lost while the user is
// scrolling. This problem does not impact ASAP because Safari 6.0 supports
// mutation observers, so that implementation is used instead.
// However, if we ever elect to use timers in Safari, the prevalent work-around
// is to add a scroll event listener that calls for a flush.
// `setTimeout` does not call the passed callback if the delay is less than
// approximately 7 in web workers in Firefox 8 through 18, and sometimes not
// even then.
// This is for `asap.js` only.
// Its name will be periodically randomized to break any code that depends on
// // its existence.
// rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer
// ASAP was originally a nextTick shim included in Q. This was factored out
// into this ASAP package. It was later adapted to RSVP which made further
// amendments. These decisions, particularly to marginalize MessageChannel and
// to capture the MutationObserver implementation in a closure, were integrated
// back into ASAP proper.
// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
//# sourceMappingURL=AsapQueue.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +0,0 @@
import type { Task, TaskFn } from 'types';
export declare class RawTask implements Task {
private onError;
private release;
task: TaskFn | null;
constructor(onError: (err: any) => void, release: (t: RawTask) => void);
call(): void;
}

View File

@@ -1,20 +0,0 @@
// `call`, just like a function.
export class RawTask {
call() {
try {
this.task && this.task();
} catch (error) {
this.onError(error);
} finally{
this.task = null;
this.release(this);
}
}
constructor(onError, release){
this.onError = onError;
this.release = release;
this.task = null;
}
}
//# sourceMappingURL=RawTask.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../src/RawTask.ts"],"sourcesContent":["// We wrap tasks with recyclable task objects. A task object implements\n\nimport type { Task, TaskFn } from 'types'\n\n// `call`, just like a function.\nexport class RawTask implements Task {\n\tpublic task: TaskFn | null = null\n\n\tpublic constructor(\n\t\tprivate onError: (err: any) => void,\n\t\tprivate release: (t: RawTask) => void,\n\t) {}\n\n\tpublic call() {\n\t\ttry {\n\t\t\tthis.task && this.task()\n\t\t} catch (error) {\n\t\t\tthis.onError(error)\n\t\t} finally {\n\t\t\tthis.task = null\n\t\t\tthis.release(this)\n\t\t}\n\t}\n}\n"],"names":["RawTask","call","task","error","onError","release"],"mappings":"AAIA,gCAAgC;AAChC,OAAO,MAAMA,OAAO;IAQnB,AAAOC,IAAI,GAAG;QACb,IAAI;YACH,IAAI,CAACC,IAAI,IAAI,IAAI,CAACA,IAAI,EAAE;SACxB,CAAC,OAAOC,KAAK,EAAE;YACf,IAAI,CAACC,OAAO,CAACD,KAAK,CAAC;SACnB,QAAS;YACT,IAAI,CAACD,IAAI,GAAG,IAAI;YAChB,IAAI,CAACG,OAAO,CAAC,IAAI,CAAC;SAClB;KACD;IAdD,YACSD,OAA2B,EAC3BC,OAA6B,CACpC;aAFOD,OAA2B,GAA3BA,OAA2B;aAC3BC,OAA6B,GAA7BA,OAA6B;aAJ/BH,IAAI,GAAkB,IAAI;KAK7B;CAYJ"}

View File

@@ -1,7 +0,0 @@
import type { Task } from './types.js';
export declare class TaskFactory {
private onError;
private freeTasks;
constructor(onError: (err: any) => void);
create(task: () => void): Task;
}

View File

@@ -1,16 +0,0 @@
import { RawTask } from './RawTask.js';
export class TaskFactory {
create(task) {
const tasks = this.freeTasks;
const t1 = tasks.length ? tasks.pop() : new RawTask(this.onError, (t)=>tasks[tasks.length] = t
);
t1.task = task;
return t1;
}
constructor(onError){
this.onError = onError;
this.freeTasks = [];
}
}
//# sourceMappingURL=TaskFactory.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../src/TaskFactory.ts"],"sourcesContent":["import { RawTask } from './RawTask.js'\nimport type { Task } from './types.js'\n\nexport class TaskFactory {\n\tprivate freeTasks: RawTask[] = []\n\n\tpublic constructor(private onError: (err: any) => void) {}\n\n\tpublic create(task: () => void): Task {\n\t\tconst tasks = this.freeTasks\n\t\tconst t = tasks.length\n\t\t\t? (tasks.pop() as RawTask)\n\t\t\t: new RawTask(this.onError, (t) => (tasks[tasks.length] = t))\n\t\tt.task = task\n\t\treturn t\n\t}\n}\n"],"names":["RawTask","TaskFactory","create","task","tasks","freeTasks","t","length","pop","onError"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc,CAAA;AAGtC,OAAO,MAAMC,WAAW;IAKvB,AAAOC,MAAM,CAACC,IAAgB,EAAQ;QACrC,MAAMC,KAAK,GAAG,IAAI,CAACC,SAAS;QAC5B,MAAMC,EAAC,GAAGF,KAAK,CAACG,MAAM,GAClBH,KAAK,CAACI,GAAG,EAAE,GACZ,IAAIR,OAAO,CAAC,IAAI,CAACS,OAAO,EAAE,CAACH,CAAC,GAAMF,KAAK,CAACA,KAAK,CAACG,MAAM,CAAC,GAAGD,CAAC;QAAC,CAAC;QAC9DA,EAAC,CAACH,IAAI,GAAGA,IAAI;QACb,OAAOG,EAAC,CAAA;KACR;IATD,YAA2BG,OAA2B,CAAE;aAA7BA,OAA2B,GAA3BA,OAA2B;aAF9CJ,SAAS,GAAc,EAAE;KAEyB;CAU1D"}

View File

@@ -1,10 +0,0 @@
import type { TaskFn } from './types.js';
/**
* Calls a task as soon as possible after returning, in its own event, with priority
* over other events like animation, reflow, and repaint. An error thrown from an
* event will not interrupt, nor even substantially slow down the processing of
* other events, but will be rather postponed to a lower priority event.
* @param {{call}} task A callable object, typically a function that takes no
* arguments.
*/
export declare function asap(task: TaskFn): void;

View File

@@ -1,16 +0,0 @@
import { AsapQueue } from './AsapQueue.js';
import { TaskFactory } from './TaskFactory.js';
const asapQueue = new AsapQueue();
const taskFactory = new TaskFactory(asapQueue.registerPendingError);
/**
* Calls a task as soon as possible after returning, in its own event, with priority
* over other events like animation, reflow, and repaint. An error thrown from an
* event will not interrupt, nor even substantially slow down the processing of
* other events, but will be rather postponed to a lower priority event.
* @param {{call}} task A callable object, typically a function that takes no
* arguments.
*/ export function asap(task) {
asapQueue.enqueueTask(taskFactory.create(task));
}
//# sourceMappingURL=asap.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../src/asap.ts"],"sourcesContent":["import { AsapQueue } from './AsapQueue.js'\nimport { TaskFactory } from './TaskFactory.js'\nimport type { TaskFn } from './types.js'\n\nconst asapQueue = new AsapQueue()\nconst taskFactory = new TaskFactory(asapQueue.registerPendingError)\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nexport function asap(task: TaskFn) {\n\tasapQueue.enqueueTask(taskFactory.create(task))\n}\n"],"names":["AsapQueue","TaskFactory","asapQueue","taskFactory","registerPendingError","asap","task","enqueueTask","create"],"mappings":"AAAA,SAASA,SAAS,QAAQ,gBAAgB,CAAA;AAC1C,SAASC,WAAW,QAAQ,kBAAkB,CAAA;AAG9C,MAAMC,SAAS,GAAG,IAAIF,SAAS,EAAE;AACjC,MAAMG,WAAW,GAAG,IAAIF,WAAW,CAACC,SAAS,CAACE,oBAAoB,CAAC;AAEnE;;;;;;;GAOG,CACH,OAAO,SAASC,IAAI,CAACC,IAAY,EAAE;IAClCJ,SAAS,CAACK,WAAW,CAACJ,WAAW,CAACK,MAAM,CAACF,IAAI,CAAC,CAAC;CAC/C"}

View File

@@ -1,4 +0,0 @@
export * from './asap.js';
export * from './AsapQueue.js';
export * from './TaskFactory.js';
export * from './types.js';

View File

@@ -1,6 +0,0 @@
export * from './asap.js';
export * from './AsapQueue.js';
export * from './TaskFactory.js';
export * from './types.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './asap.js'\nexport * from './AsapQueue.js'\nexport * from './TaskFactory.js'\nexport * from './types.js'\n"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}

View File

@@ -1,3 +0,0 @@
export declare function makeRequestCallFromTimer(callback: () => void): () => void;
export declare function makeRequestCallFromMutationObserver(callback: () => void): () => void;
export declare const makeRequestCall: typeof makeRequestCallFromMutationObserver;

View File

@@ -1,77 +0,0 @@
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
// have WebKitMutationObserver but not un-prefixed MutationObserver.
// Must use `global` or `self` instead of `window` to work in both frames and web
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
/* globals self */ const scope = typeof global !== 'undefined' ? global : self;
const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
export function makeRequestCallFromTimer(callback) {
return function requestCall() {
// We dispatch a timeout with a specified delay of 0 for engines that
// can reliably accommodate that request. This will usually be snapped
// to a 4 milisecond delay, but once we're flushing, there's no delay
// between events.
const timeoutHandle = setTimeout(handleTimer, 0);
// However, since this timer gets frequently dropped in Firefox
// workers, we enlist an interval handle that will try to fire
// an event 20 times per second until it succeeds.
const intervalHandle = setInterval(handleTimer, 50);
function handleTimer() {
// Whichever timer succeeds will cancel both timers and
// execute the callback.
clearTimeout(timeoutHandle);
clearInterval(intervalHandle);
callback();
}
};
}
// To request a high priority event, we induce a mutation observer by toggling
// the text of a text node between "1" and "-1".
export function makeRequestCallFromMutationObserver(callback) {
let toggle = 1;
const observer = new BrowserMutationObserver(callback);
const node = document.createTextNode('');
observer.observe(node, {
characterData: true
});
return function requestCall() {
toggle = -toggle;
node.data = toggle;
};
}
export const makeRequestCall = typeof BrowserMutationObserver === 'function' ? // reliably everywhere they are implemented.
// They are implemented in all modern browsers.
//
// - Android 4-4.3
// - Chrome 26-34
// - Firefox 14-29
// - Internet Explorer 11
// - iPad Safari 6-7.1
// - iPhone Safari 7-7.1
// - Safari 6-7
makeRequestCallFromMutationObserver : // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
// 11-12, and in web workers in many engines.
// Although message channels yield to any queued rendering and IO tasks, they
// would be better than imposing the 4ms delay of timers.
// However, they do not work reliably in Internet Explorer or Safari.
// Internet Explorer 10 is the only browser that has setImmediate but does
// not have MutationObservers.
// Although setImmediate yields to the browser's renderer, it would be
// preferrable to falling back to setTimeout since it does not have
// the minimum 4ms penalty.
// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
// Desktop to a lesser extent) that renders both setImmediate and
// MessageChannel useless for the purposes of ASAP.
// https://github.com/kriskowal/q/issues/396
// Timers are implemented universally.
// We fall back to timers in workers in most engines, and in foreground
// contexts in the following browsers.
// However, note that even this simple case requires nuances to operate in a
// broad spectrum of browsers.
//
// - Firefox 3-13
// - Internet Explorer 6-9
// - iPad Safari 4.3
// - Lynx 2.8.7
makeRequestCallFromTimer;
//# sourceMappingURL=makeRequestCall.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +0,0 @@
export interface Task {
call(): void;
}
export declare type TaskFn = () => void;

View File

@@ -1,3 +0,0 @@
export { };
//# sourceMappingURL=types.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface Task {\n\tcall(): void\n}\nexport type TaskFn = () => void\n"],"names":[],"mappings":"AAAA,WAG+B"}