initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

251
node_modules/hookable/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,251 @@
'use strict';
function flatHooks(configHooks, hooks = {}, parentName) {
for (const key in configHooks) {
const subHook = configHooks[key];
const name = parentName ? `${parentName}:${key}` : key;
if (typeof subHook === "object" && subHook !== null) {
flatHooks(subHook, hooks, name);
} else if (typeof subHook === "function") {
hooks[name] = subHook;
}
}
return hooks;
}
function mergeHooks(...hooks) {
const finalHooks = {};
for (const hook of hooks) {
const flatenHook = flatHooks(hook);
for (const key in flatenHook) {
if (finalHooks[key]) {
finalHooks[key].push(flatenHook[key]);
} else {
finalHooks[key] = [flatenHook[key]];
}
}
}
for (const key in finalHooks) {
if (finalHooks[key].length > 1) {
const array = finalHooks[key];
finalHooks[key] = (...arguments_) => serial(array, (function_) => function_(...arguments_));
} else {
finalHooks[key] = finalHooks[key][0];
}
}
return finalHooks;
}
function serial(tasks, function_) {
return tasks.reduce((promise, task) => promise.then(() => function_(task)), Promise.resolve());
}
function serialCaller(hooks, arguments_) {
return hooks.reduce((promise, hookFunction) => promise.then(() => hookFunction.apply(void 0, arguments_)), Promise.resolve());
}
function parallelCaller(hooks, arguments_) {
return Promise.all(hooks.map((hook) => hook.apply(void 0, arguments_)));
}
function callEachWith(callbacks, argument0) {
for (const callback of callbacks) {
callback(argument0);
}
}
class Hookable {
constructor() {
this._hooks = {};
this._before = void 0;
this._after = void 0;
this._deprecatedMessages = void 0;
this._deprecatedHooks = {};
this.hook = this.hook.bind(this);
this.callHook = this.callHook.bind(this);
this.callHookWith = this.callHookWith.bind(this);
}
hook(name, function_, options = {}) {
if (!name || typeof function_ !== "function") {
return () => {
};
}
const originalName = name;
let dep;
while (this._deprecatedHooks[name]) {
dep = this._deprecatedHooks[name];
name = dep.to;
}
if (dep && !options.allowDeprecated) {
let message = dep.message;
if (!message) {
message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
}
if (!this._deprecatedMessages) {
this._deprecatedMessages = /* @__PURE__ */ new Set();
}
if (!this._deprecatedMessages.has(message)) {
console.warn(message);
this._deprecatedMessages.add(message);
}
}
this._hooks[name] = this._hooks[name] || [];
this._hooks[name].push(function_);
return () => {
if (function_) {
this.removeHook(name, function_);
function_ = void 0;
}
};
}
hookOnce(name, function_) {
let _unreg;
let _function = (...arguments_) => {
if (typeof _unreg === "function") {
_unreg();
}
_unreg = void 0;
_function = void 0;
return function_(...arguments_);
};
_unreg = this.hook(name, _function);
return _unreg;
}
removeHook(name, function_) {
if (this._hooks[name]) {
const index = this._hooks[name].indexOf(function_);
if (index !== -1) {
this._hooks[name].splice(index, 1);
}
if (this._hooks[name].length === 0) {
delete this._hooks[name];
}
}
}
deprecateHook(name, deprecated) {
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
const _hooks = this._hooks[name] || [];
this._hooks[name] = void 0;
for (const hook of _hooks) {
this.hook(name, hook);
}
}
deprecateHooks(deprecatedHooks) {
Object.assign(this._deprecatedHooks, deprecatedHooks);
for (const name in deprecatedHooks) {
this.deprecateHook(name, deprecatedHooks[name]);
}
}
addHooks(configHooks) {
const hooks = flatHooks(configHooks);
const removeFns = Object.keys(hooks).map((key) => this.hook(key, hooks[key]));
return () => {
for (const unreg of removeFns.splice(0, removeFns.length)) {
unreg();
}
};
}
removeHooks(configHooks) {
const hooks = flatHooks(configHooks);
for (const key in hooks) {
this.removeHook(key, hooks[key]);
}
}
callHook(name, ...arguments_) {
return this.callHookWith(serialCaller, name, ...arguments_);
}
callHookParallel(name, ...arguments_) {
return this.callHookWith(parallelCaller, name, ...arguments_);
}
callHookWith(caller, name, ...arguments_) {
const event = this._before || this._after ? { name, args: arguments_, context: {} } : void 0;
if (this._before) {
callEachWith(this._before, event);
}
const result = caller(this._hooks[name] || [], arguments_);
if (result instanceof Promise) {
return result.finally(() => {
if (this._after && event) {
callEachWith(this._after, event);
}
});
}
if (this._after && event) {
callEachWith(this._after, event);
}
return result;
}
beforeEach(function_) {
this._before = this._before || [];
this._before.push(function_);
return () => {
const index = this._before.indexOf(function_);
if (index !== -1) {
this._before.splice(index, 1);
}
};
}
afterEach(function_) {
this._after = this._after || [];
this._after.push(function_);
return () => {
const index = this._after.indexOf(function_);
if (index !== -1) {
this._after.splice(index, 1);
}
};
}
}
function createHooks() {
return new Hookable();
}
const isBrowser = typeof window !== "undefined";
function createDebugger(hooks, _options = {}) {
const options = {
inspect: isBrowser,
group: isBrowser,
filter: () => true,
..._options
};
const _filter = options.filter;
const filter = typeof _filter === "string" ? (name) => name.startsWith(_filter) : _filter;
const _tag = options.tag ? `[${options.tag}] ` : "";
const logPrefix = (event) => _tag + event.name + "".padEnd(event._id, "\0");
const _idCtr = {};
const unsubscribeBefore = hooks.beforeEach((event) => {
if (!filter(event.name)) {
return;
}
_idCtr[event.name] = _idCtr[event.name] || 0;
event._id = _idCtr[event.name]++;
console.time(logPrefix(event));
});
const unsubscribeAfter = hooks.afterEach((event) => {
if (!filter(event.name)) {
return;
}
if (options.group) {
console.groupCollapsed(event.name);
}
if (options.inspect) {
console.timeLog(logPrefix(event), event.args);
} else {
console.timeEnd(logPrefix(event));
}
if (options.group) {
console.groupEnd();
}
_idCtr[event.name]--;
});
return {
close: () => {
unsubscribeBefore();
unsubscribeAfter();
}
};
}
exports.Hookable = Hookable;
exports.createDebugger = createDebugger;
exports.createHooks = createHooks;
exports.flatHooks = flatHooks;
exports.mergeHooks = mergeHooks;
exports.parallelCaller = parallelCaller;
exports.serial = serial;
exports.serialCaller = serialCaller;

100
node_modules/hookable/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,100 @@
declare type HookCallback = (...arguments_: any) => Promise<void> | void;
interface Hooks {
[key: string]: HookCallback;
}
declare type HookKeys<T> = keyof T & string;
declare type DeprecatedHook<T> = {
message?: string;
to: HookKeys<T>;
};
declare type DeprecatedHooks<T> = {
[name in HookKeys<T>]: DeprecatedHook<T>;
};
declare type ValueOf<C> = C extends Record<any, any> ? C[keyof C] : never;
declare type Strings<T> = Exclude<keyof T, number | symbol>;
declare type KnownKeys<T> = keyof {
[K in keyof T as string extends K ? never : number extends K ? never : K]: never;
};
declare type StripGeneric<T> = Pick<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
declare type OnlyGeneric<T> = Omit<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
declare type Namespaces<T> = ValueOf<{
[key in Strings<T>]: key extends `${infer Namespace}:${string}` ? Namespace : never;
}>;
declare type BareHooks<T> = ValueOf<{
[key in Strings<T>]: key extends `${string}:${string}` ? never : key;
}>;
declare type HooksInNamespace<T, Namespace extends string> = ValueOf<{
[key in Strings<T>]: key extends `${Namespace}:${infer HookName}` ? HookName : never;
}>;
declare type WithoutNamespace<T, Namespace extends string> = {
[key in HooksInNamespace<T, Namespace>]: `${Namespace}:${key}` extends keyof T ? T[`${Namespace}:${key}`] : never;
};
declare type NestedHooks<T> = (Partial<StripGeneric<T>> | Partial<OnlyGeneric<T>>) & Partial<{
[key in Namespaces<StripGeneric<T>>]: NestedHooks<WithoutNamespace<T, key>>;
}> & Partial<{
[key in BareHooks<StripGeneric<T>>]: T[key];
}>;
declare type InferCallback<HT, HN extends keyof HT> = HT[HN] extends HookCallback ? HT[HN] : never;
declare type InferSpyEvent<HT extends Record<string, any>> = {
[key in keyof HT]: {
name: key;
args: Parameters<HT[key]>;
context: Record<string, any>;
};
}[keyof HT];
declare class Hookable<HooksT = Record<string, HookCallback>, HookNameT extends HookKeys<HooksT> = HookKeys<HooksT>> {
private _hooks;
private _before;
private _after;
private _deprecatedHooks;
private _deprecatedMessages;
constructor();
hook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>, options?: {
allowDeprecated?: boolean;
}): () => void;
hookOnce<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): () => void;
removeHook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): void;
deprecateHook<NameT extends HookNameT>(name: NameT, deprecated: HookKeys<HooksT> | DeprecatedHook<HooksT>): void;
deprecateHooks(deprecatedHooks: Partial<Record<HookNameT, DeprecatedHook<HooksT>>>): void;
addHooks(configHooks: NestedHooks<HooksT>): () => void;
removeHooks(configHooks: NestedHooks<HooksT>): void;
callHook<NameT extends HookNameT>(name: NameT, ...arguments_: Parameters<InferCallback<HooksT, NameT>>): Promise<any>;
callHookParallel<NameT extends HookNameT>(name: NameT, ...arguments_: Parameters<InferCallback<HooksT, NameT>>): Promise<any[]>;
callHookWith<NameT extends HookNameT, CallFunction extends (hooks: HookCallback[], arguments_: Parameters<InferCallback<HooksT, NameT>>) => any>(caller: CallFunction, name: NameT, ...arguments_: Parameters<InferCallback<HooksT, NameT>>): ReturnType<CallFunction>;
beforeEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
afterEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
}
declare function createHooks<T>(): Hookable<T>;
declare function flatHooks<T>(configHooks: NestedHooks<T>, hooks?: T, parentName?: string): T;
declare function mergeHooks<T>(...hooks: NestedHooks<T>[]): T;
declare function serial<T>(tasks: T[], function_: (task: T) => Promise<any> | any): Promise<any>;
declare function serialCaller(hooks: HookCallback[], arguments_?: any[]): Promise<any>;
declare function parallelCaller(hooks: HookCallback[], arguments_?: any[]): Promise<any[]>;
interface CreateDebuggerOptions {
/** An optional tag to prefix console logs with */
tag?: string;
/**
* Show hook params to the console output
*
* Enabled for browsers by default
*/
inspect?: boolean;
/**
* Use group/groupEnd wrapper around logs happening during a specific hook
*
* Enabled for browsers by default
*/
group?: boolean;
/** Filter which hooks to enable debugger for. Can be a string prefix or fn. */
filter?: string | ((event: string) => boolean);
}
/** Start debugging hook names and timing in console */
declare function createDebugger(hooks: Hookable<any>, _options?: CreateDebuggerOptions): {
/** Stop debugging and remove listeners */
close: () => void;
};
export { CreateDebuggerOptions, DeprecatedHook, DeprecatedHooks, HookCallback, HookKeys, Hookable, Hooks, NestedHooks, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };

242
node_modules/hookable/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,242 @@
function flatHooks(configHooks, hooks = {}, parentName) {
for (const key in configHooks) {
const subHook = configHooks[key];
const name = parentName ? `${parentName}:${key}` : key;
if (typeof subHook === "object" && subHook !== null) {
flatHooks(subHook, hooks, name);
} else if (typeof subHook === "function") {
hooks[name] = subHook;
}
}
return hooks;
}
function mergeHooks(...hooks) {
const finalHooks = {};
for (const hook of hooks) {
const flatenHook = flatHooks(hook);
for (const key in flatenHook) {
if (finalHooks[key]) {
finalHooks[key].push(flatenHook[key]);
} else {
finalHooks[key] = [flatenHook[key]];
}
}
}
for (const key in finalHooks) {
if (finalHooks[key].length > 1) {
const array = finalHooks[key];
finalHooks[key] = (...arguments_) => serial(array, (function_) => function_(...arguments_));
} else {
finalHooks[key] = finalHooks[key][0];
}
}
return finalHooks;
}
function serial(tasks, function_) {
return tasks.reduce((promise, task) => promise.then(() => function_(task)), Promise.resolve());
}
function serialCaller(hooks, arguments_) {
return hooks.reduce((promise, hookFunction) => promise.then(() => hookFunction.apply(void 0, arguments_)), Promise.resolve());
}
function parallelCaller(hooks, arguments_) {
return Promise.all(hooks.map((hook) => hook.apply(void 0, arguments_)));
}
function callEachWith(callbacks, argument0) {
for (const callback of callbacks) {
callback(argument0);
}
}
class Hookable {
constructor() {
this._hooks = {};
this._before = void 0;
this._after = void 0;
this._deprecatedMessages = void 0;
this._deprecatedHooks = {};
this.hook = this.hook.bind(this);
this.callHook = this.callHook.bind(this);
this.callHookWith = this.callHookWith.bind(this);
}
hook(name, function_, options = {}) {
if (!name || typeof function_ !== "function") {
return () => {
};
}
const originalName = name;
let dep;
while (this._deprecatedHooks[name]) {
dep = this._deprecatedHooks[name];
name = dep.to;
}
if (dep && !options.allowDeprecated) {
let message = dep.message;
if (!message) {
message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
}
if (!this._deprecatedMessages) {
this._deprecatedMessages = /* @__PURE__ */ new Set();
}
if (!this._deprecatedMessages.has(message)) {
console.warn(message);
this._deprecatedMessages.add(message);
}
}
this._hooks[name] = this._hooks[name] || [];
this._hooks[name].push(function_);
return () => {
if (function_) {
this.removeHook(name, function_);
function_ = void 0;
}
};
}
hookOnce(name, function_) {
let _unreg;
let _function = (...arguments_) => {
if (typeof _unreg === "function") {
_unreg();
}
_unreg = void 0;
_function = void 0;
return function_(...arguments_);
};
_unreg = this.hook(name, _function);
return _unreg;
}
removeHook(name, function_) {
if (this._hooks[name]) {
const index = this._hooks[name].indexOf(function_);
if (index !== -1) {
this._hooks[name].splice(index, 1);
}
if (this._hooks[name].length === 0) {
delete this._hooks[name];
}
}
}
deprecateHook(name, deprecated) {
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
const _hooks = this._hooks[name] || [];
this._hooks[name] = void 0;
for (const hook of _hooks) {
this.hook(name, hook);
}
}
deprecateHooks(deprecatedHooks) {
Object.assign(this._deprecatedHooks, deprecatedHooks);
for (const name in deprecatedHooks) {
this.deprecateHook(name, deprecatedHooks[name]);
}
}
addHooks(configHooks) {
const hooks = flatHooks(configHooks);
const removeFns = Object.keys(hooks).map((key) => this.hook(key, hooks[key]));
return () => {
for (const unreg of removeFns.splice(0, removeFns.length)) {
unreg();
}
};
}
removeHooks(configHooks) {
const hooks = flatHooks(configHooks);
for (const key in hooks) {
this.removeHook(key, hooks[key]);
}
}
callHook(name, ...arguments_) {
return this.callHookWith(serialCaller, name, ...arguments_);
}
callHookParallel(name, ...arguments_) {
return this.callHookWith(parallelCaller, name, ...arguments_);
}
callHookWith(caller, name, ...arguments_) {
const event = this._before || this._after ? { name, args: arguments_, context: {} } : void 0;
if (this._before) {
callEachWith(this._before, event);
}
const result = caller(this._hooks[name] || [], arguments_);
if (result instanceof Promise) {
return result.finally(() => {
if (this._after && event) {
callEachWith(this._after, event);
}
});
}
if (this._after && event) {
callEachWith(this._after, event);
}
return result;
}
beforeEach(function_) {
this._before = this._before || [];
this._before.push(function_);
return () => {
const index = this._before.indexOf(function_);
if (index !== -1) {
this._before.splice(index, 1);
}
};
}
afterEach(function_) {
this._after = this._after || [];
this._after.push(function_);
return () => {
const index = this._after.indexOf(function_);
if (index !== -1) {
this._after.splice(index, 1);
}
};
}
}
function createHooks() {
return new Hookable();
}
const isBrowser = typeof window !== "undefined";
function createDebugger(hooks, _options = {}) {
const options = {
inspect: isBrowser,
group: isBrowser,
filter: () => true,
..._options
};
const _filter = options.filter;
const filter = typeof _filter === "string" ? (name) => name.startsWith(_filter) : _filter;
const _tag = options.tag ? `[${options.tag}] ` : "";
const logPrefix = (event) => _tag + event.name + "".padEnd(event._id, "\0");
const _idCtr = {};
const unsubscribeBefore = hooks.beforeEach((event) => {
if (!filter(event.name)) {
return;
}
_idCtr[event.name] = _idCtr[event.name] || 0;
event._id = _idCtr[event.name]++;
console.time(logPrefix(event));
});
const unsubscribeAfter = hooks.afterEach((event) => {
if (!filter(event.name)) {
return;
}
if (options.group) {
console.groupCollapsed(event.name);
}
if (options.inspect) {
console.timeLog(logPrefix(event), event.args);
} else {
console.timeEnd(logPrefix(event));
}
if (options.group) {
console.groupEnd();
}
_idCtr[event.name]--;
});
return {
close: () => {
unsubscribeBefore();
unsubscribeAfter();
}
};
}
export { Hookable, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };