diff --git a/types/gimloader/gimloader-tests.ts b/types/gimloader/gimloader-tests.ts index cfbd110a7d27797..f2fd65962160ab8 100644 --- a/types/gimloader/gimloader-tests.ts +++ b/types/gimloader/gimloader-tests.ts @@ -41,3 +41,6 @@ api.UI.showModal(document.createElement("div"), { api.patcher.before({}, "foo", () => {}); api.patcher.before({}, "foo", () => true); +GL.net.gamemode; // $ExpectType string +api.net.gamemode; // $ExpectType string +api.net.onLoad((type, gamemode) => {}); diff --git a/types/gimloader/index.d.ts b/types/gimloader/index.d.ts index 82827e3972cc41a..201c1a1e5f05c44 100644 --- a/types/gimloader/index.d.ts +++ b/types/gimloader/index.d.ts @@ -188,6 +188,7 @@ declare namespace Gimloader { needsLib: string[]; optionalLib: string[]; syncEval: string; + gamemode: string[]; hasSettings: string; }; /** Gets the exported values of a plugin, if it has been enabled */ @@ -219,6 +220,7 @@ declare namespace Gimloader { needsLib: string[]; optionalLib: string[]; syncEval: string; + gamemode: string[]; hasSettings: string; }; /** Gets the exported values of a library */ @@ -403,12 +405,14 @@ declare namespace Gimloader { class ScopedNetApi extends BaseNetApi { private readonly id; - constructor(id: string); + private readonly defaultGamemode; + constructor(id: string, defaultGamemode: string[]); /** - * Runs a callback when the game is loaded, or runs it immediately if the game has already loaded + * Runs a callback when the game is loaded, or runs it immediately if the game has already loaded. + * If the \@gamemode header is set the callback will only fire if the gamemode matches one of the provided gamemodes. * @returns A function to cancel waiting for load */ - onLoad(callback: (type: ConnectionType) => void): () => void; + onLoad(callback: (type: ConnectionType, gamemode: string) => void, gamemode?: string | string[]): () => void; } type ConnectionType = "None" | "Colyseus" | "Blueboat"; @@ -417,6 +421,8 @@ declare namespace Gimloader { constructor(); /** Which type of server the client is currently connected to */ get type(): ConnectionType; + /** The id of the gamemode the player is currently playing */ + get gamemode(): string; /** The room that the client is connected to, or null if there is no connection */ get room(): any; /** Whether the user is the one hosting the current game */ @@ -431,7 +437,11 @@ declare namespace Gimloader { * Runs a callback when the game is loaded, or runs it immediately if the game has already loaded * @returns A function to cancel waiting for load */ - onLoad(id: string, callback: (type: ConnectionType) => void): () => void; + onLoad( + id: string, + callback: (type: ConnectionType, gamemode: string) => void, + gamemode?: string | string[], + ): () => void; /** Cancels any calls to {@link onLoad} with the same id */ offLoad(id: string): void; /** diff --git a/types/gimloader/package.json b/types/gimloader/package.json index 742329683406922..8991085684f142b 100644 --- a/types/gimloader/package.json +++ b/types/gimloader/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/gimloader", - "version": "1.7.9999", + "version": "1.8.9999", "nonNpm": "conflict", "nonNpmDescription": "Types for the Gimloader global variables", "projects": [ diff --git a/types/html-minifier-next/html-minifier-next-tests.ts b/types/html-minifier-next/html-minifier-next-tests.ts index a252c1b7be94346..e0883e040c2bd65 100644 --- a/types/html-minifier-next/html-minifier-next-tests.ts +++ b/types/html-minifier-next/html-minifier-next-tests.ts @@ -1,5 +1,5 @@ import required = require("html-minifier-next"); -import imported, { MinifierOptions, minify } from "html-minifier-next"; +import imported, { type MinifierOptions, minify } from "html-minifier-next"; import * as namespaced from "html-minifier-next"; // $ExpectType Promise @@ -55,7 +55,6 @@ const options: MinifierOptions = { useShortDoctype: true, }; -const optionsImported: imported.MinifierOptions = options; const optionsRequired: required.MinifierOptions = options; const optionsNamespaced: namespaced.MinifierOptions = options; diff --git a/types/html-minifier-next/index.d.cts b/types/html-minifier-next/index.d.cts index 73469a6b9feac04..700856500068cc5 100644 --- a/types/html-minifier-next/index.d.cts +++ b/types/html-minifier-next/index.d.cts @@ -1,21 +1,13 @@ -import * as CleanCSS from "clean-css"; -import RelateUrl = require("relateurl"); +import type * as CleanCSS from "clean-css"; +import type * as RelateUrl from "relateurl"; import type * as Terser from "terser" with { "resolution-mode": "import" }; -export function minify(value: string, options?: MinifierOptions): Promise; - -declare namespace _default { - export { type MinifierOptions, minify }; -} - -export { _default as default }; - /** * Most of the options are disabled by default */ export interface MinifierOptions { /** - * Treat attributes in case sensitive manner (useful for custom HTML tags) + * Treat attributes in case-sensitive manner (useful for custom HTML tags) * @default false */ caseSensitive?: boolean; @@ -119,12 +111,24 @@ export interface MinifierOptions { */ includeAutoGeneratedTags?: boolean; + /** + * Array of custom element names to treat as inline, along with the built-in ones + * @default [] + */ + inlineCustomElements?: ArrayLike; + /** * Keep the trailing slash on singleton elements * @default false */ keepClosingSlash?: boolean; + /** + * Function for logging (`message` is usually a string or an Error) + * @default undefined + */ + log?: (message: unknown) => void; + /** * Maximum input length to prevent ReDoS attacks (disabled by default) * @default undefined @@ -143,18 +147,15 @@ export interface MinifierOptions { * * @default false */ - minifyCSS?: boolean | CleanCSS.Options | ((text: string, type?: string) => string); + minifyCSS?: boolean | CleanCSS.Options | ((text: string, type?: string) => string | Promise); /** * Minify JavaScript in script elements and event attributes * (uses [Terser](https://github.com/terser/terser)) * - * This property is loosely typed due to dtslint restrictions. - * It also accepts `import("terser").MinifyOptions` - * * @default false */ - minifyJS?: boolean | Terser.MinifyOptions | ((text: string, inline?: boolean) => string); + minifyJS?: boolean | Terser.MinifyOptions | ((text: string, inline?: boolean) => string | Promise); /** * Minify URLs in various attributes @@ -162,7 +163,7 @@ export interface MinifierOptions { * * @default false */ - minifyURLs?: boolean | string | RelateUrl.Options | ((text: string) => string); + minifyURLs?: boolean | string | RelateUrl.Options | ((text: string) => string | Promise); /** * Never add a newline before a tag that closes an element @@ -199,9 +200,9 @@ export interface MinifierOptions { processScripts?: string[]; /** - * Type of quote to use for attribute values (“'” or “"”) + * Type of quote to use for attribute values (`'` or `"`) */ - quoteCharacter?: string; + quoteCharacter?: "'" | "\""; /** * [Remove quotes around attributes when possible](http://perfectionkills.com/experimenting-with-html-minifier#remove_attribute_quotes) @@ -285,3 +286,8 @@ export interface MinifierOptions { */ useShortDoctype?: boolean; } + +export function minify(value: string, options?: MinifierOptions): Promise; + +declare const _default: { minify: typeof minify }; +export default _default; diff --git a/types/html-minifier-next/index.d.ts b/types/html-minifier-next/index.d.ts index 8684c0e272e37c8..f69511f3c2d4318 100644 --- a/types/html-minifier-next/index.d.ts +++ b/types/html-minifier-next/index.d.ts @@ -1,284 +1,6 @@ -import * as CleanCSS from "clean-css"; -import * as Terser from "terser"; -import RelateUrl = require("relateurl"); +import { type MinifierOptions, minify } from "./index.d.cjs"; -export function minify(value: string, options?: MinifierOptions): Promise; +export { MinifierOptions, minify }; -declare namespace htmlminifier { - export { MinifierOptions, minify }; -} - -export default htmlminifier; - -/** - * Most of the options are disabled by default - */ -export interface MinifierOptions { - /** - * Treat attributes in case sensitive manner (useful for custom HTML tags) - * @default false - */ - caseSensitive?: boolean; - - /** - * [Omit attribute values from boolean attributes](http://perfectionkills.com/experimenting-with-html-minifier#collapse_boolean_attributes) - * @default false - */ - collapseBooleanAttributes?: boolean; - - /** - * Don't leave any spaces between `display:inline;` elements when collapsing. - * Must be used in conjunction with `collapseWhitespace=true` - * - * @default false - */ - collapseInlineTagWhitespace?: boolean; - - /** - * [Collapse white space that contributes to text nodes in a document tree](http://perfectionkills.com/experimenting-with-html-minifier#collapse_whitespace) - * @default false - */ - collapseWhitespace?: boolean; - - /** - * Always collapse to 1 space (never remove it entirely). - * Must be used in conjunction with `collapseWhitespace=true` - * - * @default false - */ - conservativeCollapse?: boolean; - - /** - * [Handle parse errors](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors) instead of aborting - * @default false - */ - continueOnParseError?: boolean; - - /** - * Arrays of regexes that allow to support custom attribute assign expressions - * (e.g. `'
'`) - * - * @default [] - */ - customAttrAssign?: RegExp[]; - - /** - * Regex that specifies custom attribute to strip newlines from (e.g. `/ng-class/`) - */ - customAttrCollapse?: RegExp; - - /** - * Arrays of regexes that allow to support custom attribute surround expressions - * (e.g. ``) - * - * @default [] - */ - customAttrSurround?: RegExp[]; - - /** - * Arrays of regexes that allow to support custom event attributes for `minifyJS` (e.g. `ng-click`) - * @default [/^on[a-z]{3,}$/] - */ - customEventAttributes?: RegExp[]; - - /** - * Set maximum quantifier limit for custom fragments to prevent ReDoS attacks - * @default 200 - */ - customFragmentQuantifierLimit?: number; - - /** - * Use direct Unicode characters whenever possible - * @default false - */ - decodeEntities?: boolean; - - /** - * Parse input according to HTML5 specifications - * @default true - */ - html5?: boolean; - - /** - * Array of regexes that allow to ignore certain comments, when matched - * @default [/^!/, /^\s*#/] - */ - ignoreCustomComments?: RegExp[]; - - /** - * Array of regexes that allow to ignore certain fragments, when matched - * (e.g. ``, `{{ ... }}`, etc.) - * - * @default [/<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/] - */ - ignoreCustomFragments?: RegExp[]; - - /** - * Insert tags generated by HTML parser - * @default true - */ - includeAutoGeneratedTags?: boolean; - - /** - * Keep the trailing slash on singleton elements - * @default false - */ - keepClosingSlash?: boolean; - - /** - * Maximum input length to prevent ReDoS attacks (disabled by default) - * @default undefined - */ - maxInputLength?: number; - - /** - * Specify a maximum line length. - * Compressed output will be split by newlines at valid HTML split-points - */ - maxLineLength?: number; - - /** - * Minify CSS in style elements and style attributes - * (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)) - * - * @default false - */ - minifyCSS?: boolean | CleanCSS.Options | ((text: string, type?: string) => string); - - /** - * Minify JavaScript in script elements and event attributes - * (uses [Terser](https://github.com/terser/terser)) - * - * @default false - */ - minifyJS?: boolean | Terser.MinifyOptions | ((text: string, inline?: boolean) => string); - - /** - * Minify URLs in various attributes - * (uses [relateurl](https://github.com/stevenvachon/relateurl)) - * - * @default false - */ - minifyURLs?: boolean | string | RelateUrl.Options | ((text: string) => string); - - /** - * Never add a newline before a tag that closes an element - * @default false - */ - noNewlinesBeforeTagClose?: boolean; - - /** - * Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. - * Must be used in conjunction with `collapseWhitespace=true` - * - * @default false - */ - preserveLineBreaks?: boolean; - - /** - * Prevents the escaping of the values of attributes - * @default false - */ - preventAttributesEscaping?: boolean; - - /** - * Process contents of conditional comments through minifier - * @default false - */ - processConditionalComments?: boolean; - - /** - * Array of strings corresponding to types of script elements to process through minifier - * (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.) - * - * @default [] - */ - processScripts?: string[]; - - /** - * Type of quote to use for attribute values (“'” or “"”) - */ - quoteCharacter?: string; - - /** - * [Remove quotes around attributes when possible](http://perfectionkills.com/experimenting-with-html-minifier#remove_attribute_quotes) - * @default false - */ - removeAttributeQuotes?: boolean; - - /** - * [Strip HTML comments](http://perfectionkills.com/experimenting-with-html-minifier#remove_comments) - * @default false - */ - removeComments?: boolean; - - /** - * [Remove all attributes with whitespace-only values](http://perfectionkills.com/experimenting-with-html-minifier#remove_empty_or_blank_attributes) - * @default false - */ - removeEmptyAttributes?: boolean | ((attrName: string, tag: string) => boolean); - - /** - * [Remove all elements with empty contents](http://perfectionkills.com/experimenting-with-html-minifier#remove_empty_elements) - * @default false - */ - removeEmptyElements?: boolean; - - /** - * [Remove optional tags](http://perfectionkills.com/experimenting-with-html-minifier#remove_optional_tags) - * @default false - */ - removeOptionalTags?: boolean; - - /** - * [Remove attributes when value matches default](http://perfectionkills.com/experimenting-with-html-minifier#remove_redundant_attributes) - * @default false - */ - removeRedundantAttributes?: boolean; - - /** - * Remove `type="text/javascript"` from `script` tags. - * Other `type` attribute values are left intact - * - * @default false - */ - removeScriptTypeAttributes?: boolean; - - /** - * Remove `type="text/css"` from `style` and `link` tags. - * Other `type` attribute values are left intact - * - * @default false - */ - removeStyleLinkTypeAttributes?: boolean; - - /** - * Remove space between attributes whenever possible. **Note that this will result in invalid HTML!** - * @default false - */ - removeTagWhitespace?: boolean; - - /** - * [Sort attributes by frequency](https://github.com/j9t/html-minifier-next?tab=readme-ov-file#sorting-attributes--style-classes) - * @default false - */ - sortAttributes?: boolean; - - /** - * [Sort style classes by frequency](https://github.com/j9t/html-minifier-next?tab=readme-ov-file#sorting-attributes--style-classes) - * @default false - */ - sortClassName?: boolean; - - /** - * Trim white space around `ignoreCustomFragments` - * @default false - */ - trimCustomFragments?: boolean; - - /** - * Replaces the `doctype` with the short (HTML5) doctype - * @default false - */ - useShortDoctype?: boolean; -} +declare const _default: { minify: typeof minify }; +export default _default; diff --git a/types/html-minifier-next/package.json b/types/html-minifier-next/package.json index d603ae84722b4d1..8bb28a2379661d2 100644 --- a/types/html-minifier-next/package.json +++ b/types/html-minifier-next/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/html-minifier-next", - "version": "1.1.9999", + "version": "2.1.9999", "type": "module", "minimumTypeScriptVersion": "5.3", "projects": [