Comparing version 3.0.4 to 3.1.0
350
gjs.d.ts
@@ -82,6 +82,2 @@ /* | ||
declare namespace console { | ||
export function interact(): void | ||
} | ||
declare namespace lang { | ||
@@ -145,3 +141,3 @@ // TODO: There is a lot more in Lang | ||
* Connects a callback to a signal for an object. Pass the returned ID to | ||
* `disconect()` to remove the handler. | ||
* `disconnect()` to remove the handler. | ||
* | ||
@@ -190,214 +186,4 @@ * If `callback` returns `true`, emission will stop and no other handlers will be | ||
// See also https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts | ||
declare global { | ||
interface GjsGiImports { | ||
// Will be extended by the import of more gir types | ||
versions: { | ||
[namespace: string]: string | ||
} | ||
} | ||
interface GjsImports { | ||
gi: GjsGiImports | ||
lang: typeof lang | ||
system: typeof system | ||
signals: typeof signals | ||
package: typeof package | ||
mainloop: typeof mainloop | ||
searchPath: string[] | ||
gettext: typeof gettext | ||
byteArray: typeof byteArray | ||
format: typeof format | ||
cairo: typeof cairo | ||
} | ||
function print(...args: any[]): void | ||
function printerr(...args: any[]): void | ||
function log(message: any): void | ||
function logError(exception: object, message?: any): void | ||
function logError(message?: any): void | ||
const pkg: typeof package | ||
interface Console { | ||
/** | ||
* Logs a critical message if the condition is not truthy. | ||
* {@link console.error()} for additional information. | ||
* | ||
* @param condition a boolean condition which, if false, causes | ||
* the log to print | ||
* @param data formatting substitutions, if applicable | ||
* @returns | ||
*/ | ||
assert(condition: boolean, ...data: any[]): void | ||
/** | ||
* Resets grouping and clears the terminal on systems supporting ANSI | ||
* terminal control sequences. | ||
* | ||
* In file-based stdout or systems which do not support clearing, | ||
* console.clear() has no visual effect. | ||
* | ||
*/ | ||
clear(): void | ||
/** | ||
* Logs a message with severity equal to {@link GLib.LogLevelFlags.DEBUG}. | ||
* | ||
* @param {...any} data formatting substitutions, if applicable | ||
*/ | ||
debug(...data: any[]): void | ||
/** | ||
* Logs a message with severity equal to {@link GLib.LogLevelFlags.CRITICAL}. | ||
* Does not use {@link GLib.LogLevelFlags.ERROR} to avoid asserting and | ||
* forcibly shutting down the application. | ||
* | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
error(...data: any[]): void | ||
/** | ||
* Logs a message with severity equal to {@link GLib.LogLevelFlags.INFO}. | ||
* | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
info(...data: any[]): void | ||
/** | ||
* Logs a message with severity equal to {@link GLib.LogLevelFlags.MESSAGE}. | ||
* | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
log(...data: any[]): void | ||
// 1.1.7 table(tabularData, properties) | ||
table(tabularData: any, _properties: never): void | ||
/** | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
trace(...data: any[]): void | ||
/** | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
warn(...data: any[]): void | ||
/** | ||
* @param item an item to format generically | ||
* @param [options] any additional options for the formatter. Unused | ||
* in our implementation. | ||
*/ | ||
dir(item: object, options: never): void | ||
/** | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
dirxml(...data: any[]): void | ||
// 1.2 Counting functions | ||
// https://console.spec.whatwg.org/#counting | ||
/** | ||
* Logs how many times console.count(label) has been called with a given | ||
* label. | ||
* {@link console.countReset()} for resetting a count. | ||
* | ||
* @param label unique identifier for this action | ||
*/ | ||
count(label: string): void | ||
/** | ||
* @param label the unique label to reset the count for | ||
*/ | ||
countReset(label: string): void | ||
// 1.3 Grouping functions | ||
// https://console.spec.whatwg.org/#grouping | ||
/** | ||
* @param data formatting substitutions, if applicable | ||
*/ | ||
group(...data: any[]): void | ||
/** | ||
* Alias for console.group() | ||
* | ||
* @param {...any} data formatting substitutions, if applicable | ||
*/ | ||
groupCollapsed(...data: any[]): void | ||
/** | ||
*/ | ||
groupEnd(): void | ||
// 1.4 Timing functions | ||
// https://console.spec.whatwg.org/#timing | ||
/** | ||
* @param label unique identifier for this action, pass to | ||
* console.timeEnd() to complete | ||
*/ | ||
time(label: string): void | ||
/** | ||
* Logs the time since the last call to console.time(label) where label is | ||
* the same. | ||
* | ||
* @param label unique identifier for this action, pass to | ||
* console.timeEnd() to complete | ||
* @param data string substitutions, if applicable | ||
*/ | ||
timeLog(label: string, ...data: any[]): void | ||
/** | ||
* Logs the time since the last call to console.time(label) and completes | ||
* the action. | ||
* Call console.time(label) again to re-measure. | ||
* | ||
* @param label unique identifier for this action | ||
*/ | ||
timeEnd(label: string): void | ||
// Non-standard functions which are de-facto standards. | ||
// Similar to Node, we define these as no-ops for now. | ||
/** | ||
* @deprecated Not implemented in GJS | ||
* | ||
* @param _label unique identifier for this action, pass to | ||
* console.profileEnd to complete | ||
*/ | ||
profile(_label: string): void | ||
/** | ||
* @deprecated Not implemented in GJS | ||
* | ||
* @param _label unique identifier for this action | ||
*/ | ||
profileEnd(_label: string): void | ||
/** | ||
* @deprecated Not implemented in GJS | ||
* | ||
* @param _label unique identifier for this action | ||
*/ | ||
timeStamp(_label: string): void | ||
// GJS-specific extensions for integrating with GLib structured logging | ||
/** | ||
* @param logDomain the GLib log domain this Console should print | ||
* with. Defaults to 'Gjs-Console'. | ||
*/ | ||
setLogDomain(logDomain: string): void | ||
logDomain: string | ||
} | ||
const console: Console | ||
// https://gitlab.gnome.org/GNOME/gjs/-/blob/1.73.2/modules/esm/_encoding/encodingMap.js#L7-232 | ||
@@ -626,84 +412,31 @@ type TextDecoderEncoding = | ||
interface TextDecodeOptions { | ||
// As of Gjs 1.73.2 stream mode is not supported yet. | ||
// stream?: boolean | ||
interface GjsGiImports { | ||
// Will be extended by the import of more gir types | ||
versions: { | ||
[namespace: string]: string | ||
} | ||
} | ||
interface TextDecoderOptions { | ||
/** Indicates whether the error mode is fatal. */ | ||
fatal?: boolean | ||
/** Indicates whether whether the byte order mark is ignored. */ | ||
ignoreBOM?: boolean | ||
} | ||
/** | ||
* The TextDecoder interface represents a decoder for a specific text encoding. | ||
* It takes a stream of bytes as input and emits a stream of code points. | ||
* | ||
* @version Gjs 1.69.2 | ||
*/ | ||
interface TextDecoder { | ||
/** A string containing the name of the decoder, that is a string describing the method the TextDecoder will use. */ | ||
readonly encoding: TextDecoderEncoding | ||
/** A Boolean indicating whether the error mode is fatal. */ | ||
readonly fatal: boolean | ||
/** A Boolean indicating whether the byte order mark is ignored. */ | ||
readonly ignoreBOM: boolean | ||
/** | ||
* Returns a string containing the text decoded with the method of the specific TextDecoder object. | ||
* | ||
* If the error mode is "fatal" and the encoder method encounter an error it WILL THROW a TypeError. | ||
* | ||
* @param input Buffer containing the text to decode | ||
* @param options Object defining the decode options | ||
*/ | ||
decode(input?: ArrayBufferView | ArrayBuffer, options?: TextDecodeOptions): string | ||
} | ||
const TextDecoder: { | ||
prototype: TextDecoder | ||
new (label?: TextDecoderEncoding, options?: TextDecoderOptions): TextDecoder | ||
interface GjsImports { | ||
gi: GjsGiImports | ||
lang: typeof lang | ||
system: typeof system | ||
signals: typeof signals | ||
package: typeof package | ||
mainloop: typeof mainloop | ||
searchPath: string[] | ||
gettext: typeof gettext | ||
byteArray: typeof byteArray | ||
format: typeof format | ||
cairo: typeof cairo | ||
} | ||
interface TextEncoderEncodeIntoResult { | ||
read?: number | ||
written?: number | ||
} | ||
function print(...args: any[]): void | ||
function printerr(...args: any[]): void | ||
function log(message: any): void | ||
function logError(exception: object, message?: any): void | ||
function logError(message?: any): void | ||
/** | ||
* TextEncoder takes a stream of code points as input and emits a stream of bytes. | ||
* | ||
* @version Gjs 1.69.2 | ||
*/ | ||
interface TextEncoder { | ||
readonly encoding: 'utf-8' | ||
const pkg: typeof package | ||
/** | ||
* Takes a string as input, and returns a buffer containing the text given in parameters encoded with the UTF-8 method. | ||
* | ||
* @param input Text to encode. | ||
*/ | ||
encode(input?: string): Uint8Array | ||
/** | ||
* Takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, | ||
* and returns a dictionary object indicating the progress of the encoding. | ||
* | ||
* This is potentially more performant than the older encode() method. | ||
* | ||
* @param source Text to encode. | ||
* @param destination Buffer where to place the resulting UTF-8 encoded text into. | ||
*/ | ||
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult | ||
} | ||
const TextEncoder: { | ||
prototype: TextEncoder | ||
new (): TextEncoder | ||
} | ||
interface BooleanConstructor { | ||
@@ -721,36 +454,5 @@ $gtype: GObject.GType<boolean> | ||
const imports: GjsImports | ||
const ARGV: string[] | ||
// Timers | ||
// See https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/esm/_timers.js | ||
/** | ||
* @version Gjs 1.71.1 | ||
* @param callback a callback function | ||
* @param delay the duration in milliseconds to wait before running callback | ||
* @param args arguments to pass to callback | ||
*/ | ||
function setTimeout(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source | ||
/** | ||
* @version Gjs 1.71.1 | ||
* @param callback a callback function | ||
* @param delay the duration in milliseconds to wait between calling callback | ||
* @param args arguments to pass to callback | ||
*/ | ||
function setInterval(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source | ||
/** | ||
* @version Gjs 1.71.1 | ||
* @param timeout the timeout to clear | ||
*/ | ||
function clearTimeout(timeout: GLib.Source): void | ||
/** | ||
* @version Gjs 1.71.1 | ||
* @param timeout the timeout to clear | ||
*/ | ||
function clearInterval(timeout: GLib.Source): void | ||
const imports: GjsImports | ||
} | ||
@@ -757,0 +459,0 @@ |
{ | ||
"name": "@girs/gjs", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"description": "GJS TypeScript type definitions for Gjs", | ||
@@ -46,2 +46,3 @@ "type": "module", | ||
}, | ||
"./dom": "./dom.d.ts", | ||
".": { | ||
@@ -60,8 +61,8 @@ "import": { | ||
"test": "yarn test:esm && yarn test:cjs", | ||
"test:esm": "tsc --noEmit gjs.d.ts", | ||
"test:cjs": "tsc --noEmit gjs.d.cts" | ||
"test:esm": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gjs.d.ts", | ||
"test:cjs": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gjs.d.cts" | ||
}, | ||
"dependencies": { | ||
"@girs/glib-2.0": "^2.76.1-3.0.4", | ||
"@girs/gobject-2.0": "^2.76.1-3.0.4" | ||
"@girs/glib-2.0": "^2.76.1-3.1.0", | ||
"@girs/gobject-2.0": "^2.76.1-3.1.0" | ||
}, | ||
@@ -68,0 +69,0 @@ "devDependencies": { |
@@ -7,3 +7,3 @@ | ||
GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v3.0.4. | ||
GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v3.1.0. | ||
@@ -37,3 +37,4 @@ [GJS](https://gitlab.gnome.org/GNOME/gjs) is a JavaScript runtime for the GNOME ecosystem. Using GJS and the type definitions in this NPM package, you can build GTK applications in JavaScript or TypeScript with type checking, better autocompletion and inline documentations. | ||
```ts | ||
console.log('Hello World from console'); | ||
import '@girs/gjs'; | ||
print('Hello World from print'); | ||
@@ -43,8 +44,27 @@ | ||
// And so on... | ||
``` | ||
### Global DOM types | ||
Some types that conflict with the DOM are outsourced to allow frameworks like Gjsify to rebuild the DOM API without causing type conflicts. | ||
But you can easily import them: | ||
```ts | ||
import '@girs/gjs/dom'; | ||
console.log('Hello World from console'); | ||
const encoder = new TextEncoder(); | ||
const encoded = encoder.encode('𝓽𝓮𝔁𝓽'); | ||
setTimeout(() => { | ||
// ... | ||
}, 1000); | ||
// And so on... | ||
``` | ||
To avoid a type conflict with the DOM types it is recommended to either modify your `tsconfig.json` or `jsconfig.json` file to exclude the DOM lib, or to enable the `noLib` property. | ||
### Ambient Modules | ||
@@ -87,2 +107,3 @@ | ||
import '@girs/gjs' | ||
import '@girs/gjs/dom' | ||
import '@girs/gio-2.0' | ||
@@ -89,0 +110,0 @@ import '@girs/gtk-4.0' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21
815
127
49776