-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
Cargo.lock | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export {}; | ||
|
||
declare global { | ||
/** | ||
* Console interface for logging. | ||
* | ||
* Currently logs are only available in the backend logs. | ||
* See https://docs.caido.io/report_bug.html#1-backend-logs | ||
*/ | ||
type Console = { | ||
debug(message: any): void; | ||
log(message: any): void; | ||
warn(message: any): void; | ||
error(message: any): void; | ||
}; | ||
var console: Console; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="console.d.ts" /> | ||
/// <reference path="timers.d.ts" /> | ||
/// <reference path="url.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "rquickjs-extra-types", | ||
"license": "Apache-2.0", | ||
"version": "0.0.1", | ||
"main": "", | ||
"types": "index.d.ts", | ||
"description": "Type definitions for rquickjs-extra", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/rquickjs/rquickjs-extra", | ||
"directory": "types" | ||
}, | ||
"files": [ | ||
"*.d.ts" | ||
], | ||
"devDependencies": { | ||
"typescript": "^5.5.3" | ||
}, | ||
"scripts": { | ||
"test": "tsc" | ||
}, | ||
"keywords": [ | ||
"quickjs", | ||
"types" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
export {}; | ||
|
||
declare global { | ||
/** | ||
* This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the | ||
* scheduled actions. | ||
*/ | ||
class Timeout {} | ||
|
||
/** | ||
* Schedules execution of a one-time `callback` after `delay` milliseconds. | ||
* | ||
* The `callback` will likely not be invoked in precisely `delay` milliseconds. | ||
* Caido makes no guarantees about the exact timing of when callbacks will fire, | ||
* nor of their ordering. The callback will be called as close as possible to the | ||
* time specified. | ||
* | ||
* When `delay` is less than `4`, the `delay` will be set to `4`. | ||
* | ||
* @param callback The function to call when the timer elapses. | ||
* @param [delay=4] The number of milliseconds to wait before calling the `callback`. | ||
* @return for use with {@link clearTimeout} | ||
*/ | ||
function setTimeout<TArgs extends any[]>( | ||
callback: (...args: TArgs) => void, | ||
ms?: number, | ||
): Timeout; | ||
|
||
/** | ||
* Cancels a `Timeout` object created by `setTimeout()`. | ||
* @param timeout A `Timeout` object as returned by {@link setTimeout}. | ||
*/ | ||
function clearTimeout(timeout: Timeout): void; | ||
|
||
/** | ||
* Schedules repeated execution of `callback` every `delay` milliseconds. | ||
* | ||
* When `delay` isless than `4`, the `delay` will be set to `4`. | ||
* | ||
* @param callback The function to call when the timer elapses. | ||
* @param [delay=4] The number of milliseconds to wait before calling the `callback`. | ||
* @return for use with {@link clearInterval} | ||
*/ | ||
function setInterval<TArgs extends any[]>( | ||
callback: (...args: TArgs) => void, | ||
ms?: number, | ||
): Timeout; | ||
|
||
/** | ||
* Cancels a `Timeout` object created by `setInterval()`. | ||
* @param timeout A `Timeout` object as returned by {@link setInterval} | ||
*/ | ||
function clearInterval(interval: Timeout): void; | ||
|
||
/** | ||
* Schedules the "immediate" execution of the `callback` after I/O events' | ||
* callbacks. | ||
* | ||
* @param callback The function to call at the end of this turn of the Node.js `Event Loop` | ||
* @return for use with {@link clearImmediate} | ||
*/ | ||
function setImmediate<TArgs extends any[]>( | ||
callback: (...args: TArgs) => void, | ||
): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["ESNext"], | ||
"skipLibCheck": false, | ||
"strict": true, | ||
"target": "esnext", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"disableSolutionSearching": true, | ||
"noUnusedLocals": true, | ||
"noEmit": true, | ||
"resolveJsonModule": true, | ||
"types": [] | ||
}, | ||
"exclude": ["dist", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
export {}; | ||
|
||
declare global { | ||
/** | ||
* The URLSearchParams interface defines utility methods to work with the query string of a URL. | ||
*/ | ||
class URLSearchParams implements Iterable<[string, string]> { | ||
constructor( | ||
init?: | ||
| URLSearchParams | ||
| string | ||
| { readonly [name: string]: string } | ||
| Iterable<readonly [name: string, value: string]> | ||
| ReadonlyArray<readonly [name: string, value: string]>, | ||
); | ||
/** | ||
* Append a new name-value pair to the query string. | ||
*/ | ||
append(name: string, value: string): void; | ||
/** | ||
* If `value` is provided, removes all name-value pairs | ||
* where name is `name` and value is `value`. | ||
* | ||
* If `value` is not provided, removes all name-value pairs whose name is `name`. | ||
*/ | ||
delete(name: string, value?: string): void; | ||
/** | ||
* Returns an ES6 `Iterator` over each of the name-value pairs in the query. | ||
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`. | ||
* | ||
* Alias for `urlSearchParams[@@iterator]()`. | ||
*/ | ||
entries(): IterableIterator<[string, string]>; | ||
/** | ||
* Iterates over each name-value pair in the query and invokes the given function. | ||
* | ||
* ```js | ||
* const myURL = new URL('https://example.org/?a=b&c=d'); | ||
* myURL.searchParams.forEach((value, name) => { | ||
* console.log(name, value); | ||
* }); | ||
* // Prints: | ||
* // a b | ||
* // c d | ||
* ``` | ||
* @param fn Invoked for each name-value pair in the query | ||
*/ | ||
forEach(fn: (value: string, name: string) => void): void; | ||
/** | ||
* Returns the value of the first name-value pair whose name is `name`. If there | ||
* are no such pairs, `null` is returned. | ||
* @return or `null` if there is no name-value pair with the given `name`. | ||
*/ | ||
get(name: string): string | null; | ||
/** | ||
* Returns the values of all name-value pairs whose name is `name`. If there are | ||
* no such pairs, an empty array is returned. | ||
*/ | ||
getAll(name: string): string[]; | ||
/** | ||
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument. | ||
* | ||
* If `value` is provided, returns `true` when name-value pair with | ||
* same `name` and `value` exists. | ||
* | ||
* If `value` is not provided, returns `true` if there is at least one name-value | ||
* pair whose name is `name`. | ||
*/ | ||
has(name: string, value?: string): boolean; | ||
/** | ||
* Returns an ES6 `Iterator` over the names of each name-value pair. | ||
* | ||
* ```js | ||
* const params = new URLSearchParams('foo=bar&foo=baz'); | ||
* for (const name of params.keys()) { | ||
* console.log(name); | ||
* } | ||
* // Prints: | ||
* // foo | ||
* // foo | ||
* ``` | ||
*/ | ||
keys(): IterableIterator<string>; | ||
/** | ||
* Sets the value in the `URLSearchParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`, | ||
* set the first such pair's value to `value` and remove all others. If not, | ||
* append the name-value pair to the query string. | ||
* | ||
* ```js | ||
* const params = new URLSearchParams(); | ||
* params.append('foo', 'bar'); | ||
* params.append('foo', 'baz'); | ||
* params.append('abc', 'def'); | ||
* console.log(params.toString()); | ||
* // Prints foo=bar&foo=baz&abc=def | ||
* | ||
* params.set('foo', 'def'); | ||
* params.set('xyz', 'opq'); | ||
* console.log(params.toString()); | ||
* // Prints foo=def&abc=def&xyz=opq | ||
* ``` | ||
*/ | ||
set(name: string, value: string): void; | ||
/** | ||
* The total number of parameter entries. | ||
*/ | ||
readonly size: number; | ||
/** | ||
* Sort all existing name-value pairs in-place by their names. Sorting is done | ||
* with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs | ||
* with the same name is preserved. | ||
* | ||
* This method can be used, in particular, to increase cache hits. | ||
* | ||
* ```js | ||
* const params = new URLSearchParams('query[]=abc&type=search&query[]=123'); | ||
* params.sort(); | ||
* console.log(params.toString()); | ||
* // Prints query%5B%5D=abc&query%5B%5D=123&type=search | ||
* ``` | ||
*/ | ||
sort(): void; | ||
/** | ||
* Returns the search parameters serialized as a string, with characters | ||
* percent-encoded where necessary. | ||
*/ | ||
toString(): string; | ||
/** | ||
* Returns an ES6 `Iterator` over the values of each name-value pair. | ||
*/ | ||
values(): IterableIterator<string>; | ||
[Symbol.iterator](): IterableIterator<[string, string]>; | ||
} | ||
} |