extensions.d.ts 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /// <reference types="jquery" />
  2. declare global {
  3. /**
  4. * @param value The member being processed.
  5. * @param index The index of member being processed.
  6. * @param array The array being processed.
  7. */
  8. type ArrayPredicate<T, ThisType> = (this: ThisType, value: T, index: number, array: T[]) => boolean;
  9. interface ReadonlyArray<T> {
  10. /**
  11. * Returns the number of times that the given member was found within the array, starting the search at position.
  12. * @param needle The member to count.
  13. * @param position The zero-based index at which to begin searching for needle. If omitted, will default to 0.
  14. * @since SugarCube 2.0.0
  15. * @example
  16. * // Given: $fruits = ["Apples", "Oranges", "Plums", "Oranges"]
  17. * $fruits.count("Oranges") → Returns 2
  18. * $fruits.count("Oranges", 2) → Returns 1
  19. */
  20. count(needle: T, position?: number): number;
  21. /**
  22. * Returns the number of times that members within the array pass the test implemented by the given predicate function.
  23. * @param predicate The function used to test each member. It is called with three arguments:
  24. * value: The member being processed.
  25. * index: (optional, integer) The index of member being processed.
  26. * array: (optional, array) The array being processed.
  27. * @param thisArg The value to use as this when executing predicate.
  28. * @since SugarCube 2.36.0
  29. * @example
  30. * // Given: $fruits = ["Apples", "Oranges", "Plums", "Oranges"]
  31. * $fruits.countWith(function (fruit) { return fruit === "Oranges"; }) → Returns 2
  32. */
  33. countWith<PredicateThisArg>(predicate: ArrayPredicate<T, PredicateThisArg>, thisArg: PredicateThisArg): number;
  34. countWith(predicate: ArrayPredicate<T, undefined>): number;
  35. /**
  36. * Returns the first member from the array. Does not modify the original.
  37. * @since SugarCube 2.2.7.0
  38. * @example
  39. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  40. * $pies.first() // Returns "Blueberry"
  41. */
  42. first(): T | undefined;
  43. /**
  44. * Returns a new array consisting of the flattened source array (i.e. flat map reduce). Does not modify the original.
  45. * Equivalent to ES2019 Array.prototype.flat(Infinity).
  46. * @since SugarCube 2.0.0
  47. * @deprecated in favour of native Array.flat()
  48. * @example
  49. * // Given: $npa = [["Alfa", "Bravo"], [["Charlie", "Delta"], ["Echo"]], "Foxtrot"]
  50. * $npa.flatten() // Returns ["Alfa", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot"]
  51. */
  52. flatten(): T[];
  53. /**
  54. * Returns whether all of the given members were found within the array.
  55. * @param needles The members to find. May be a list of members or an array.
  56. * @since SugarCube 2.10.0
  57. * @example
  58. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  59. * <<if $pies.includesAll("Cherry", "Pecan")>>…found Cherry and Pecan pies…<</if>>
  60. * @example
  61. * // Given: $search = ["Blueberry", "Pumpkin"]
  62. * <<if $pies.includesAll($search)>>…found Blueberry and Pumpkin pies…<</if>>
  63. */
  64. includesAll(needles: T[]): boolean;
  65. includesAll(...needles: T[]): boolean;
  66. /**
  67. * Returns whether any of the given members were found within the array.
  68. * @param needles The members to find. May be a list of members or an array.
  69. * @since SugarCube 2.10.0
  70. * @example
  71. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  72. * <<if $pies.includesAny("Cherry", "Pecan")>>…found Cherry or Pecan pie…<</if>>
  73. * @example
  74. * // Given: $search = ["Blueberry", "Pumpkin"]
  75. * <<if $pies.includesAny($search)>>…found Blueberry or Pumpkin pie…<</if>>
  76. */
  77. includesAny(needles: T[]): boolean;
  78. includesAny(...needles: T[]): boolean;
  79. /**
  80. * Returns the last member from the array. Does not modify the original.
  81. * @since SugarCube 2.27.0
  82. * @example
  83. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  84. * $pies.last() // Returns "Pumpkin"
  85. */
  86. last(): T | undefined;
  87. /**
  88. * Returns a random member from the array. Does not modify the original.
  89. * @since SugarCube 2.0.0
  90. * @example
  91. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  92. * $pies.random() // Returns a random pie from the array
  93. */
  94. random(): T | undefined;
  95. /**
  96. * Randomly selects the given number of unique members from the array and returns the selected members as a new array.
  97. * Does not modify the original.
  98. * @param want The number of members to select.
  99. * @since SugarCube 2.20.0
  100. * @example
  101. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  102. * $pies.randomMany(3) // Returns a new array containing three unique random pies from the array
  103. */
  104. randomMany(want?: number): T[];
  105. }
  106. interface Array<T> {
  107. /**
  108. * Concatenates one or more unique members to the end of the base array and returns the result as a new array. Does not modify the original.
  109. * @param members The members to concatenate. Members which are arrays will be merged—i.e. their members will be concatenated, rather than the array itself.
  110. * @since SugarCube 2.21.0
  111. * @example
  112. * // Given: $fruits1 = ["Apples", "Oranges"], $fruits2 = ["Pears", "Plums"]
  113. * $fruits1.concatUnique($fruits2) → Returns ["Apples", "Oranges", "Pears", "Plums"]
  114. * $fruits1.concatUnique($fruits2, $fruits2) → Returns ["Apples", "Oranges", "Pears", "Plums"]
  115. * $fruits1.concatUnique("Pears") → Returns ["Apples", "Oranges", "Pears"]
  116. * $fruits1.concatUnique("Pears", "Pears") → Returns ["Apples", "Oranges", "Pears"]
  117. * $fruits1.concatUnique($fruits2, "Pears") → Returns ["Apples", "Oranges", "Pears", "Plums"]
  118. */
  119. concatUnique(...members: any[]): T[];
  120. /**
  121. * Returns the number of times that the given member was found within the array, starting the search at position.
  122. * @param needle The member to count.
  123. * @param position The zero-based index at which to begin searching for needle. If omitted, will default to 0.
  124. * @since SugarCube 2.0.0
  125. * @example
  126. * // Given: $fruits = ["Apples", "Oranges", "Plums", "Oranges"]
  127. * $fruits.count("Oranges") → Returns 2
  128. * $fruits.count("Oranges", 2) → Returns 1
  129. */
  130. count(needle: T, position?: number): number;
  131. /**
  132. * Returns the number of times that members within the array pass the test implemented by the given predicate function.
  133. * @param predicate The function used to test each member. It is called with three arguments:
  134. * value: The member being processed.
  135. * index: (optional, integer) The index of member being processed.
  136. * array: (optional, array) The array being processed.
  137. * @param thisArg The value to use as this when executing predicate.
  138. * @since SugarCube 2.36.0
  139. * @example
  140. * // Given: $fruits = ["Apples", "Oranges", "Plums", "Oranges"]
  141. * $fruits.countWith(function (fruit) { return fruit === "Oranges"; }) → Returns 2
  142. */
  143. countWith<PredicateThisArg>(predicate: ArrayPredicate<T, PredicateThisArg>, thisArg: PredicateThisArg): number;
  144. countWith(predicate: ArrayPredicate<T, undefined>): number;
  145. /**
  146. * Removes all instances of the given members from the array and returns a new array containing the removed members.
  147. * @param needles The members to remove. May be a list of members or an array.
  148. * @returns new array
  149. * @since SugarCube 2.5.0
  150. * @example
  151. * // Given: $fruits = ["Apples", "Oranges", "Plums", "Oranges"]
  152. * $fruits.delete("Oranges") → Returns ["Oranges", "Oranges"]; $fruits ["Apples", "Plums"]
  153. * $fruits.delete("Apples", "Plums") → Returns ["Apples", "Plums"]; $fruits ["Oranges", "Oranges"]
  154. */
  155. delete(...needles: T[]): T[];
  156. /**
  157. * Removes all of the members at the given indices from the array and returns a new array containing the removed
  158. * members.
  159. * @param indices The indices of the members to remove.
  160. * @since SugarCube 2.5.0
  161. * @example
  162. * // Given: $fruits = ["Apples", "Oranges", "Plums", "Oranges"]
  163. * $fruits.deleteAt(2) → Returns ["Plums"]; $fruits ["Apples", "Oranges", "Oranges"]
  164. * $fruits.deleteAt(1, 3) → Returns ["Oranges", "Oranges"]; $fruits ["Apples", "Plums"]
  165. * $fruits.deleteAt(0, 2) → Returns ["Apples", "Plums"]; $fruits ["Oranges", "Oranges"]
  166. */
  167. deleteAt(...indices: number[]): T[];
  168. /**
  169. * Removes all of the members that pass the test implemented by the given predicate function from the array and returns
  170. * a new array containing the removed members.
  171. * @param predicate The function used to test each member. It is called with three arguments:
  172. * value: The member being processed.
  173. * index: (optional, integer) The index of member being processed.
  174. * array: (optional, array) The array being processed.
  175. * @param thisArg The value to use as this when executing predicate.
  176. * @example
  177. * // Given: $fruits = ["Apples", "Apricots", "Oranges"]
  178. * $fruits.deleteWith(function (val) {
  179. * return val === "Apricots";
  180. * }) // Returns ["Apricots"];
  181. * // and now $fruits is ["Apples", "Oranges"]
  182. *
  183. * $fruits.deleteWith(function (val) {
  184. * return val.startsWith("Ap");
  185. * }) // Returns ["Apples", "Apricots"];
  186. * // and now $fruits is ["Oranges"]
  187. *
  188. * // Given: $fruits = [{ name : "Apples" }, { name : "Apricots" }, { name : "Oranges" }]
  189. * $fruits.deleteWith(function (val) {
  190. * return val.name === "Apricots";
  191. * }) // Returns [{ name : "Apricots" }]; $fruits [{ name : "Apples" }, { name : "Oranges" }]
  192. *
  193. * $fruits.deleteWith(function (val) {
  194. * return val.name.startsWith("Ap");
  195. * }) // Returns [{ name : "Apples" }, { name : "Apricots" }];
  196. * // and now $fruits is [{ name : "Oranges" }]
  197. */
  198. deleteWith<PredicateThisArg>(predicate: ArrayPredicate<T, PredicateThisArg>, thisArg: PredicateThisArg): T[];
  199. deleteWith(predicate: ArrayPredicate<T, undefined>): T[];
  200. /**
  201. * Returns the first member from the array. Does not modify the original.
  202. * @since SugarCube 2.2.7.0
  203. * @example
  204. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  205. * $pies.first() // Returns "Blueberry"
  206. */
  207. first(): T | undefined;
  208. /**
  209. * Returns a new array consisting of the flattened source array (i.e. flat map reduce). Does not modify the original.
  210. * Equivalent to ES2019 Array.prototype.flat(Infinity).
  211. * @since SugarCube 2.0.0
  212. * @deprecated in favour of native Array.flat()
  213. * @example
  214. * // Given: $npa = [["Alfa", "Bravo"], [["Charlie", "Delta"], ["Echo"]], "Foxtrot"]
  215. * $npa.flatten() // Returns ["Alfa", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot"]
  216. */
  217. flatten(): T[];
  218. /**
  219. * Returns whether all of the given members were found within the array.
  220. * @param needles The members to find. May be a list of members or an array.
  221. * @since SugarCube 2.10.0
  222. * @example
  223. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  224. * <<if $pies.includesAll("Cherry", "Pecan")>>…found Cherry and Pecan pies…<</if>>
  225. * @example
  226. * // Given: $search = ["Blueberry", "Pumpkin"]
  227. * <<if $pies.includesAll($search)>>…found Blueberry and Pumpkin pies…<</if>>
  228. */
  229. includesAll(needles: T[]): boolean;
  230. includesAll(...needles: T[]): boolean;
  231. /**
  232. * Returns whether any of the given members were found within the array.
  233. * @param needles The members to find. May be a list of members or an array.
  234. * @since SugarCube 2.10.0
  235. * @example
  236. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  237. * <<if $pies.includesAny("Cherry", "Pecan")>>…found Cherry or Pecan pie…<</if>>
  238. * @example
  239. * // Given: $search = ["Blueberry", "Pumpkin"]
  240. * <<if $pies.includesAny($search)>>…found Blueberry or Pumpkin pie…<</if>>
  241. */
  242. includesAny(needles: T[]): boolean;
  243. includesAny(...needles: T[]): boolean;
  244. /**
  245. * Returns the last member from the array. Does not modify the original.
  246. * @since SugarCube 2.27.0
  247. * @example
  248. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  249. * $pies.last() // Returns "Pumpkin"
  250. */
  251. last(): T | undefined;
  252. /**
  253. * Removes and returns a random member from the array.
  254. * @since SugarCube 2.0.0
  255. * @example
  256. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  257. * $pies.pluck() // Removes and returns a random pie from the array
  258. */
  259. pluck(): T | undefined;
  260. /**
  261. * Randomly removes the given number of members from the base array and returns the removed members as a new array.
  262. * @param want The number of members to pluck.
  263. * @since SugarCube 2.20.0
  264. * @example
  265. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  266. * $pies.pluckMany(3) // Removes three random pies from the array and returns them as a new array
  267. */
  268. pluckMany(want?: number): T[];
  269. /**
  270. * Appends one or more unique members to the end of the base array and returns its new length.
  271. * @param members The members to append.
  272. * @since 2.21.0
  273. * @example
  274. * // Given: $fruits = ["Apples", "Oranges"]
  275. * $fruits.pushUnique("Apples") // Returns 2; $fruits ["Apples", "Oranges"]
  276. * $fruits.pushUnique("Plums", "Plums") // Returns 3; $fruits ["Apples", "Oranges", "Plums"]
  277. */
  278. pushUnique(...members: T[]): number;
  279. /**
  280. * Returns a random member from the array. Does not modify the original.
  281. * @since SugarCube 2.0.0
  282. * @example
  283. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  284. * $pies.random() // Returns a random pie from the array
  285. */
  286. random(): T | undefined;
  287. /**
  288. * Randomly selects the given number of unique members from the array and returns the selected members as a new array.
  289. * Does not modify the original.
  290. * @param want The number of members to select.
  291. * @since SugarCube 2.20.0
  292. * @example
  293. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  294. * $pies.randomMany(3) // Returns a new array containing three unique random pies from the array
  295. */
  296. randomMany(want?: number): T[];
  297. /**
  298. * Randomly shuffles the array.
  299. * @since SugarCube 2.0.0
  300. * @example
  301. * // Given: $pies = ["Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin"]
  302. * $pies.shuffle() // Randomizes the order of the pies in the array
  303. */
  304. shuffle(): T[];
  305. /**
  306. * Prepends one or more unique members to the beginning of the base array and returns its new length.
  307. * @param members The members to append.
  308. * @since SugarCube 2.21.0
  309. * @example
  310. * // Given: $fruits = ["Oranges", "Plums"]
  311. * $fruits.unshiftUnique("Oranges") // Returns 2; $fruits ["Oranges", "Plums"]
  312. * $fruits.unshiftUnique("Apples", "Apples") // Returns 3; $fruits ["Apples", "Oranges", "Plums"]
  313. */
  314. unshiftUnique(...members: T[]): number;
  315. // deprecated members
  316. /**
  317. * @deprecated in favor of <Array>.includes().
  318. */
  319. contains(needle: T, position?: number): boolean;
  320. /**
  321. * @deprecated Deprecated in favor of <Array>.includesAll().
  322. */
  323. containsAll(...needle: T[]): boolean;
  324. /**
  325. * @deprecated in favor of <Array>.includesAny().
  326. */
  327. containsAny(...needle: T[]): boolean;
  328. }
  329. interface JSON {
  330. /**
  331. * Returns the given code string, and optional data chunk, wrapped within the JSON deserialization revive wrapper.
  332. * Intended to allow authors to easily wrap their custom object types (a.k.a. classes) revival code and associated data
  333. * within the revive wrapper, which should be returned from an object instance's .toJSON() method, so that the instance
  334. * may be properly revived upon deserialization.
  335. * @param codeString The revival code string to wrap.
  336. * @param reviveData he data which should be made available to the evaluated revival code during deserialization via the
  337. * special $ReviveData$ variable. WARNING: Attempting to pass the value of an object instance's this directly as the
  338. * reviveData parameter will trigger out of control recursion in the serializer, so a clone of the instance's own data
  339. * must be passed instead.
  340. * @since SugarCube 2.9.0
  341. * @example
  342. * JSON.reviveWrapper( <valid JavaScript code string> ); // -> Without data chunk
  343. * JSON.reviveWrapper( <valid JavaScript code string> , myOwnData); // -> With data chunk
  344. * // E.g. Assume that you're attempting to revive an instance of a custom class named
  345. * // `Character`, which is assigned to a story variable named `$pc`. The call
  346. * // to `JSON.reviveWrapper()` might look something like the following.
  347. * var ownData = {};
  348. * Object.keys(this).forEach(function (pn) { ownData[pn] = clone(this[pn]); }, this);
  349. * return JSON.reviveWrapper('new Character($ReviveData$)', ownData);
  350. */
  351. reviveWrapper(codeString: string, reviveData?: any): [];
  352. }
  353. interface Math {
  354. /**
  355. * Returns the given number clamped to the specified bounds. Does not modify the original.
  356. * @param num The number to clamp. May be an actual number or a numerical string.
  357. * @param min The lower bound of the number.
  358. * @param max The upper bound of the number.
  359. * @since 2.0.0
  360. * @example
  361. * Math.clamp($stat, 0, 200) // Clamps $stat to the bounds 0–200 and returns the new value
  362. * Math.clamp($stat, 1, 6.6) // Clamps $stat to the bounds 1–6.6 and returns the new value
  363. */
  364. clamp(num: number | string, min: number, max: number): number;
  365. /**
  366. * Returns the whole(integer) part of the given number by removing its fractional part, if any. Does not modify the
  367. * original.
  368. * @param num The number to truncate to an integer.
  369. * @since 2.0.0
  370. * @example
  371. * Math.trunc(12.7) // Returns 12
  372. * Math.trunc(-12.7) // Returns -12
  373. */
  374. trunc(num: number): number;
  375. }
  376. interface Number {
  377. /**
  378. * Returns the number clamped to the specified bounds. Does not modify the original.
  379. * @param min The lower bound of the number.
  380. * @param max The upper bound of the number.
  381. * @since 2.0.0
  382. * @example
  383. * $stat.clamp(0, 200) → Clamps $stat to the bounds 0–200 and returns the new value
  384. * $stat.clamp(1, 6.6) → Clamps $stat to the bounds 1–6.6 and returns the new value
  385. */
  386. clamp(min: number, max: number): number;
  387. }
  388. interface JQueryAriaClickOptions {
  389. /**
  390. * A period-separated list of event namespaces.
  391. */
  392. namespace?: string | undefined;
  393. /**
  394. * Whether the clickables are single-use—i.e., the handler callback runs only once and then removes itself.
  395. * If omitted, defaults to false.
  396. */
  397. one?: boolean | undefined;
  398. /**
  399. * A selector applied to the target element(s) to filter the descendants that triggered the event. If omitted or
  400. * null, the event is always handled when it reaches the target element(s)
  401. */
  402. selector?: string | undefined;
  403. /**
  404. * Data to be passed to the handler in event.data when an event is triggered.
  405. */
  406. data?: any;
  407. /**
  408. * Value for the aria-controls attribute.
  409. */
  410. controls?: string | undefined;
  411. /**
  412. * Value for the aria-pressed attribute (valid values: "true", "false").
  413. */
  414. pressed?: "true" | "false" | undefined;
  415. /**
  416. * Value for the aria-label and title attributes.
  417. */
  418. label?: string | undefined;
  419. }
  420. interface RegExpConstructor {
  421. /**
  422. * Returns the given string with all regular expression metacharacters escaped. Does not modify the original.
  423. * @param text The string to escape.
  424. * @since 2.0.0
  425. * @example
  426. * RegExp.escape('That will be $5 (cash only)') // Returns 'That will be \$5 \(cash only\)'
  427. */
  428. escape(text: string): string;
  429. }
  430. interface String {
  431. /**
  432. * Returns the number of times that the given substring was found within the string, starting the search at position.
  433. * @param needle The substring to count.
  434. * @param position The zero-based index at which to begin searching for needle. If omitted, will default to 0.
  435. * @since 2.0.0
  436. */
  437. count(needle: string, position?: number): number;
  438. /**
  439. * Returns the first Unicode code point within the string. Does not modify the original.
  440. * @since 2.27.0
  441. */
  442. first(): string;
  443. /**
  444. * Returns the last Unicode code point within the string. Does not modify the original.
  445. * @since 2.27.0
  446. */
  447. last(): string;
  448. /**
  449. * Returns the string with its first Unicode code point converted to upper case, according to any locale-specific rules.
  450. * Does not modify the original.
  451. * @since 2.9.0
  452. */
  453. toLocaleUpperFirst(): string;
  454. /**
  455. * Returns the string with its first Unicode code point converted to upper case. Does not modify the original.
  456. * @since 2.9.0
  457. */
  458. toUpperFirst(): string;
  459. }
  460. interface StringConstructor {
  461. /**
  462. * Returns a formatted string, after replacing each format item in the given format string with the text equivalent of the
  463. * corresponding argument's value.
  464. * @param format The format string, which consists of normal text and format items.
  465. * @param arguments Either a list of arguments, which correspond by-index to the format items within the format string, or an
  466. * array, whose members correspond by-index.
  467. *
  468. * A format item has the syntax {index[,alignment]}, square-brackets denoting optional elements.
  469. * * **index**: (integer) The (zero-based) index of the argument whose string representation will replace the format item.
  470. * * **alignment**: (optional, integer) The total length of the field into which the argument is inserted, and whether it's
  471. * right- or left-aligned (positive aligns right, negative aligns left).
  472. *
  473. * @since 2.0.0
  474. * @example
  475. * String.format("{0}, {1}!", "Hello", "World"); //List of arguments; Returns "Hello, World!"
  476. * String.format("{0}, {1}!", [ "Hello", "World" ]); //Array argument; Returns "Hello, World!"
  477. * String.format("{0,6}", "foo"); // Returns " foo"
  478. * String.format("{0,-6}", "foo"); //Returns "foo "
  479. */
  480. format(format: string, ...arguments: any[]): string;
  481. }
  482. interface JQuery {
  483. /**
  484. * Makes the target element(s) WAI-ARIA-compatible clickables—meaning that various accessibility attributes are set and,
  485. * in addition to mouse clicks, enter/return and spacebar key presses also activate them. Returns a reference to the current
  486. * jQuery object for chaining.
  487. * @param handler The callback to invoke when the target element(s) are activated.
  488. * @since 2.0.0
  489. * @example
  490. * // Given an existing element: <a id="so-clicky">Click me</a>
  491. * $('#so-clicky').ariaClick(function (event) {
  492. * // do stuff
  493. * });
  494. *
  495. * @example
  496. * // Creates a basic link and appends it to the `output` element
  497. * $('<a>Click me</a>')
  498. * .ariaClick(function (event) {
  499. * // do stuff
  500. * })
  501. * .appendTo(output);
  502. *
  503. * @example
  504. * // Creates a basic button and appends it to the `output` element
  505. * $('<button>Click me</button>')
  506. * .ariaClick(function (event) {
  507. * // do stuff
  508. * })
  509. * .appendTo(output);
  510. */
  511. ariaClick(handler: (event: JQuery.Event) => void): this;
  512. /**
  513. * Makes the target element(s) WAI-ARIA-compatible clickables—meaning that various accessibility attributes are set and,
  514. * in addition to mouse clicks, enter/return and spacebar key presses also activate them. Returns a reference to the current
  515. * jQuery object for chaining.
  516. * @param options The options to be used when creating the clickables.
  517. * @param handler The callback to invoke when the target element(s) are activated.
  518. * @example
  519. * // Creates a link with options and appends it to the `output` element
  520. * $('<a>Click me</a>')
  521. * .ariaClick({
  522. * one : true,
  523. * label : 'This single-use link does stuff.'
  524. * }, function (event) {
  525. * // do stuff
  526. * })
  527. * .appendTo(output);
  528. */
  529. ariaClick(options: JQueryAriaClickOptions, handler: (event: JQuery.Event) => void): this;
  530. /**
  531. * Changes the disabled state of the target WAI-ARIA-compatible clickable element(s). Returns a reference to the current
  532. * jQuery object for chaining.
  533. * NOTE: This method is meant to work with clickables created via <jQuery>.ariaClick() and may not work with clickables
  534. * from other sources. SugarCube uses <jQuery>.ariaClick() internally to handle all of its various link markup and macros.
  535. * @param state The disabled state to apply. Truthy to disable the element(s), falsy to enable them.
  536. * @since 2.26.0
  537. * @example
  538. * // Given an existing WAI-ARIA-compatible clickable element with the ID "so-clicky"
  539. * $('#so-clicky').ariaDisabled(true); // Disables the target element
  540. * $('#so-clicky').ariaDisabled(false); // Enables the target element
  541. */
  542. ariaDisabled(state: boolean): boolean;
  543. /**
  544. * Returns whether any of the target WAI-ARIA-compatible clickable element(s) are disabled.
  545. *
  546. * NOTE: This method is meant to work with clickables created via <jQuery>.ariaClick() and may not work with clickables
  547. * from other sources. SugarCube uses <jQuery>.ariaClick() internally to handle all of its various link markup and macros.
  548. * @since 2.26.0
  549. * @example
  550. * // Given an existing WAI-ARIA-compatible clickable element with the ID "so-clicky"
  551. * // If "#so-clicky" is disabled:
  552. * $('#so-clicky').ariaIsDisabled(); // Returns true
  553. *
  554. * // If "#so-clicky" is enabled:
  555. * $('#so-clicky').ariaIsDisabled(); // Returns false
  556. */
  557. ariaIsDisabled(): boolean;
  558. /**
  559. * Wikifies the given content source(s) and appends the result to the target element(s). Returns a reference to the
  560. * current jQuery object for chaining.
  561. * @param sources The list of content sources.
  562. * @since 2.0.0
  563. * @example
  564. * // Given an element: <div id="the-box"></div>
  565. * $('#the-box').wiki('Who //are// you?'); // Appends "Who <em>are</em> you?" to the target element
  566. */
  567. wiki(...sources: string[]): this;
  568. }
  569. interface JQueryStatic {
  570. /**
  571. * Wikifies the given content source(s) and discards the result. If there were errors, an exception is thrown. This is only
  572. * really useful when you want to invoke a macro for its side-effects and aren't interested in its output.
  573. * @param sources The list of content sources.
  574. * @since 2.17.0
  575. * @example
  576. * $.wiki('<<somemacro>>'); // Invokes the <<somemacro>> macro, discarding any output
  577. */
  578. wiki(...sources: string[]): void;
  579. }
  580. }
  581. export {};