@kitten-science/kitten-scientists 2.0.0-beta.11-dev.20250520124238 → 2.0.0-beta.11-dev.20250520132826

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kitten-scientists-loader-0.0.0-ci.min.user.js","sources":["../node_modules/@oliversalzburg/js-utils/data/nil.js","../node_modules/@oliversalzburg/js-utils/errors/console.js","../node_modules/@oliversalzburg/js-utils/errors/AbstractError.js","../node_modules/@oliversalzburg/js-utils/errors/InvalidOperationError.js","../source/entrypoint-loader.ts"],"sourcesContent":["/**\n * Check if something is nil.\n * Can be used as a typeguard.\n * @param subject - The subject that could be nil.\n * @typeParam TSubject - The type of the subject.\n * @returns `true` if the subject is nil, `false` otherwise.\n */\nexport function isNil(subject) {\n return subject === null || subject === undefined;\n}\n/**\n * Check if something is a concrete value of the given type.\n * Can be used as a typeguard.\n * @param subject - The subject that could be nil.\n * @param Prototype - The prototype to check against.\n * @typeParam TSubject - The type to check against.\n * @returns `true` if the input element matches the given type,\n * `false` otherwise.\n */\nexport function is(subject, Prototype) {\n return !isNil(subject) && subject instanceof Prototype;\n}\n/**\n * Thrown when an unexpected nil value was encountered.\n */\nexport class UnexpectedNilError extends Error {\n /**\n * Constructs a new {@linkcode UnexpectedNilError}.\n * @param message - The error message.\n */\n constructor(message = \"unexpected nil value\") {\n super(message);\n }\n}\n/**\n * Ensure that the passed subject is not nil; throw otherwise.\n * @param subject - A subject that is possibly nil.\n * @param errorMessage - An optional error message to throw when the subject is nil.\n * @typeParam TSubject - The type of the subject.\n * @returns The subject, if it isn't nil.\n * @throws {@linkcode UnexpectedNilError} When the subject is nil.\n */\nexport function mustExist(subject, errorMessage) {\n if (isNil(subject)) {\n throw new UnexpectedNilError(errorMessage);\n }\n return subject;\n}\n/**\n * Ensure that all passed subjects are not nil; throw otherwise.\n * @param subjects - The subjects that are possibly nil.\n * @param errorMessage - An optional error message to throw when a subject is nil.\n * @typeParam TSubject - The type a the subject.\n * @returns The subjects, if they aren't nil.\n * @throws {@linkcode UnexpectedNilError} When a subject is nil.\n */\nexport function mustExistAll(subjects, errorMessage) {\n for (const subject of subjects) {\n if (isNil(subject)) {\n throw new UnexpectedNilError(errorMessage);\n }\n }\n return subjects;\n}\n/**\n * Ensure that the passed subject is not nil; throw otherwise.\n * @param subject - A subject that is possibly nil.\n * @typeParam TSubject - The type of the subject.\n * @throws {@linkcode UnexpectedNilError} When the subject is nil.\n */\nexport function assertExists(subject) {\n if (isNil(subject)) {\n throw new UnexpectedNilError();\n }\n}\n/**\n * Ensure that the passed subjects are not nil; throw otherwise.\n * @param subjects - Subjects that are possibly nil.\n * @typeParam TSubject - The type of a subject.\n * @throws {@linkcode UnexpectedNilError} When a subject is nil.\n */\nexport function assertExistsAll(subjects) {\n for (const subject of subjects) {\n if (isNil(subject)) {\n throw new UnexpectedNilError();\n }\n }\n}\n/**\n * Convert a nilable into a real value, if it is nil.\n * @param nilable - The subject to convert to an optional.\n * @param to - The value to coalese to.\n * @returns The input value, if it wasn't nil, or the value to coalesce to.\n */\nexport function coalesce(nilable, to) {\n if (isNil(nilable)) {\n return to;\n }\n return nilable;\n}\n/**\n * Drop all nil values from an array, or replaces them with another value.\n * @param nilables - The subject to convert.\n * @param to - The value to coalese to.\n * @returns An array with where all values are not nil.\n */\nexport function coalesceArray(nilables, to) {\n const result = new Array();\n for (const nilable of nilables) {\n if (!isNil(nilable)) {\n result.push(nilable);\n }\n else if (!isNil(to)) {\n result.push(to);\n }\n }\n return result;\n}\n/**\n * Convert a nilable into an optional argument.\n * This means `null` is normalized to `undefined`.\n * @param nilable - The subject to convert to an optional.\n * @returns The value, normalized to `undefined`, if it was nil.\n */\nexport function toOptional(nilable) {\n if (isNil(nilable)) {\n return undefined;\n }\n return nilable;\n}\n//# sourceMappingURL=nil.js.map","/**\n * Returns a function that will receive errors (or anything else that was `throw`n)\n * and prints it to a {@linkcode !console}.\n * @param console - The console to print errors to.\n * @returns A function that will print errors to the console.\n */\nexport const redirectErrorsToConsole = (console) => {\n const printErrorsToConsole = (error) => {\n console.error(error);\n };\n return printErrorsToConsole;\n};\n//# sourceMappingURL=console.js.map","/**\n * Base class for all errors.\n */\nexport class AbstractError extends Error {\n /**\n * The HTTP status code to associate with this error.\n */\n status;\n /**\n * An application-unique, readable error code.\n */\n code;\n /**\n * Constructs a new {@linkcode AbstractError}.\n * @param code - The main identification code for the error.\n * @param message - The main error message.\n * @param status - The HTTP status code to return.\n */\n constructor(code, message, status) {\n super(message);\n this.code = code;\n this.name = \"AbstractError\";\n this.status = status;\n if (typeof Error.captureStackTrace !== \"undefined\") {\n // Capture a new stacktrace, otherwise it will include our base-class constructor instead of the code\n // location we're actually interested in.\n Error.captureStackTrace(this, AbstractError);\n }\n }\n /**\n * Checks if an object is an instance of {@linkcode AbstractError}, or one of its subclasses.\n * @param error - The object to check.\n * @param allowForeignModule - Only check for similar looking error codes.\n * You're going to want to use this if you're dealing with a setup where\n * multiple versions of js-utils are loaded.\n * @returns `true` if the object is an {@linkcode AbstractError}, `false` otherwise.\n */\n static isAbstractError(error, allowForeignModule = true) {\n if (error instanceof AbstractError) {\n return true;\n }\n // When multiple versions of js-utils are loaded at runtime, the\n // prototypes of errors don't align. In that case, we just analyze the\n // error code.\n if (allowForeignModule) {\n const errorRecord = error;\n if (Object(error) === error &&\n \"code\" in errorRecord &&\n typeof errorRecord.code === \"string\") {\n const codedError = error;\n if (codedError.code.match(/^ERR_OS_/)) {\n return true;\n }\n }\n }\n return false;\n }\n}\n//# sourceMappingURL=AbstractError.js.map","import { AbstractError } from \"./AbstractError.js\";\n/**\n * Used when an operation was attempted that can not be completed in the current\n * context.\n */\nexport class InvalidOperationError extends AbstractError {\n /**\n * Constructs a new {@linkcode InvalidOperationError}.\n * @param message - The main error message.\n * @param status - The HTTP status code to return.\n */\n constructor(message, status = 400) {\n super(\"ERR_OS_INVALID_OPERATION\", message, status);\n this.name = \"InvalidOperationError\";\n if (typeof Error.captureStackTrace !== \"undefined\") {\n // Capture a new stacktrace, otherwise it will include our base-class\n // constructor instead of the code location we're actually interested in.\n Error.captureStackTrace(this, InvalidOperationError);\n }\n }\n}\n//# sourceMappingURL=InvalidOperationError.js.map","import { isNil } from \"@oliversalzburg/js-utils/data/nil.js\";\nimport { redirectErrorsToConsole } from \"@oliversalzburg/js-utils/errors/console.js\";\nimport { InvalidOperationError } from \"@oliversalzburg/js-utils/errors/InvalidOperationError.js\";\n\ndeclare global {\n const PAYLOAD: string;\n}\n\n(async () => {\n const existingLoader = document.querySelector(\"#ks-loader-singleton\");\n if (!isNil(existingLoader)) {\n throw new InvalidOperationError(\n \"The Kitten Science script loader was already created. This is unexpected.\",\n );\n }\n\n if (typeof GM !== \"undefined\") {\n const nodeScript = document.createElement(\"script\");\n nodeScript.id = \"ks-loader-singleton\";\n nodeScript.textContent = PAYLOAD;\n nodeScript.type = \"application/javascript\";\n document.body.appendChild(nodeScript);\n }\n})().catch(redirectErrorsToConsole(console));\n"],"names":["isNil","subject","redirectErrorsToConsole","console","error","AbstractError","code","message","status","__publicField","allowForeignModule","errorRecord","InvalidOperationError","existingLoader","nodeScript"],"mappings":"+PAOO,SAASA,EAAMC,EAAS,CAC3B,OAAOA,GAAY,IACvB,CCHO,MAAMC,EAA2BC,GACNC,GAAU,CACpCD,EAAQ,MAAMC,CAAK,CACtB,ECNE,MAAMC,UAAsB,KAAM,CAerC,YAAYC,EAAMC,EAASC,EAAQ,CAC/B,MAAMD,CAAO,EAZjBE,EAAA,eAIAA,EAAA,aASI,KAAK,KAAOH,EACZ,KAAK,KAAO,gBACZ,KAAK,OAASE,EACV,OAAO,MAAM,kBAAsB,KAGnC,MAAM,kBAAkB,KAAMH,CAAa,CAEvD,CASI,OAAO,gBAAgBD,EAAOM,EAAqB,GAAM,CACrD,GAAIN,aAAiBC,EACjB,MAAO,GAKX,GAAIK,EAAoB,CACpB,MAAMC,EAAcP,EACpB,GAAI,OAAOA,CAAK,IAAMA,GAClB,SAAUO,GACV,OAAOA,EAAY,MAAS,UACTP,EACJ,KAAK,MAAM,UAAU,EAChC,MAAO,EAG3B,CACQ,MAAO,EACf,CACA,CCpDO,MAAMQ,UAA8BP,CAAc,CAMrD,YAAYE,EAASC,EAAS,IAAK,CAC/B,MAAM,2BAA4BD,EAASC,CAAM,EACjD,KAAK,KAAO,wBACR,OAAO,MAAM,kBAAsB,KAGnC,MAAM,kBAAkB,KAAMI,CAAqB,CAE/D,CACA,ECZC,SAAY,CACL,MAAAC,EAAiB,SAAS,cAAc,sBAAsB,EAChE,GAAA,CAACb,EAAMa,CAAc,EACvB,MAAM,IAAID,EACR,2EACF,EAGE,GAAA,OAAO,GAAO,IAAa,CACvB,MAAAE,EAAa,SAAS,cAAc,QAAQ,EAClDA,EAAW,GAAK,sBAChBA,EAAW,YAAc,u/nWACzBA,EAAW,KAAO,yBACT,SAAA,KAAK,YAAYA,CAAU,CAAA,CAExC,GAAA,EAAK,MAAMZ,EAAwB,OAAO,CAAC","x_google_ignoreList":[0,1,2,3]}