Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions types/gimloader/gimloader-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {});
18 changes: 14 additions & 4 deletions types/gimloader/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -219,6 +220,7 @@ declare namespace Gimloader {
needsLib: string[];
optionalLib: string[];
syncEval: string;
gamemode: string[];
hasSettings: string;
};
/** Gets the exported values of a library */
Expand Down Expand Up @@ -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";
Expand All @@ -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 */
Expand All @@ -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;
/**
Expand Down
2 changes: 1 addition & 1 deletion types/gimloader/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
3 changes: 1 addition & 2 deletions types/html-minifier-next/html-minifier-next-tests.ts
Original file line number Diff line number Diff line change
@@ -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<string>
Expand Down Expand Up @@ -55,7 +55,6 @@ const options: MinifierOptions = {
useShortDoctype: true,
};

const optionsImported: imported.MinifierOptions = options;
const optionsRequired: required.MinifierOptions = options;
const optionsNamespaced: namespaced.MinifierOptions = options;

Expand Down
44 changes: 25 additions & 19 deletions types/html-minifier-next/index.d.cts
Original file line number Diff line number Diff line change
@@ -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<string>;

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;
Expand Down Expand Up @@ -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<string>;

/**
* 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
Expand All @@ -143,26 +147,23 @@ export interface MinifierOptions {
*
* @default false
*/
minifyCSS?: boolean | CleanCSS.Options | ((text: string, type?: string) => string);
minifyCSS?: boolean | CleanCSS.Options | ((text: string, type?: string) => string | Promise<string>);

/**
* 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<string>);

/**
* Minify URLs in various attributes
* (uses [relateurl](https://github.com/stevenvachon/relateurl))
*
* @default false
*/
minifyURLs?: boolean | string | RelateUrl.Options | ((text: string) => string);
minifyURLs?: boolean | string | RelateUrl.Options | ((text: string) => string | Promise<string>);

/**
* Never add a newline before a tag that closes an element
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -285,3 +286,8 @@ export interface MinifierOptions {
*/
useShortDoctype?: boolean;
}

export function minify(value: string, options?: MinifierOptions): Promise<string>;

declare const _default: { minify: typeof minify };
export default _default;
Loading