From beebb0840e7663f45b2edc96c3c5d6e363574470 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sun, 10 Mar 2024 21:57:52 -0700 Subject: [PATCH 01/53] Remove types submodule --- .gitmodules | 4 ---- types | 1 - 2 files changed, 5 deletions(-) delete mode 160000 types diff --git a/.gitmodules b/.gitmodules index 1737af562..08d648c77 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,7 +2,3 @@ path = vala-girs url = https://github.com/nemequ/vala-girs.git branch = master -[submodule "types"] - path = types - url = https://github.com/gjsify/types - branch = main \ No newline at end of file diff --git a/types b/types deleted file mode 160000 index 9104102dc..000000000 --- a/types +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9104102dcdfc002d86b4ffaac69ff02ed778f503 From a9b1c7668acc383f8ed3ebfd0ff172971854fc89 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Thu, 15 Jun 2023 23:55:32 -0700 Subject: [PATCH 02/53] Add @gi.ts/parser sources --- packages/cli/src/module-loader.ts | 1 + packages/parser/.gitignore | 1 + packages/parser/LICENSE | 7 + packages/parser/package.json | 37 + packages/parser/src/lib.ts | 3 + packages/parser/src/parser.ts | 17 + packages/parser/src/xml.ts | 710 ++ packages/parser/tsconfig.json | 24 + yarn.lock | 15319 +--------------------------- 9 files changed, 854 insertions(+), 15265 deletions(-) create mode 100644 packages/parser/.gitignore create mode 100644 packages/parser/LICENSE create mode 100644 packages/parser/package.json create mode 100644 packages/parser/src/lib.ts create mode 100644 packages/parser/src/parser.ts create mode 100644 packages/parser/src/xml.ts create mode 100644 packages/parser/tsconfig.json diff --git a/packages/cli/src/module-loader.ts b/packages/cli/src/module-loader.ts index f6211d7ad..83fdebb62 100644 --- a/packages/cli/src/module-loader.ts +++ b/packages/cli/src/module-loader.ts @@ -8,6 +8,7 @@ import { basename } from 'path' import { readFile } from 'fs/promises' import { bold } from 'colorette' import * as xml2js from 'xml2js' +import * as parser from '@gi.ts/parser' import { DependencyManager, ResolveType, diff --git a/packages/parser/.gitignore b/packages/parser/.gitignore new file mode 100644 index 000000000..53c37a166 --- /dev/null +++ b/packages/parser/.gitignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/packages/parser/LICENSE b/packages/parser/LICENSE new file mode 100644 index 000000000..ac805acbb --- /dev/null +++ b/packages/parser/LICENSE @@ -0,0 +1,7 @@ +Copyright © 2020 Evan Welsh + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/parser/package.json b/packages/parser/package.json new file mode 100644 index 000000000..67dd99991 --- /dev/null +++ b/packages/parser/package.json @@ -0,0 +1,37 @@ +{ + "name": "@gi.ts/parser", + "version": "2.0.0", + "type": "module", + "main": "dist/lib.js", + "types": "dist/lib.d.ts", + "files": [ + "dist", + "package.json", + "package-lock.json", + "README.md" + ], + "exports": { + ".": { + "types": "./dist/lib.d.ts", + "import": "./dist/lib.js" + } + }, + "engines": { + "node": ">=12.0.0" + }, + "publishConfig": { + "access": "public" + }, + "license": "MIT", + "scripts": { + "build": "tsc", + "prepack": "rm -rf dist && yarn build" + }, + "dependencies": { + "fast-xml-parser": "^3.17.5" + }, + "devDependencies": { + "@types/xml2js": "^0.4.4", + "typescript": "5.1.3" + } +} diff --git a/packages/parser/src/lib.ts b/packages/parser/src/lib.ts new file mode 100644 index 000000000..69b6fb48d --- /dev/null +++ b/packages/parser/src/lib.ts @@ -0,0 +1,3 @@ +export * as parser from "./parser.js"; + +export * from "./xml.js"; \ No newline at end of file diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts new file mode 100644 index 000000000..bd9154995 --- /dev/null +++ b/packages/parser/src/parser.ts @@ -0,0 +1,17 @@ +import { parse } from "fast-xml-parser"; +import { GirXML } from "./xml.js"; + +export function parseGir(contents: string): GirXML { + return parse(contents, { + attributeNamePrefix: "", + attrNodeName: "$", // default is 'false', + textNodeName: "_", + ignoreAttributes : false, + ignoreNameSpace : false, + allowBooleanAttributes : true, + parseNodeValue : true, + parseAttributeValue : false, + trimValues: true, + arrayMode: true + }) as GirXML; +} \ No newline at end of file diff --git a/packages/parser/src/xml.ts b/packages/parser/src/xml.ts new file mode 100644 index 000000000..6c3d9abf7 --- /dev/null +++ b/packages/parser/src/xml.ts @@ -0,0 +1,710 @@ +// Written based on https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/0c414e34113fca089a67eb1beadfcdce722a89db/docs/gir-1.2.rnc + +// Most grammar has been modified to *prefer* potentially being undefined +// as we're parsing from XML files which may or may not contain all parts +// of this grammar + +// Many keys are prefixed with `glib:` in XML, this grammar preserves that syntax. + +export enum Direction { + In = "in", + Inout = "inout", + Out = "out", +} + +export interface GirXML { + repository: Repository[]; +} + +/** A type alias for fields which *should* be treated as numerical */ +type UnparsedNumber = string; + +/** A type alias for 'binary' (boolean) fields */ +type BinaryOption = "0" | "1"; + +/** Root node of a GIR repository. It contains namespaces, which can in turn be implemented in several libraries */ +export interface Repository { + $: { + /** version number of the repository */ + version?: string; + /** prefixes to filter out from C identifiers for data structures and types. For example, GtkWindow will be Window. If c:symbol-prefixes is not used, then this element is used for both */ + "c:identifier-prefixes"?: string; + /** prefixes to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefixes"?: string; + }; + + /* Other elements a repository can contain */ + include: Include[]; + "c:include": CInclude[]; + package: Package[]; + namespace: Namespace[]; +} + +/** Namespace which maps metadata entries to C functionality. This a similar concept to namespace in C++, but for GObject-based C libraries */ +export interface Namespace { + $: InfoAttrs & { + /** name of the namespace. For example, 'Gtk' (technically optional) */ + name: string; + /** version number of the namespace (technically optional) */ + version: string; + /** prefixes to filter out from C identifiers for data structures and types. For example, GtkWindow will be Window. If c:symbol-prefixes is not used, then this element is used for both */ + "c:identifier-prefixes"?: string; + /** prefixes to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefixes"?: string; + /** Deprecated: the same as c:identifier-prefixes. Only used for backward compatibility */ + "c:prefix"?: string; + /** Path to the shared library implementing the namespace. It can be a comma-separated list, with relative path only */ + "shared-library"?: string; + }; + + /* Other elements a namespace can contain */ + alias?: AliasElement[]; + class?: ClassElement[]; + interface?: InterfaceElement[]; + record?: RecordElement[]; + enumeration?: EnumElement[]; + function?: FunctionElement[]; + union?: UnionElement[]; + bitfield?: BitfieldElement[]; + callback?: CallbackElement[]; + constant?: ConstantElement[]; + annotation?: Annotation[]; + ["glib:boxed"]?: BoxedElement[]; +} + +export interface Annotation { + /** element defining an annotation from the source code, usually a user-defined annotation associated to a parameter or a return value */ + $: { + /** name of the attribute */ + name: string; + /** value of the attribute */ + value: string[]; + }; +} + +export interface CInclude { + /** Dependant C header file which should be included in C programs */ + $: { + /** File name of the C header file. The path can be relative. */ + name: string; + }; +} + +export interface Include { + /** Dependant namespace to include with the current namespace. For example, Gtk will need the namespace GLib */ + $: { + /** name of the dependant namespace to include */ + name: string; + /** version of the dependant namespace to use */ + version?: string; + }; +} + +export interface Package { + /** Deprecated: package name containing the library */ + $: { + /** name of the package */ + name: string; + }; +} + +export interface AliasElement extends InfoElements { + /** Type's name substitution, representing a typedef in C */ + $: InfoAttrs & { + //Attributes of an Alias (see definition below) + + /** the new name or typedef'd name */ + name: string; + /** the corresponding C type's name */ + "c:type": string; + }; + + /** Other elements an alias can contain */ + type: Type[]; +} + +export interface InterfaceElement extends InfoElements { + /** Abstract interface to other classes */ + $: { + //Attributes of an Interface (see definition below) + + /** name of the interface */ + name: string; + /** Type name compatible with the GObject type system */ + "glib:type-name": string; + /** Function to get the GObject compatible type of the interface */ + "glib:get-type": string; + /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefix"?: string; + /** Corresponding C type */ + "c:type"?: string; + /** GObject compatible C structure defining the Interface */ + "glib:type-struct"?: string; + }; + + //Other elements an interface can contain + + prerequisite?: Prerequisite[]; + implements?: Implements[]; + function?: FunctionElement[]; + constructors?: ConstructorElement[]; // Typed as optional + method?: MethodElement[]; + "virtual-method"?: VirtualMethodElement[]; + field?: FieldElement[]; + property?: PropertyElement[]; + signal?: SignalElement[]; + callback?: CallbackElement[]; + constant?: ConstantElement[]; +} + +export interface ClassElement extends InfoElements { + /** GObject inherited class definition */ + $: InfoAttrs & { + /** Name of the class */ + name: string; + /** GObject compatible type name of the class */ + "glib:type-name": string; + /** Function to get the GObject compatible type of the class */ + "glib:get-type": string; + /** Name of the parent class if any */ + parent?: string; + /** GObject compatible C structure defining the class */ + "glib:type-struct"?: string; + /** GObject compatible function to reference or increase the reference count of the class */ + "glib:ref-func"?: string; + /** GObject compatible function to unreference or decrease the reference count of the class */ + "glib:unref-func"?: string; + /** GObject compatible function to set a value of a property of the class */ + "glib:set-value-func"?: string; + /** GObject compatible function to get a value of a property of the class */ + "glib:get-value-func"?: string; + /** C type of the class */ + "c:type"?: string; + /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefix"?: string; + /** Binary attribute to declare the class abstract or not */ + abstract?: BinaryOption | BinaryOption; + /** Binary attribute to declare the class fundamental or not (top-level class which do not derives from any other type) */ + "glib:fundamental"?: BinaryOption | BinaryOption; + }; + + /* Other elements a class can contain */ + + implements?: Implements[]; + "constructor"?: ConstructorElement[]; + method?: MethodElement[]; + function?: FunctionElement[]; + "virtual-method"?: VirtualMethodElement[]; + field?: FieldElement[]; + property?: PropertyElement[]; + signal?: SignalElement[]; + union?: UnionElement[]; + constant?: ConstantElement[]; + record?: RecordElement[]; + callback?: CallbackElement[]; +} + +export interface BoxedElement { + /** Boxed type (wrapper to opaque C structures registered by the type system) */ + $: InfoAttrs & { + /** GObject compatible type name of the boxed type */ + "glib:name": string; + /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefix"?: string; + /** GObject compatible type name of the boxed type */ + "glib:type-name"?: string; + /** Function to get the GObject compatible type of the boxed type */ + "glib:get-type"?: string; + }; + + /* Other elements a Boxed type can contain */ + + function?: FunctionElement[]; +} + +export interface RecordElement extends InfoElements { + /** Record definition, equivalent to a C struct, that is a simple structure, not a class */ + $: InfoAttrs & { + /** name of the record */ + name: string; + /** Corresponding C type of the record */ + "c:type"?: string; + /** Binary attribute to tell if the record is disguised, i.e. whether the c:type is a typedef that doesn't look like a pointer, but is one internally */ + /** Its second meaning is "private" and is set when any typedef struct is parsed which doesn't also include a full struct with fields (https://gitlab.gnome.org/GNOME/gobject-introspection/issues/101) */ + disguised?: BinaryOption | BinaryOption; + /** GObject compatible C type of the record */ + "glib:type-name"?: string; + /** Function to get the GObject compatible type of the record */ + "glib:get-type"?: string; + /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefix"?: string; + /** Binary attribute to tell if the record is foreign, that is it is not available in a g-i supported library */ + foreign?: BinaryOption | BinaryOption; + /** Name of the GObject compatible gtype this record represents. If }, this record will be hidden from generated public APIs. */ + "glib:is-gtype-struct-for"?: string; + }; + + /* Other elements a record can contain */ + + field?: FieldElement[]; + function?: FunctionElement[]; + union?: UnionElement[]; + method?: MethodElement[]; + "constructor"?: ConstructorElement[]; + property?: PropertyElement[]; +} + +//Some base information for most elements like version, deprecation, stability, if they are introspectable or not, etc... +export interface InfoAttrs { + /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: BinaryOption | BinaryOption; + /** Binary attribute which isBinaryOption (true) if the element has been deprecated */ + deprecated?: string; + /** Version number from which this element is deprecated */ + "deprecated-version"?: string; + /** version number of an element */ + version?: string; + /** give the statibility status of the element. Can take the values "Stable", "Unstable" or "Private" */ + stability?: string[]; +} + +//Documentation of elements +export interface DocElement { + /** Version of the documentation */ + "doc-version"?: [ + { + $: { + /** Preserve the original formatting of the documentation from the source code */ + "xml:space"?: "preserve"; + /** Preserve the original formatting of the documentation from the source code. Recommended to use this instead of xml:space */ + "xml:whitespace"?: "preserve"; + }; + /** the text of the version of the documentation */ + _: string; + } + ]; + /** give the stability of the documentation */ + "doc-stability"?: [ + { + $: { + /** Preserve the original formatting of the documentation from the source code */ + "xml:space"?: "preserve"; + /** Preserve the original formatting of the documentation from the source code. Recommended to use this instead of xml:space */ + "xml:whitespace"?: "preserve"; + /** a text value about the stability of the documentation. Usually a simple description like stable or unstable */ + }; + _: string; + } + ]; + /** documentation of an element */ + doc: [ + { + $: { + /** Preserve the original formatting of the documentation from the source code */ + "xml:space"?: "preserve"; + /** Keep the whitespace as they were in the source code */ + "xml:whitespace"?: "preserve"; + /** The file containing this documentation */ + filename: string; + /** The first line of the documentation in the source code */ + line: string; + /** The first column of the documentation in the source code */ + column: string; + /** the text of the documentation */ + }; + _: string; + } + ]; + /** Deprecated documentation of an element. Kept for historical reasons in general */ + "doc-deprecated": [ + { + $: { + /** Preserve the original formatting of the documentation from the source code */ + "xml:space"?: "preserve"; + /** Keep the whitespace as they were in the source code */ + "xml:whitespace"?: "preserve"; + /** the text of the deprecated documentation */ + }; + _: string; + } + ]; + /** Position of the documentation in the original source code */ + "source-position": [ + { + /** File name of the source of the documentation */ + filename: string; + /** The first line of the documentation in the source code */ + line: string; + /** The first column of the documentation in the source code */ + column: string[]; + } + ]; +} + +//Information about elements can be a documentation of annotations +export interface InfoElements extends DocElement { + annotation: Annotation[]; +} + +export interface ConstantElement extends InfoElements, AnyType { + /** A constant entity, similar to const variable in C */ + $: InfoAttrs & { + /** name of the constant */ + name: string; + /** value of the constant */ + value: string; + /** corresponding C type of the constant in C */ + "c:type"?: string; + /** corresponding C identifier in the source code */ + "c:identifier"?: string; + }; +} + +export interface PropertyElement extends InfoElements, AnyType { + /** Property, that is a variable or members with getter and setter functions */ + $: InfoAttrs & { + /** name of the property */ + name: string; + /** Binary attribute, true if the property is writeable, that is it has a setter function */ + writable?: BinaryOption | BinaryOption; + /** Binary attribute, true if the property is readable, that is it has a getter function */ + readable?: BinaryOption | BinaryOption; + /** Binary attribute, true if the property will be set upon construction */ + construct?: BinaryOption | BinaryOption; + /** Binary attribute, true if the property can only be set upon construction */ + "construct-only"?: BinaryOption | BinaryOption; + //Define the transfer of ownership of the property element + TransferOwnership?; + }; +} + +export interface SignalElement extends InfoElements { + /** A signal as defined in the GObject system (https://developer.gnome.org/gobject/stable/signal.html) */ + $: InfoAttrs & { + /** name of the signal */ + name: string; + /** Binary attribute, true if the signal has a detailed parameter (https://developer.gnome.org/gobject/stable/signal.html#signal-detail//and https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ + detailed?: BinaryOption | BinaryOption; + /** When to run the signal during the 5 steps of signal emission (https://developer.gnome.org/gobject/stable/signal.html#signal-emission and https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ + when?: "first" | "last" | "cleanup"; + /** Binary attribute, true if the signal can be freely emitted on alive objects from user code (https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ + action?: BinaryOption | BinaryOption; + /** Binary attribute, true if no emission hooks are supported for this signal (https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ + "no-hooks"?: BinaryOption | BinaryOption; + /** Binary attribute, true if signals emitted for an object while currently being in emission for this very object will not be emitted recursively, but instead cause the first emission to be restarted (https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ + "no-recurse"?: BinaryOption | BinaryOption; + }; + + /* Other elements a property can contain */ + + parameters?: [CallableParams]; + "return-value"?: CallableReturn[]; +} + +export interface FieldElement extends InfoElements, AnyType { + /** A field of struct of union structure, that is a C bit field, that is a fixed length in bits variable */ + $: InfoAttrs & { + /** name of the field */ + name: string; + /** Binary attribute, true if the field is writeable */ + writable?: BinaryOption | BinaryOption; + /** Binary attribute, true if the field is readable */ + readable?: BinaryOption | BinaryOption; + /** Binary attribute, true if the field is private to the structure or has public ("0") visibility */ + private?: BinaryOption | BinaryOption; + /** number of bits of the field */ + bits?: UnparsedNumber /** integer */; + }; + + /* Other elements a property can contain */ + callback?: CallbackElement[]; +} + +export interface CallbackElement extends InfoElements { + /** A callback closure, that is a function called when a signal is emitted (as an answer to that signal) */ + $: InfoAttrs & { + /** name of the callback */ + name: string; + /** the C type returned by the callback closure (i.e. function) */ + "c:type"?: string; + /** Binary attribute, true if the callback can throw an error */ + throws?: BinaryOption | BinaryOption; + }; + + /* Other elements a property can contain */ + + parameters?: [CallableParams]; + "return-value"?: CallableReturn[]; +} + +export interface Implements { + /** Give the name of the interface it implements. This element is generally used within a class element */ + $: InfoAttrs & { + /** name of the interface implemented by a class */ + name: string; + }; +} + +export interface Prerequisite { + /** Interface which is pre-required to implement another interface. This node is generally using within an interface element */ + $: InfoAttrs & { + /** name of the required interface */ + name: string; + }; +} + +//A generic grammar element to represent either a simple Type or an Array of the same Type +export interface AnyType { + type?: Type[]; + array?: ArrayType[]; +} + +export interface Type extends DocElement { + /** A simple type of data (as opposed to an array) */ + $: InfoAttrs & { + /** name of the type */ + name?: string; + /** the C representation of the type */ + "c:type"?: string; + /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: BinaryOption | BinaryOption; + }; + + array?: ArrayType[]; + type: Type[]; +} + +export interface ArrayType { + /** An array type of data where each element is of the same type */ + $: InfoAttrs & { + /** name of the array type */ + name?: string; + /** Binary attribute, true if the last element of the array is zero. For example, in an array of pointers, the last pointer would be NULL */ + "zero-terminated"?: BinaryOption | BinaryOption; + /** size of an array of predetermined fixed size. For example a C array declared as char arr[5]. */ + "fixed-size"?: UnparsedNumber /** integer */; + /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: BinaryOption | BinaryOption; + /** 0-based index of parameter element that specifies the length of the array */ + length?: UnparsedNumber /** integer */; + /** the C representation of the array type */ + "c:type"?: string; + }; + + array?: ArrayType[]; + type?: Type[]; +} + +export enum TransferOwnershipType { + Container = "container", + Full = "full", + None = "none", +} + +export interface TransferOwnership { + /** attributes used by many elements for the transfer of ownership, with for example, a returned value. "none" if the recipient does not own the value, "container" if the recipient owns the container but not the value (for arrays or lists for example) , "full" the recipient owns the entire value. For details, see https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Memory_and_lifecycle_management */ + "transfer-ownership": TransferOwnershipType; +} + +export interface ConstructorElement { + /** A constructor of a class */ + $: InfoAttrs & CallableAttrs; + + parameters?: [CallableParams]; + "return-value"?: CallableReturn[]; +} + +/** Attributes of a Callable (functions, callbacks, closures, etc...) */ +export interface CallableAttrs { + /** name of the Callable */ + name: string; + //C identifier in the source code of the Callable + "c:identifier"?: string; + /** Callable it is shadowed by. For example, in C++, only one version of an overloaded callable will appear */ + "shadowed-by"?: string; + /** Callable it shadows. For example, in C++, only one version of an overloaded callable will appear */ + shadows?: string; + /** Binary attribute, true if the callable can throw an error */ + throws?: BinaryOption | BinaryOption; + /** if for backward compatibility reason the callable has a name in the source code but should be known by another one, this attribute contains the new name */ + "moved-to"?: string[]; +} + +export interface VarArgs { + /** an element, usually found in a parameter element for variadic parameter in a function or callable */ + $: InfoAttrs; +} + +export interface CallableParamElement extends DocElement, AnyType { + /** parameter element of a list of parameters */ + $: InfoAttrs & + Partial & { + /** name of the parameter */ + name?: string; + /** Binary attribute, true if the parameter can have a null value */ + nullable?: BinaryOption | BinaryOption; + /** Deprecated. Replaced by nullable and optional */ + "allow-none"?: BinaryOption | BinaryOption; + /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: BinaryOption | BinaryOption; + /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ + closure?: UnparsedNumber /** integer */; + /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ + destroy?: UnparsedNumber /** integer */; + /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocationi (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ + scope?: "notified" | "async" | "call"; + /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ + direction?: Direction; + /** Binary attribute, true if the caller should allocate the parameter before calling the callable */ + "caller-allocates"?: BinaryOption | BinaryOption; + /** Binary attribute, true if the parameter is optional */ + optional?: BinaryOption | BinaryOption; + /** Binary attribute, true if the parameter can be omitted from the introspected output */ + skip?: BinaryOption | BinaryOption; + }; + + varargs?: VarArgs[]; +} + +// Refer to https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Support_for_GObject_closures +export interface CallableParams { + /** parameters element of a callable, that is in general parameters of a function or similar */ + parameter: CallableParamElement[]; + /** instance-parameter is a parameter of a C function which is an instance of an existing object. So the callable is surely a method of a class, and this parameter points to the instance of the object. In C++, this would be equivalent to the pointer this which is not passed to the method, in Python it's equivalent to self. */ + "instance-parameter"?: AnyType & + { + $: Partial<{ + /** name of the instance-parameter */ name: string; + /** Binary attribute, true if the parameter can have a null value */ + nullable?: BinaryOption | BinaryOption; + /** Deprecated. Replaced by nullable and optional */ + "allow-none"?: BinaryOption | BinaryOption; + /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ + direction?: Direction; + /** Binary attribute, true if the caller should allocate the parameter before calling the callable */ + "caller-allocates"?: BinaryOption | BinaryOption; + }> & + Partial; + }[]; +} + +export interface CallableReturn extends AnyType, DocElement { + /** return value of a callable */ + $: { + /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: BinaryOption | BinaryOption; + /** Binary attribute, true if the parameter can have a null value */ + nullable?: BinaryOption | BinaryOption; + /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ + closure?: UnparsedNumber /** integer */; + /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocationi (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ + scope?: "notified" | "async" | "call"; + /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ + destroy?: UnparsedNumber /** integer */; + /** Binary attribute, true if the parameter can be omitted from the introspected output */ + skip?: BinaryOption | BinaryOption; + /** Deprecated. Replaced by nullable and optional */ + "allow-none"?: BinaryOption | BinaryOption; + } & Partial; +} + +export interface FunctionElement extends DocElement { + /** element defining a standalone function (as usual in most programming languages) */ + $: InfoAttrs & CallableAttrs; + + parameters?: [CallableParams]; + "return-value"?: CallableReturn[]; +} + +export interface MethodElement extends DocElement { + /** element defining a method from a class */ + $: InfoAttrs & CallableAttrs; + + parameters?: [CallableParams]; + "return-value"?: CallableReturn[]; +} + +export interface VirtualMethodElement extends DocElement { + /** element defining a virtual method from a class, concept similar to C++ */ + + $: InfoAttrs & + CallableAttrs & { + /** name of the callable called when invoking this virtual method */ + invoker?: string; + }; + + parameters?: [CallableParams]; + "return-value"?: CallableReturn[]; +} + +export interface UnionElement extends InfoElements { + /** element defining a type of data being a union of type, similar to union in C/C++ but extended with fields and methods */ + $: InfoAttrs & { + /** name of the union */ + name?: string; + /** C type defining the union */ + "c:type"?: string; + /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ + "c:symbol-prefix"?: string; + /** GObject compatible type name */ + "glib:type-name"?: string; + /** function to retrieve the GObject compatible type of the element */ + "glib:get-type"?: string; + }; + + field?: FieldElement[]; + "constructor"?: ConstructorElement[]; + method?: MethodElement[]; + function?: FunctionElement[]; + record?: RecordElement[]; +} + +export interface BitfieldElement extends InfoElements { + /** element defining a bit field (as in C) */ + $: InfoAttrs & { + /** name of the bit field */ + name: string; + /** corresponding C type of the bit field type */ + "c:type": string; + /** GObject compatible type name */ + "glib:type-name"?: string; + /** function to retrieve the GObject compatible type of the element */ + "glib:get-type"?: string; + }; + + member: MemberElement[]; + function: FunctionElement[]; +} + +export interface EnumElement extends InfoElements { + /** element defining a enumeration type similar to enum in C/C++ */ + $: InfoAttrs & { + /** name of the enumeration */ + name: string; + /** corresponding C type of the enumeration type */ + "c:type": string; + /** GObject compatible type name */ + "glib:type-name"?: string; + /** function to retrieve the GObject compatible type of the element */ + "glib:get-type"?: string; + /** Error domain of this enumeration in a stringified form */ + "glib:error-domain"?: string; + }; + + member?: MemberElement[]; + function?: FunctionElement[]; +} + +export interface MemberElement extends InfoElements { + /** element defining a member of a bit field or an enumeration */ + $: InfoAttrs & { + /** name of the member */ + name: string; + /** value of the member */ + value: string; + /** corresponding C type of the member */ + "c:identifier": string; + /** short nickname of the member */ + "glib:nick"?: string; + }; +} diff --git a/packages/parser/tsconfig.json b/packages/parser/tsconfig.json new file mode 100644 index 000000000..ccedbfe42 --- /dev/null +++ b/packages/parser/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "ES2017", + "module": "ES2020", + "moduleResolution": "node", + "rootDir": "src", + "outDir": "dist", + "resolveJsonModule": true, + "noImplicitThis": true, + "noImplicitReturns": true, + "strictBindCallApply": true, + "removeComments": true, + "strictNullChecks": true, + "declaration": true, + "strictPropertyInitialization": true, + "esModuleInterop": true, + "lib": [ + "ES2019" + ] + }, + "include": [ + "src/**/*" + ] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b18fada04..aae3f14bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -706,15271 +706,13 @@ __metadata: languageName: node linkType: hard -"@girs/accounts-1.0@workspace:types/accounts-1.0": +"@gi.ts/parser@workspace:packages/parser": version: 0.0.0-use.local - resolution: "@girs/accounts-1.0@workspace:types/accounts-1.0" + resolution: "@gi.ts/parser@workspace:packages/parser" dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/accountsservice-1.0@workspace:types/accountsservice-1.0": - version: 0.0.0-use.local - resolution: "@girs/accountsservice-1.0@workspace:types/accountsservice-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/adw-1@workspace:types/adw-1": - version: 0.0.0-use.local - resolution: "@girs/adw-1@workspace:types/adw-1" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/amtk-4@workspace:types/amtk-4": - version: 0.0.0-use.local - resolution: "@girs/amtk-4@workspace:types/amtk-4" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/amtk-5@workspace:^, @girs/amtk-5@workspace:types/amtk-5": - version: 0.0.0-use.local - resolution: "@girs/amtk-5@workspace:types/amtk-5" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/anjuta-3.0@workspace:^, @girs/anjuta-3.0@workspace:types/anjuta-3.0": - version: 0.0.0-use.local - resolution: "@girs/anjuta-3.0@workspace:types/anjuta-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gdl-3": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/anthy-9000@workspace:types/anthy-9000": - version: 0.0.0-use.local - resolution: "@girs/anthy-9000@workspace:types/anthy-9000" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/appindicator3-0.1@workspace:types/appindicator3-0.1": - version: 0.0.0-use.local - resolution: "@girs/appindicator3-0.1@workspace:types/appindicator3-0.1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/appstream-1.0@workspace:types/appstream-1.0": - version: 0.0.0-use.local - resolution: "@girs/appstream-1.0@workspace:types/appstream-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/appstreambuilder-1.0@workspace:types/appstreambuilder-1.0": - version: 0.0.0-use.local - resolution: "@girs/appstreambuilder-1.0@workspace:types/appstreambuilder-1.0" - dependencies: - "@girs/appstreamglib-1.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/appstreamglib-1.0@workspace:^, @girs/appstreamglib-1.0@workspace:types/appstreamglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/appstreamglib-1.0@workspace:types/appstreamglib-1.0" - dependencies: - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/arrow-1.0@workspace:^, @girs/arrow-1.0@workspace:types/arrow-1.0": - version: 0.0.0-use.local - resolution: "@girs/arrow-1.0@workspace:types/arrow-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/arrowcuda-1.0@workspace:^, @girs/arrowcuda-1.0@workspace:types/arrowcuda-1.0": - version: 0.0.0-use.local - resolution: "@girs/arrowcuda-1.0@workspace:types/arrowcuda-1.0" - dependencies: - "@girs/arrow-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/arrowdataset-1.0@workspace:types/arrowdataset-1.0": - version: 0.0.0-use.local - resolution: "@girs/arrowdataset-1.0@workspace:types/arrowdataset-1.0" - dependencies: - "@girs/arrow-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/arrowflight-1.0@workspace:types/arrowflight-1.0": - version: 0.0.0-use.local - resolution: "@girs/arrowflight-1.0@workspace:types/arrowflight-1.0" - dependencies: - "@girs/arrow-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/atk-1.0@workspace:^, @girs/atk-1.0@workspace:types/atk-1.0": - version: 0.0.0-use.local - resolution: "@girs/atk-1.0@workspace:types/atk-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/atspi-2.0@workspace:types/atspi-2.0": - version: 0.0.0-use.local - resolution: "@girs/atspi-2.0@workspace:types/atspi-2.0" - dependencies: - "@girs/dbus-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/babl-0.1@workspace:^, @girs/babl-0.1@workspace:types/babl-0.1": - version: 0.0.0-use.local - resolution: "@girs/babl-0.1@workspace:types/babl-0.1" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/bamf-3@workspace:types/bamf-3": - version: 0.0.0-use.local - resolution: "@girs/bamf-3@workspace:types/bamf-3" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/builder-1.0@workspace:types/builder-1.0": - version: 0.0.0-use.local - resolution: "@girs/builder-1.0@workspace:types/builder-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/dazzle-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/girepository-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/ide-1.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/peas-1.0": "workspace:^" - "@girs/template-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/bump-0.1@workspace:types/bump-0.1": - version: 0.0.0-use.local - resolution: "@girs/bump-0.1@workspace:types/bump-0.1" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cairo-1.0@workspace:^, @girs/cairo-1.0@workspace:types/cairo-1.0": - version: 0.0.0-use.local - resolution: "@girs/cairo-1.0@workspace:types/cairo-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cally-1.0@workspace:types/cally-1.0": - version: 0.0.0-use.local - resolution: "@girs/cally-1.0@workspace:types/cally-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cally-10@workspace:types/cally-10": - version: 0.0.0-use.local - resolution: "@girs/cally-10@workspace:types/cally-10" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-10": "workspace:^" - "@girs/cogl-10": "workspace:^" - "@girs/coglpango-10": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cally-11@workspace:^, @girs/cally-11@workspace:types/cally-11": - version: 0.0.0-use.local - resolution: "@girs/cally-11@workspace:types/cally-11" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-11": "workspace:^" - "@girs/cogl-11": "workspace:^" - "@girs/coglpango-11": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cally-12@workspace:^, @girs/cally-12@workspace:types/cally-12": - version: 0.0.0-use.local - resolution: "@girs/cally-12@workspace:types/cally-12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-12": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/coglpango-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cally-13@workspace:^, @girs/cally-13@workspace:types/cally-13": - version: 0.0.0-use.local - resolution: "@girs/cally-13@workspace:types/cally-13" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-13": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/coglpango-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/mtk-13": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/camel-1.2@workspace:^, @girs/camel-1.2@workspace:types/camel-1.2": - version: 0.0.0-use.local - resolution: "@girs/camel-1.2@workspace:types/camel-1.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/caribou-1.0@workspace:types/caribou-1.0": - version: 0.0.0-use.local - resolution: "@girs/caribou-1.0@workspace:types/caribou-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/champlain-0.12@workspace:^, @girs/champlain-0.12@workspace:types/champlain-0.12": - version: 0.0.0-use.local - resolution: "@girs/champlain-0.12@workspace:types/champlain-0.12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cheese-3.0@workspace:types/cheese-3.0": - version: 0.0.0-use.local - resolution: "@girs/cheese-3.0@workspace:types/cheese-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cloudproviders-0.3@workspace:types/cloudproviders-0.3": - version: 0.0.0-use.local - resolution: "@girs/cloudproviders-0.3@workspace:types/cloudproviders-0.3" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/clutter-1.0@workspace:^, @girs/clutter-1.0@workspace:types/clutter-1.0": - version: 0.0.0-use.local - resolution: "@girs/clutter-1.0@workspace:types/clutter-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/clutter-10@workspace:^, @girs/clutter-10@workspace:types/clutter-10": - version: 0.0.0-use.local - resolution: "@girs/clutter-10@workspace:types/clutter-10" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-10": "workspace:^" - "@girs/coglpango-10": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/clutter-11@workspace:^, @girs/clutter-11@workspace:types/clutter-11": - version: 0.0.0-use.local - resolution: "@girs/clutter-11@workspace:types/clutter-11" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-11": "workspace:^" - "@girs/coglpango-11": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/clutter-12@workspace:^, @girs/clutter-12@workspace:types/clutter-12": - version: 0.0.0-use.local - resolution: "@girs/clutter-12@workspace:types/clutter-12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/coglpango-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/clutter-13@workspace:^, @girs/clutter-13@workspace:types/clutter-13": - version: 0.0.0-use.local - resolution: "@girs/clutter-13@workspace:types/clutter-13" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/coglpango-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/mtk-13": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cluttergdk-1.0@workspace:types/cluttergdk-1.0": - version: 0.0.0-use.local - resolution: "@girs/cluttergdk-1.0@workspace:types/cluttergdk-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cluttergst-1.0@workspace:types/cluttergst-1.0": - version: 0.0.0-use.local - resolution: "@girs/cluttergst-1.0@workspace:types/cluttergst-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/gstaudio-0.10": "workspace:^" - "@girs/gstbase-0.10": "workspace:^" - "@girs/gstinterfaces-0.10": "workspace:^" - "@girs/gstvideo-0.10": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cluttergst-2.0@workspace:types/cluttergst-2.0": - version: 0.0.0-use.local - resolution: "@girs/cluttergst-2.0@workspace:types/cluttergst-2.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cluttergst-3.0@workspace:types/cluttergst-3.0": - version: 0.0.0-use.local - resolution: "@girs/cluttergst-3.0@workspace:types/cluttergst-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/clutterx11-1.0@workspace:types/clutterx11-1.0": - version: 0.0.0-use.local - resolution: "@girs/clutterx11-1.0@workspace:types/clutterx11-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cogl-1.0@workspace:^, @girs/cogl-1.0@workspace:types/cogl-1.0": - version: 0.0.0-use.local - resolution: "@girs/cogl-1.0@workspace:types/cogl-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cogl-10@workspace:^, @girs/cogl-10@workspace:types/cogl-10": - version: 0.0.0-use.local - resolution: "@girs/cogl-10@workspace:types/cogl-10" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cogl-11@workspace:^, @girs/cogl-11@workspace:types/cogl-11": - version: 0.0.0-use.local - resolution: "@girs/cogl-11@workspace:types/cogl-11" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cogl-12@workspace:^, @girs/cogl-12@workspace:types/cogl-12": - version: 0.0.0-use.local - resolution: "@girs/cogl-12@workspace:types/cogl-12" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cogl-13@workspace:^, @girs/cogl-13@workspace:types/cogl-13": - version: 0.0.0-use.local - resolution: "@girs/cogl-13@workspace:types/cogl-13" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/cogl-2.0@workspace:^, @girs/cogl-2.0@workspace:types/cogl-2.0": - version: 0.0.0-use.local - resolution: "@girs/cogl-2.0@workspace:types/cogl-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglgst-2.0@workspace:types/coglgst-2.0": - version: 0.0.0-use.local - resolution: "@girs/coglgst-2.0@workspace:types/coglgst-2.0" - dependencies: - "@girs/cogl-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglpango-1.0@workspace:^, @girs/coglpango-1.0@workspace:types/coglpango-1.0": - version: 0.0.0-use.local - resolution: "@girs/coglpango-1.0@workspace:types/coglpango-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglpango-10@workspace:^, @girs/coglpango-10@workspace:types/coglpango-10": - version: 0.0.0-use.local - resolution: "@girs/coglpango-10@workspace:types/coglpango-10" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-10": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglpango-11@workspace:^, @girs/coglpango-11@workspace:types/coglpango-11": - version: 0.0.0-use.local - resolution: "@girs/coglpango-11@workspace:types/coglpango-11" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-11": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglpango-12@workspace:^, @girs/coglpango-12@workspace:types/coglpango-12": - version: 0.0.0-use.local - resolution: "@girs/coglpango-12@workspace:types/coglpango-12" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglpango-13@workspace:^, @girs/coglpango-13@workspace:types/coglpango-13": - version: 0.0.0-use.local - resolution: "@girs/coglpango-13@workspace:types/coglpango-13" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/coglpango-2.0@workspace:types/coglpango-2.0": - version: 0.0.0-use.local - resolution: "@girs/coglpango-2.0@workspace:types/coglpango-2.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/cogl-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/colord-1.0@workspace:^, @girs/colord-1.0@workspace:types/colord-1.0": - version: 0.0.0-use.local - resolution: "@girs/colord-1.0@workspace:types/colord-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/colordgtk-1.0@workspace:types/colordgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/colordgtk-1.0@workspace:types/colordgtk-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/colord-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/colorhug-1.0@workspace:types/colorhug-1.0": - version: 0.0.0-use.local - resolution: "@girs/colorhug-1.0@workspace:types/colorhug-1.0" - dependencies: - "@girs/colord-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gusb-1.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dazzle-1.0@workspace:^, @girs/dazzle-1.0@workspace:types/dazzle-1.0": - version: 0.0.0-use.local - resolution: "@girs/dazzle-1.0@workspace:types/dazzle-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dbus-1.0@workspace:^, @girs/dbus-1.0@workspace:types/dbus-1.0": - version: 0.0.0-use.local - resolution: "@girs/dbus-1.0@workspace:types/dbus-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dbusglib-1.0@workspace:^, @girs/dbusglib-1.0@workspace:types/dbusglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/dbusglib-1.0@workspace:types/dbusglib-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dbusmenu-0.4@workspace:^, @girs/dbusmenu-0.4@workspace:types/dbusmenu-0.4": - version: 0.0.0-use.local - resolution: "@girs/dbusmenu-0.4@workspace:types/dbusmenu-0.4" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dbusmenugtk-0.4@workspace:types/dbusmenugtk-0.4": - version: 0.0.0-use.local - resolution: "@girs/dbusmenugtk-0.4@workspace:types/dbusmenugtk-0.4" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/dbusmenu-0.4": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dbusmenugtk3-0.4@workspace:types/dbusmenugtk3-0.4": - version: 0.0.0-use.local - resolution: "@girs/dbusmenugtk3-0.4@workspace:types/dbusmenugtk3-0.4" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/dbusmenu-0.4": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dee-1.0@workspace:^, @girs/dee-1.0@workspace:types/dee-1.0": - version: 0.0.0-use.local - resolution: "@girs/dee-1.0@workspace:types/dee-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/devhelp-3.0@workspace:types/devhelp-3.0": - version: 0.0.0-use.local - resolution: "@girs/devhelp-3.0@workspace:types/devhelp-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-4.1": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - "@girs/webkit2-4.1": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dex-1@workspace:types/dex-1": - version: 0.0.0-use.local - resolution: "@girs/dex-1@workspace:types/dex-1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/dmap-3.0@workspace:types/dmap-3.0": - version: 0.0.0-use.local - resolution: "@girs/dmap-3.0@workspace:types/dmap-3.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ebackend-1.2@workspace:^, @girs/ebackend-1.2@workspace:types/ebackend-1.2": - version: 0.0.0-use.local - resolution: "@girs/ebackend-1.2@workspace:types/ebackend-1.2" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ebook-1.2@workspace:types/ebook-1.2": - version: 0.0.0-use.local - resolution: "@girs/ebook-1.2@workspace:types/ebook-1.2" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/ebookcontacts-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ebookcontacts-1.2@workspace:^, @girs/ebookcontacts-1.2@workspace:types/ebookcontacts-1.2": - version: 0.0.0-use.local - resolution: "@girs/ebookcontacts-1.2@workspace:types/ebookcontacts-1.2" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ecal-2.0@workspace:^, @girs/ecal-2.0@workspace:types/ecal-2.0": - version: 0.0.0-use.local - resolution: "@girs/ecal-2.0@workspace:types/ecal-2.0" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/icalglib-3.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ecalendar-1.2@workspace:types/ecalendar-1.2": - version: 0.0.0-use.local - resolution: "@girs/ecalendar-1.2@workspace:types/ecalendar-1.2" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/edatabook-1.2@workspace:types/edatabook-1.2": - version: 0.0.0-use.local - resolution: "@girs/edatabook-1.2@workspace:types/edatabook-1.2" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/ebackend-1.2": "workspace:^" - "@girs/ebookcontacts-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/edatacal-2.0@workspace:types/edatacal-2.0": - version: 0.0.0-use.local - resolution: "@girs/edatacal-2.0@workspace:types/edatacal-2.0" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/ebackend-1.2": "workspace:^" - "@girs/ecal-2.0": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/icalglib-3.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/edataserver-1.2@workspace:^, @girs/edataserver-1.2@workspace:types/edataserver-1.2": - version: 0.0.0-use.local - resolution: "@girs/edataserver-1.2@workspace:types/edataserver-1.2" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/edataserverui-1.2@workspace:types/edataserverui-1.2": - version: 0.0.0-use.local - resolution: "@girs/edataserverui-1.2@workspace:types/edataserverui-1.2" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/camel-1.2": "workspace:^" - "@girs/ecal-2.0": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/icalglib-3.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/edataserverui4-1.0@workspace:types/edataserverui4-1.0": - version: 0.0.0-use.local - resolution: "@girs/edataserverui4-1.0@workspace:types/edataserverui4-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/camel-1.2": "workspace:^" - "@girs/ecal-2.0": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/icalglib-3.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/egg-1.0@workspace:types/egg-1.0": - version: 0.0.0-use.local - resolution: "@girs/egg-1.0@workspace:types/egg-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/eog-3.0@workspace:types/eog-3.0": - version: 0.0.0-use.local - resolution: "@girs/eog-3.0@workspace:types/eog-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/epc-1.0@workspace:^, @girs/epc-1.0@workspace:types/epc-1.0": - version: 0.0.0-use.local - resolution: "@girs/epc-1.0@workspace:types/epc-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/epcui-1.0@workspace:types/epcui-1.0": - version: 0.0.0-use.local - resolution: "@girs/epcui-1.0@workspace:types/epcui-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/epc-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/evincedocument-3.0@workspace:^, @girs/evincedocument-3.0@workspace:types/evincedocument-3.0": - version: 0.0.0-use.local - resolution: "@girs/evincedocument-3.0@workspace:types/evincedocument-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/evinceview-3.0@workspace:types/evinceview-3.0": - version: 0.0.0-use.local - resolution: "@girs/evinceview-3.0@workspace:types/evinceview-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/evincedocument-3.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/farstream-0.1@workspace:types/farstream-0.1": - version: 0.0.0-use.local - resolution: "@girs/farstream-0.1@workspace:types/farstream-0.1" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/farstream-0.2@workspace:^, @girs/farstream-0.2@workspace:types/farstream-0.2": - version: 0.0.0-use.local - resolution: "@girs/farstream-0.2@workspace:types/farstream-0.2" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/flatpak-1.0@workspace:types/flatpak-1.0": - version: 0.0.0-use.local - resolution: "@girs/flatpak-1.0@workspace:types/flatpak-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folks-0.6@workspace:^, @girs/folks-0.6@workspace:types/folks-0.6": - version: 0.0.0-use.local - resolution: "@girs/folks-0.6@workspace:types/folks-0.6" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folks-0.7@workspace:^, @girs/folks-0.7@workspace:types/folks-0.7": - version: 0.0.0-use.local - resolution: "@girs/folks-0.7@workspace:types/folks-0.7" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folksdummy-0.6@workspace:types/folksdummy-0.6": - version: 0.0.0-use.local - resolution: "@girs/folksdummy-0.6@workspace:types/folksdummy-0.6" - dependencies: - "@girs/folks-0.6": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folksdummy-0.7@workspace:types/folksdummy-0.7": - version: 0.0.0-use.local - resolution: "@girs/folksdummy-0.7@workspace:types/folksdummy-0.7" - dependencies: - "@girs/folks-0.7": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folkseds-0.6@workspace:types/folkseds-0.6": - version: 0.0.0-use.local - resolution: "@girs/folkseds-0.6@workspace:types/folkseds-0.6" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/ebookcontacts-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/folks-0.6": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folkseds-0.7@workspace:types/folkseds-0.7": - version: 0.0.0-use.local - resolution: "@girs/folkseds-0.7@workspace:types/folkseds-0.7" - dependencies: - "@girs/camel-1.2": "workspace:^" - "@girs/ebookcontacts-1.2": "workspace:^" - "@girs/edataserver-1.2": "workspace:^" - "@girs/folks-0.7": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folkslibsocialweb-0.6@workspace:types/folkslibsocialweb-0.6": - version: 0.0.0-use.local - resolution: "@girs/folkslibsocialweb-0.6@workspace:types/folkslibsocialweb-0.6" - dependencies: - "@girs/folks-0.6": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/socialwebclient-0.25": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folkstelepathy-0.6@workspace:types/folkstelepathy-0.6": - version: 0.0.0-use.local - resolution: "@girs/folkstelepathy-0.6@workspace:types/folkstelepathy-0.6" - dependencies: - "@girs/folks-0.6": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/folkstelepathy-0.7@workspace:types/folkstelepathy-0.7": - version: 0.0.0-use.local - resolution: "@girs/folkstelepathy-0.7@workspace:types/folkstelepathy-0.7" - dependencies: - "@girs/folks-0.7": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/fontconfig-2.0@workspace:^, @girs/fontconfig-2.0@workspace:types/fontconfig-2.0": - version: 0.0.0-use.local - resolution: "@girs/fontconfig-2.0@workspace:types/fontconfig-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/freetype2-2.0@workspace:^, @girs/freetype2-2.0@workspace:types/freetype2-2.0": - version: 0.0.0-use.local - resolution: "@girs/freetype2-2.0@workspace:types/freetype2-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/fwupd-2.0@workspace:types/fwupd-2.0": - version: 0.0.0-use.local - resolution: "@girs/fwupd-2.0@workspace:types/fwupd-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gandiva-1.0@workspace:types/gandiva-1.0": - version: 0.0.0-use.local - resolution: "@girs/gandiva-1.0@workspace:types/gandiva-1.0" - dependencies: - "@girs/arrow-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcab-1.0@workspace:types/gcab-1.0": - version: 0.0.0-use.local - resolution: "@girs/gcab-1.0@workspace:types/gcab-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcalc-1@workspace:types/gcalc-1": - version: 0.0.0-use.local - resolution: "@girs/gcalc-1@workspace:types/gcalc-1" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcalc-2@workspace:^, @girs/gcalc-2@workspace:types/gcalc-2": - version: 0.0.0-use.local - resolution: "@girs/gcalc-2@workspace:types/gcalc-2" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gck-1@workspace:^, @girs/gck-1@workspace:types/gck-1": - version: 0.0.0-use.local - resolution: "@girs/gck-1@workspace:types/gck-1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gck-2@workspace:^, @girs/gck-2@workspace:types/gck-2": - version: 0.0.0-use.local - resolution: "@girs/gck-2@workspace:types/gck-2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gconf-2.0@workspace:^, @girs/gconf-2.0@workspace:types/gconf-2.0": - version: 0.0.0-use.local - resolution: "@girs/gconf-2.0@workspace:types/gconf-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcr-3@workspace:^, @girs/gcr-3@workspace:types/gcr-3": - version: 0.0.0-use.local - resolution: "@girs/gcr-3@workspace:types/gcr-3" - dependencies: - "@girs/gck-1": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcr-4@workspace:^, @girs/gcr-4@workspace:types/gcr-4": - version: 0.0.0-use.local - resolution: "@girs/gcr-4@workspace:types/gcr-4" - dependencies: - "@girs/gck-2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcrgtk3-4@workspace:types/gcrgtk3-4": - version: 0.0.0-use.local - resolution: "@girs/gcrgtk3-4@workspace:types/gcrgtk3-4" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gck-2": "workspace:^" - "@girs/gcr-4": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcrgtk4-4@workspace:types/gcrgtk4-4": - version: 0.0.0-use.local - resolution: "@girs/gcrgtk4-4@workspace:types/gcrgtk4-4" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gck-2": "workspace:^" - "@girs/gcr-4": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gcrui-3@workspace:types/gcrui-3": - version: 0.0.0-use.local - resolution: "@girs/gcrui-3@workspace:types/gcrui-3" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gck-1": "workspace:^" - "@girs/gcr-3": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gd-1.0@workspace:types/gd-1.0": - version: 0.0.0-use.local - resolution: "@girs/gd-1.0@workspace:types/gd-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gda-5.0@workspace:^, @girs/gda-5.0@workspace:types/gda-5.0": - version: 0.0.0-use.local - resolution: "@girs/gda-5.0@workspace:types/gda-5.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gda-6.0@workspace:^, @girs/gda-6.0@workspace:types/gda-6.0": - version: 0.0.0-use.local - resolution: "@girs/gda-6.0@workspace:types/gda-6.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdata-0.0@workspace:types/gdata-0.0": - version: 0.0.0-use.local - resolution: "@girs/gdata-0.0@workspace:types/gdata-0.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/goa-1.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdaui-5.0@workspace:types/gdaui-5.0": - version: 0.0.0-use.local - resolution: "@girs/gdaui-5.0@workspace:types/gdaui-5.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gda-5.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdaui-6.0@workspace:types/gdaui-6.0": - version: 0.0.0-use.local - resolution: "@girs/gdaui-6.0@workspace:types/gdaui-6.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gda-6.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdesktopenums-3.0@workspace:^, @girs/gdesktopenums-3.0@workspace:types/gdesktopenums-3.0": - version: 0.0.0-use.local - resolution: "@girs/gdesktopenums-3.0@workspace:types/gdesktopenums-3.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdk-2.0@workspace:^, @girs/gdk-2.0@workspace:types/gdk-2.0": - version: 0.0.0-use.local - resolution: "@girs/gdk-2.0@workspace:types/gdk-2.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdk-3.0@workspace:^, @girs/gdk-3.0@workspace:types/gdk-3.0": - version: 0.0.0-use.local - resolution: "@girs/gdk-3.0@workspace:types/gdk-3.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdk-4.0@workspace:^, @girs/gdk-4.0@workspace:types/gdk-4.0": - version: 0.0.0-use.local - resolution: "@girs/gdk-4.0@workspace:types/gdk-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdkpixbuf-2.0@workspace:^, @girs/gdkpixbuf-2.0@workspace:types/gdkpixbuf-2.0": - version: 0.0.0-use.local - resolution: "@girs/gdkpixbuf-2.0@workspace:types/gdkpixbuf-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdkpixdata-2.0@workspace:types/gdkpixdata-2.0": - version: 0.0.0-use.local - resolution: "@girs/gdkpixdata-2.0@workspace:types/gdkpixdata-2.0" - dependencies: - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdkwayland-4.0@workspace:types/gdkwayland-4.0": - version: 0.0.0-use.local - resolution: "@girs/gdkwayland-4.0@workspace:types/gdkwayland-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdkx11-2.0@workspace:types/gdkx11-2.0": - version: 0.0.0-use.local - resolution: "@girs/gdkx11-2.0@workspace:types/gdkx11-2.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdkx11-3.0@workspace:types/gdkx11-3.0": - version: 0.0.0-use.local - resolution: "@girs/gdkx11-3.0@workspace:types/gdkx11-3.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdkx11-4.0@workspace:types/gdkx11-4.0": - version: 0.0.0-use.local - resolution: "@girs/gdkx11-4.0@workspace:types/gdkx11-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdl-3@workspace:^, @girs/gdl-3@workspace:types/gdl-3": - version: 0.0.0-use.local - resolution: "@girs/gdl-3@workspace:types/gdl-3" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gdm-1.0@workspace:types/gdm-1.0": - version: 0.0.0-use.local - resolution: "@girs/gdm-1.0@workspace:types/gdm-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gedit-3.0@workspace:types/gedit-3.0": - version: 0.0.0-use.local - resolution: "@girs/gedit-3.0@workspace:types/gedit-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-4": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gee-0.8@workspace:^, @girs/gee-0.8@workspace:types/gee-0.8": - version: 0.0.0-use.local - resolution: "@girs/gee-0.8@workspace:types/gee-0.8" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gee-1.0@workspace:types/gee-1.0": - version: 0.0.0-use.local - resolution: "@girs/gee-1.0@workspace:types/gee-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gegl-0.3@workspace:types/gegl-0.3": - version: 0.0.0-use.local - resolution: "@girs/gegl-0.3@workspace:types/gegl-0.3" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gegl-0.4@workspace:^, @girs/gegl-0.4@workspace:types/gegl-0.4": - version: 0.0.0-use.local - resolution: "@girs/gegl-0.4@workspace:types/gegl-0.4" - dependencies: - "@girs/babl-0.1": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/geglgtk3-0.1@workspace:types/geglgtk3-0.1": - version: 0.0.0-use.local - resolution: "@girs/geglgtk3-0.1@workspace:types/geglgtk3-0.1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/babl-0.1": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gegl-0.4": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/geoclue-2.0@workspace:types/geoclue-2.0": - version: 0.0.0-use.local - resolution: "@girs/geoclue-2.0@workspace:types/geoclue-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/geocodeglib-1.0@workspace:^, @girs/geocodeglib-1.0@workspace:types/geocodeglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/geocodeglib-1.0@workspace:types/geocodeglib-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/geocodeglib-2.0@workspace:types/geocodeglib-2.0": - version: 0.0.0-use.local - resolution: "@girs/geocodeglib-2.0@workspace:types/geocodeglib-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gepub-0.5@workspace:types/gepub-0.5": - version: 0.0.0-use.local - resolution: "@girs/gepub-0.5@workspace:types/gepub-0.5" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-4.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - "@girs/webkit2-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ges-1.0@workspace:types/ges-1.0": - version: 0.0.0-use.local - resolution: "@girs/ges-1.0@workspace:types/ges-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gexiv2-0.10@workspace:types/gexiv2-0.10": - version: 0.0.0-use.local - resolution: "@girs/gexiv2-0.10@workspace:types/gexiv2-0.10" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gfbgraph-0.2@workspace:types/gfbgraph-0.2": - version: 0.0.0-use.local - resolution: "@girs/gfbgraph-0.2@workspace:types/gfbgraph-0.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/rest-0.7": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gfbgraph-0.3@workspace:types/gfbgraph-0.3": - version: 0.0.0-use.local - resolution: "@girs/gfbgraph-0.3@workspace:types/gfbgraph-0.3" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/rest-0.7": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ggit-1.0@workspace:^, @girs/ggit-1.0@workspace:types/ggit-1.0": - version: 0.0.0-use.local - resolution: "@girs/ggit-1.0@workspace:types/ggit-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gio-2.0@workspace:^, @girs/gio-2.0@workspace:types/gio-2.0": - version: 0.0.0-use.local - resolution: "@girs/gio-2.0@workspace:types/gio-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/girepository-2.0@workspace:^, @girs/girepository-2.0@workspace:types/girepository-2.0": - version: 0.0.0-use.local - resolution: "@girs/girepository-2.0@workspace:types/girepository-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gitg-1.0@workspace:^, @girs/gitg-1.0@workspace:types/gitg-1.0": - version: 0.0.0-use.local - resolution: "@girs/gitg-1.0@workspace:types/gitg-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/ggit-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gitgext-1.0@workspace:types/gitgext-1.0": - version: 0.0.0-use.local - resolution: "@girs/gitgext-1.0@workspace:types/gitgext-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/ggit-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gitg-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gjs@workspace:^, @girs/gjs@workspace:types/gjs": - version: 0.0.0-use.local - resolution: "@girs/gjs@workspace:types/gjs" - dependencies: - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gjsdbus-1.0@workspace:types/gjsdbus-1.0": - version: 0.0.0-use.local - resolution: "@girs/gjsdbus-1.0@workspace:types/gjsdbus-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gkbd-3.0@workspace:types/gkbd-3.0": - version: 0.0.0-use.local - resolution: "@girs/gkbd-3.0@workspace:types/gkbd-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xkl-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gl-1.0@workspace:^, @girs/gl-1.0@workspace:types/gl-1.0": - version: 0.0.0-use.local - resolution: "@girs/gl-1.0@workspace:types/gl-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gladeui-2.0@workspace:types/gladeui-2.0": - version: 0.0.0-use.local - resolution: "@girs/gladeui-2.0@workspace:types/gladeui-2.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/glib-2.0@workspace:^, @girs/glib-2.0@workspace:types/glib-2.0": - version: 0.0.0-use.local - resolution: "@girs/glib-2.0@workspace:types/glib-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gmenu-3.0@workspace:types/gmenu-3.0": - version: 0.0.0-use.local - resolution: "@girs/gmenu-3.0@workspace:types/gmenu-3.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gmime-3.0@workspace:types/gmime-3.0": - version: 0.0.0-use.local - resolution: "@girs/gmime-3.0@workspace:types/gmime-3.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gmodule-2.0@workspace:^, @girs/gmodule-2.0@workspace:types/gmodule-2.0": - version: 0.0.0-use.local - resolution: "@girs/gmodule-2.0@workspace:types/gmodule-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomeautoar-0.1@workspace:^, @girs/gnomeautoar-0.1@workspace:types/gnomeautoar-0.1": - version: 0.0.0-use.local - resolution: "@girs/gnomeautoar-0.1@workspace:types/gnomeautoar-0.1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomeautoargtk-0.1@workspace:types/gnomeautoargtk-0.1": - version: 0.0.0-use.local - resolution: "@girs/gnomeautoargtk-0.1@workspace:types/gnomeautoargtk-0.1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gnomeautoar-0.1": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomebg-4.0@workspace:types/gnomebg-4.0": - version: 0.0.0-use.local - resolution: "@girs/gnomebg-4.0@workspace:types/gnomebg-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gnomedesktop-4.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomebluetooth-1.0@workspace:types/gnomebluetooth-1.0": - version: 0.0.0-use.local - resolution: "@girs/gnomebluetooth-1.0@workspace:types/gnomebluetooth-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomebluetooth-3.0@workspace:types/gnomebluetooth-3.0": - version: 0.0.0-use.local - resolution: "@girs/gnomebluetooth-3.0@workspace:types/gnomebluetooth-3.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomedesktop-3.0@workspace:types/gnomedesktop-3.0": - version: 0.0.0-use.local - resolution: "@girs/gnomedesktop-3.0@workspace:types/gnomedesktop-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomedesktop-4.0@workspace:^, @girs/gnomedesktop-4.0@workspace:types/gnomedesktop-4.0": - version: 0.0.0-use.local - resolution: "@girs/gnomedesktop-4.0@workspace:types/gnomedesktop-4.0" - dependencies: - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomekeyring-1.0@workspace:types/gnomekeyring-1.0": - version: 0.0.0-use.local - resolution: "@girs/gnomekeyring-1.0@workspace:types/gnomekeyring-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomemaps-1.0@workspace:types/gnomemaps-1.0": - version: 0.0.0-use.local - resolution: "@girs/gnomemaps-1.0@workspace:types/gnomemaps-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/champlain-0.12": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/geocodeglib-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/rest-0.7": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gnomerr-4.0@workspace:types/gnomerr-4.0": - version: 0.0.0-use.local - resolution: "@girs/gnomerr-4.0@workspace:types/gnomerr-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gnomedesktop-4.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/goa-1.0@workspace:^, @girs/goa-1.0@workspace:types/goa-1.0": - version: 0.0.0-use.local - resolution: "@girs/goa-1.0@workspace:types/goa-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gobject-2.0@workspace:^, @girs/gobject-2.0@workspace:types/gobject-2.0": - version: 0.0.0-use.local - resolution: "@girs/gobject-2.0@workspace:types/gobject-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/goocanvas-2.0@workspace:types/goocanvas-2.0": - version: 0.0.0-use.local - resolution: "@girs/goocanvas-2.0@workspace:types/goocanvas-2.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/goocanvas-3.0@workspace:types/goocanvas-3.0": - version: 0.0.0-use.local - resolution: "@girs/goocanvas-3.0@workspace:types/goocanvas-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/govirt-1.0@workspace:types/govirt-1.0": - version: 0.0.0-use.local - resolution: "@girs/govirt-1.0@workspace:types/govirt-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/rest-0.7": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gpseq-1.0@workspace:types/gpseq-1.0": - version: 0.0.0-use.local - resolution: "@girs/gpseq-1.0@workspace:types/gpseq-1.0" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/granite-1.0@workspace:types/granite-1.0": - version: 0.0.0-use.local - resolution: "@girs/granite-1.0@workspace:types/granite-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/granite-7.0@workspace:types/granite-7.0": - version: 0.0.0-use.local - resolution: "@girs/granite-7.0@workspace:types/granite-7.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/graphene-1.0@workspace:^, @girs/graphene-1.0@workspace:types/graphene-1.0": - version: 0.0.0-use.local - resolution: "@girs/graphene-1.0@workspace:types/graphene-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grl-0.1@workspace:types/grl-0.1": - version: 0.0.0-use.local - resolution: "@girs/grl-0.1@workspace:types/grl-0.1" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grl-0.2@workspace:^, @girs/grl-0.2@workspace:types/grl-0.2": - version: 0.0.0-use.local - resolution: "@girs/grl-0.2@workspace:types/grl-0.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grl-0.3@workspace:^, @girs/grl-0.3@workspace:types/grl-0.3": - version: 0.0.0-use.local - resolution: "@girs/grl-0.3@workspace:types/grl-0.3" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grlnet-0.1@workspace:types/grlnet-0.1": - version: 0.0.0-use.local - resolution: "@girs/grlnet-0.1@workspace:types/grlnet-0.1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grlnet-0.2@workspace:types/grlnet-0.2": - version: 0.0.0-use.local - resolution: "@girs/grlnet-0.2@workspace:types/grlnet-0.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grlnet-0.3@workspace:types/grlnet-0.3": - version: 0.0.0-use.local - resolution: "@girs/grlnet-0.3@workspace:types/grlnet-0.3" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grlpls-0.2@workspace:types/grlpls-0.2": - version: 0.0.0-use.local - resolution: "@girs/grlpls-0.2@workspace:types/grlpls-0.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/grl-0.2": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grlpls-0.3@workspace:types/grlpls-0.3": - version: 0.0.0-use.local - resolution: "@girs/grlpls-0.3@workspace:types/grlpls-0.3" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/grl-0.3": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/grss-0.7@workspace:types/grss-0.7": - version: 0.0.0-use.local - resolution: "@girs/grss-0.7@workspace:types/grss-0.7" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsf-1@workspace:types/gsf-1": - version: 0.0.0-use.local - resolution: "@girs/gsf-1@workspace:types/gsf-1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsignon-1.0@workspace:types/gsignon-1.0": - version: 0.0.0-use.local - resolution: "@girs/gsignon-1.0@workspace:types/gsignon-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsignond-1.0@workspace:types/gsignond-1.0": - version: 0.0.0-use.local - resolution: "@girs/gsignond-1.0@workspace:types/gsignond-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsk-4.0@workspace:^, @girs/gsk-4.0@workspace:types/gsk-4.0": - version: 0.0.0-use.local - resolution: "@girs/gsk-4.0@workspace:types/gsk-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsound-1.0@workspace:types/gsound-1.0": - version: 0.0.0-use.local - resolution: "@girs/gsound-1.0@workspace:types/gsound-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gspell-1@workspace:types/gspell-1": - version: 0.0.0-use.local - resolution: "@girs/gspell-1@workspace:types/gspell-1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gssdp-1.0@workspace:^, @girs/gssdp-1.0@workspace:types/gssdp-1.0": - version: 0.0.0-use.local - resolution: "@girs/gssdp-1.0@workspace:types/gssdp-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gssdp-1.2@workspace:^, @girs/gssdp-1.2@workspace:types/gssdp-1.2": - version: 0.0.0-use.local - resolution: "@girs/gssdp-1.2@workspace:types/gssdp-1.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gssdp-1.6@workspace:^, @girs/gssdp-1.6@workspace:types/gssdp-1.6": - version: 0.0.0-use.local - resolution: "@girs/gssdp-1.6@workspace:types/gssdp-1.6" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gst-0.10@workspace:^, @girs/gst-0.10@workspace:types/gst-0.10": - version: 0.0.0-use.local - resolution: "@girs/gst-0.10@workspace:types/gst-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gst-1.0@workspace:^, @girs/gst-1.0@workspace:types/gst-1.0": - version: 0.0.0-use.local - resolution: "@girs/gst-1.0@workspace:types/gst-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstallocators-1.0@workspace:types/gstallocators-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstallocators-1.0@workspace:types/gstallocators-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstapp-1.0@workspace:types/gstapp-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstapp-1.0@workspace:types/gstapp-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstaudio-0.10@workspace:^, @girs/gstaudio-0.10@workspace:types/gstaudio-0.10": - version: 0.0.0-use.local - resolution: "@girs/gstaudio-0.10@workspace:types/gstaudio-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/gstbase-0.10": "workspace:^" - "@girs/gstinterfaces-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstaudio-1.0@workspace:^, @girs/gstaudio-1.0@workspace:types/gstaudio-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstaudio-1.0@workspace:types/gstaudio-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstbadallocators-1.0@workspace:types/gstbadallocators-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstbadallocators-1.0@workspace:types/gstbadallocators-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstbadaudio-1.0@workspace:types/gstbadaudio-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstbadaudio-1.0@workspace:types/gstbadaudio-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstbase-0.10@workspace:^, @girs/gstbase-0.10@workspace:types/gstbase-0.10": - version: 0.0.0-use.local - resolution: "@girs/gstbase-0.10@workspace:types/gstbase-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstbase-1.0@workspace:^, @girs/gstbase-1.0@workspace:types/gstbase-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstbase-1.0@workspace:types/gstbase-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstcheck-1.0@workspace:types/gstcheck-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstcheck-1.0@workspace:types/gstcheck-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstcodecs-1.0@workspace:types/gstcodecs-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstcodecs-1.0@workspace:types/gstcodecs-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstcontroller-1.0@workspace:types/gstcontroller-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstcontroller-1.0@workspace:types/gstcontroller-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstfft-1.0@workspace:types/gstfft-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstfft-1.0@workspace:types/gstfft-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstgl-1.0@workspace:^, @girs/gstgl-1.0@workspace:types/gstgl-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstgl-1.0@workspace:types/gstgl-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstglegl-1.0@workspace:types/gstglegl-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstglegl-1.0@workspace:types/gstglegl-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstgl-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstglwayland-1.0@workspace:types/gstglwayland-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstglwayland-1.0@workspace:types/gstglwayland-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstgl-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstglx11-1.0@workspace:types/gstglx11-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstglx11-1.0@workspace:types/gstglx11-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstgl-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstinsertbin-1.0@workspace:types/gstinsertbin-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstinsertbin-1.0@workspace:types/gstinsertbin-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstinterfaces-0.10@workspace:^, @girs/gstinterfaces-0.10@workspace:types/gstinterfaces-0.10": - version: 0.0.0-use.local - resolution: "@girs/gstinterfaces-0.10@workspace:types/gstinterfaces-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstmpegts-1.0@workspace:types/gstmpegts-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstmpegts-1.0@workspace:types/gstmpegts-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstnet-1.0@workspace:^, @girs/gstnet-1.0@workspace:types/gstnet-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstnet-1.0@workspace:types/gstnet-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstpbutils-0.10@workspace:^, @girs/gstpbutils-0.10@workspace:types/gstpbutils-0.10": - version: 0.0.0-use.local - resolution: "@girs/gstpbutils-0.10@workspace:types/gstpbutils-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstpbutils-1.0@workspace:^, @girs/gstpbutils-1.0@workspace:types/gstpbutils-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstpbutils-1.0@workspace:types/gstpbutils-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstplay-1.0@workspace:types/gstplay-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstplay-1.0@workspace:types/gstplay-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gsttag-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstplayer-1.0@workspace:types/gstplayer-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstplayer-1.0@workspace:types/gstplayer-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gsttag-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstriff-1.0@workspace:types/gstriff-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstriff-1.0@workspace:types/gstriff-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstrtp-1.0@workspace:types/gstrtp-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstrtp-1.0@workspace:types/gstrtp-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstrtsp-1.0@workspace:^, @girs/gstrtsp-1.0@workspace:types/gstrtsp-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstrtsp-1.0@workspace:types/gstrtsp-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstsdp-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstrtspserver-1.0@workspace:types/gstrtspserver-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstrtspserver-1.0@workspace:types/gstrtspserver-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstnet-1.0": "workspace:^" - "@girs/gstrtsp-1.0": "workspace:^" - "@girs/gstsdp-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstsdp-1.0@workspace:^, @girs/gstsdp-1.0@workspace:types/gstsdp-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstsdp-1.0@workspace:types/gstsdp-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsttag-0.10@workspace:^, @girs/gsttag-0.10@workspace:types/gsttag-0.10": - version: 0.0.0-use.local - resolution: "@girs/gsttag-0.10@workspace:types/gsttag-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsttag-1.0@workspace:^, @girs/gsttag-1.0@workspace:types/gsttag-1.0": - version: 0.0.0-use.local - resolution: "@girs/gsttag-1.0@workspace:types/gsttag-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsttranscoder-1.0@workspace:types/gsttranscoder-1.0": - version: 0.0.0-use.local - resolution: "@girs/gsttranscoder-1.0@workspace:types/gsttranscoder-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstvideo-0.10@workspace:^, @girs/gstvideo-0.10@workspace:types/gstvideo-0.10": - version: 0.0.0-use.local - resolution: "@girs/gstvideo-0.10@workspace:types/gstvideo-0.10" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/gstbase-0.10": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstvideo-1.0@workspace:^, @girs/gstvideo-1.0@workspace:types/gstvideo-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstvideo-1.0@workspace:types/gstvideo-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstvulkan-1.0@workspace:types/gstvulkan-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstvulkan-1.0@workspace:types/gstvulkan-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - "@girs/vulkan-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gstwebrtc-1.0@workspace:types/gstwebrtc-1.0": - version: 0.0.0-use.local - resolution: "@girs/gstwebrtc-1.0@workspace:types/gstwebrtc-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstsdp-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gsystem-1.0@workspace:types/gsystem-1.0": - version: 0.0.0-use.local - resolution: "@girs/gsystem-1.0@workspace:types/gsystem-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtef-2@workspace:types/gtef-2": - version: 0.0.0-use.local - resolution: "@girs/gtef-2@workspace:types/gtef-2" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtk-2.0@workspace:^, @girs/gtk-2.0@workspace:types/gtk-2.0": - version: 0.0.0-use.local - resolution: "@girs/gtk-2.0@workspace:types/gtk-2.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtk-3.0@workspace:^, @girs/gtk-3.0@workspace:types/gtk-3.0": - version: 0.0.0-use.local - resolution: "@girs/gtk-3.0@workspace:types/gtk-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtk-4.0@workspace:^, @girs/gtk-4.0@workspace:types/gtk-4.0": - version: 0.0.0-use.local - resolution: "@girs/gtk-4.0@workspace:types/gtk-4.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtkchamplain-0.12@workspace:types/gtkchamplain-0.12": - version: 0.0.0-use.local - resolution: "@girs/gtkchamplain-0.12@workspace:types/gtkchamplain-0.12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/champlain-0.12": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtkclutter-1.0@workspace:types/gtkclutter-1.0": - version: 0.0.0-use.local - resolution: "@girs/gtkclutter-1.0@workspace:types/gtkclutter-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtksource-3.0@workspace:^, @girs/gtksource-3.0@workspace:types/gtksource-3.0": - version: 0.0.0-use.local - resolution: "@girs/gtksource-3.0@workspace:types/gtksource-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtksource-4@workspace:^, @girs/gtksource-4@workspace:types/gtksource-4": - version: 0.0.0-use.local - resolution: "@girs/gtksource-4@workspace:types/gtksource-4" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtksource-5@workspace:types/gtksource-5": - version: 0.0.0-use.local - resolution: "@girs/gtksource-5@workspace:types/gtksource-5" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtkvnc-2.0@workspace:types/gtkvnc-2.0": - version: 0.0.0-use.local - resolution: "@girs/gtkvnc-2.0@workspace:types/gtkvnc-2.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gvnc-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gtop-2.0@workspace:types/gtop-2.0": - version: 0.0.0-use.local - resolution: "@girs/gtop-2.0@workspace:types/gtop-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gucharmap-2.90@workspace:types/gucharmap-2.90": - version: 0.0.0-use.local - resolution: "@girs/gucharmap-2.90@workspace:types/gucharmap-2.90" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gudev-1.0@workspace:^, @girs/gudev-1.0@workspace:types/gudev-1.0": - version: 0.0.0-use.local - resolution: "@girs/gudev-1.0@workspace:types/gudev-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/guestfs-1.0@workspace:types/guestfs-1.0": - version: 0.0.0-use.local - resolution: "@girs/guestfs-1.0@workspace:types/guestfs-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnp-1.0@workspace:types/gupnp-1.0": - version: 0.0.0-use.local - resolution: "@girs/gupnp-1.0@workspace:types/gupnp-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnp-1.2@workspace:^, @girs/gupnp-1.2@workspace:types/gupnp-1.2": - version: 0.0.0-use.local - resolution: "@girs/gupnp-1.2@workspace:types/gupnp-1.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.2": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnp-1.6@workspace:^, @girs/gupnp-1.6@workspace:types/gupnp-1.6": - version: 0.0.0-use.local - resolution: "@girs/gupnp-1.6@workspace:types/gupnp-1.6" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.6": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnpav-1.0@workspace:^, @girs/gupnpav-1.0@workspace:types/gupnpav-1.0": - version: 0.0.0-use.local - resolution: "@girs/gupnpav-1.0@workspace:types/gupnpav-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnpdlna-1.0@workspace:types/gupnpdlna-1.0": - version: 0.0.0-use.local - resolution: "@girs/gupnpdlna-1.0@workspace:types/gupnpdlna-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnpdlna-2.0@workspace:^, @girs/gupnpdlna-2.0@workspace:types/gupnpdlna-2.0": - version: 0.0.0-use.local - resolution: "@girs/gupnpdlna-2.0@workspace:types/gupnpdlna-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnpdlnagst-2.0@workspace:types/gupnpdlnagst-2.0": - version: 0.0.0-use.local - resolution: "@girs/gupnpdlnagst-2.0@workspace:types/gupnpdlnagst-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstaudio-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gstpbutils-1.0": "workspace:^" - "@girs/gstvideo-1.0": "workspace:^" - "@girs/gupnpdlna-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gupnpigd-1.0@workspace:types/gupnpigd-1.0": - version: 0.0.0-use.local - resolution: "@girs/gupnpigd-1.0@workspace:types/gupnpigd-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gusb-1.0@workspace:^, @girs/gusb-1.0@workspace:types/gusb-1.0": - version: 0.0.0-use.local - resolution: "@girs/gusb-1.0@workspace:types/gusb-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gvc-1.0@workspace:^, @girs/gvc-1.0@workspace:types/gvc-1.0": - version: 0.0.0-use.local - resolution: "@girs/gvc-1.0@workspace:types/gvc-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gvnc-1.0@workspace:^, @girs/gvnc-1.0@workspace:types/gvnc-1.0": - version: 0.0.0-use.local - resolution: "@girs/gvnc-1.0@workspace:types/gvnc-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gvncpulse-1.0@workspace:types/gvncpulse-1.0": - version: 0.0.0-use.local - resolution: "@girs/gvncpulse-1.0@workspace:types/gvncpulse-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gvnc-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gweather-3.0@workspace:types/gweather-3.0": - version: 0.0.0-use.local - resolution: "@girs/gweather-3.0@workspace:types/gweather-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gweather-4.0@workspace:types/gweather-4.0": - version: 0.0.0-use.local - resolution: "@girs/gweather-4.0@workspace:types/gweather-4.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gxml-0.14@workspace:types/gxml-0.14": - version: 0.0.0-use.local - resolution: "@girs/gxml-0.14@workspace:types/gxml-0.14" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gxml-0.16@workspace:types/gxml-0.16": - version: 0.0.0-use.local - resolution: "@girs/gxml-0.16@workspace:types/gxml-0.16" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gxml-0.18@workspace:types/gxml-0.18": - version: 0.0.0-use.local - resolution: "@girs/gxml-0.18@workspace:types/gxml-0.18" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gxml-0.20@workspace:^, @girs/gxml-0.20@workspace:types/gxml-0.20": - version: 0.0.0-use.local - resolution: "@girs/gxml-0.20@workspace:types/gxml-0.20" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gxps-0.1@workspace:types/gxps-0.1": - version: 0.0.0-use.local - resolution: "@girs/gxps-0.1@workspace:types/gxps-0.1" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/gxps-1.0@workspace:types/gxps-1.0": - version: 0.0.0-use.local - resolution: "@girs/gxps-1.0@workspace:types/gxps-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/handy-0.0@workspace:types/handy-0.0": - version: 0.0.0-use.local - resolution: "@girs/handy-0.0@workspace:types/handy-0.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/handy-1@workspace:types/handy-1": - version: 0.0.0-use.local - resolution: "@girs/handy-1@workspace:types/handy-1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/harfbuzz-0.0@workspace:^, @girs/harfbuzz-0.0@workspace:types/harfbuzz-0.0": - version: 0.0.0-use.local - resolution: "@girs/harfbuzz-0.0@workspace:types/harfbuzz-0.0" - dependencies: - "@girs/freetype2-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ianjuta-3.0@workspace:types/ianjuta-3.0": - version: 0.0.0-use.local - resolution: "@girs/ianjuta-3.0@workspace:types/ianjuta-3.0" - dependencies: - "@girs/anjuta-3.0": "workspace:^" - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gdl-3": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ibus-1.0@workspace:types/ibus-1.0": - version: 0.0.0-use.local - resolution: "@girs/ibus-1.0@workspace:types/ibus-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ical-3.0@workspace:types/ical-3.0": - version: 0.0.0-use.local - resolution: "@girs/ical-3.0@workspace:types/ical-3.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/icalglib-3.0@workspace:^, @girs/icalglib-3.0@workspace:types/icalglib-3.0": - version: 0.0.0-use.local - resolution: "@girs/icalglib-3.0@workspace:types/icalglib-3.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ide-1.0@workspace:^, @girs/ide-1.0@workspace:types/ide-1.0": - version: 0.0.0-use.local - resolution: "@girs/ide-1.0@workspace:types/ide-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/dazzle-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/girepository-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/peas-1.0": "workspace:^" - "@girs/template-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/javascriptcore-4.0@workspace:^, @girs/javascriptcore-4.0@workspace:types/javascriptcore-4.0": - version: 0.0.0-use.local - resolution: "@girs/javascriptcore-4.0@workspace:types/javascriptcore-4.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/javascriptcore-4.1@workspace:^, @girs/javascriptcore-4.1@workspace:types/javascriptcore-4.1": - version: 0.0.0-use.local - resolution: "@girs/javascriptcore-4.1@workspace:types/javascriptcore-4.1" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/javascriptcore-5.0@workspace:^, @girs/javascriptcore-5.0@workspace:types/javascriptcore-5.0": - version: 0.0.0-use.local - resolution: "@girs/javascriptcore-5.0@workspace:types/javascriptcore-5.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/javascriptcore-6.0@workspace:^, @girs/javascriptcore-6.0@workspace:types/javascriptcore-6.0": - version: 0.0.0-use.local - resolution: "@girs/javascriptcore-6.0@workspace:types/javascriptcore-6.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/jscore-3.0@workspace:types/jscore-3.0": - version: 0.0.0-use.local - resolution: "@girs/jscore-3.0@workspace:types/jscore-3.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/json-1.0@workspace:^, @girs/json-1.0@workspace:types/json-1.0": - version: 0.0.0-use.local - resolution: "@girs/json-1.0@workspace:types/json-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/jsonrpc-1.0@workspace:types/jsonrpc-1.0": - version: 0.0.0-use.local - resolution: "@girs/jsonrpc-1.0@workspace:types/jsonrpc-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/libmsi-1.0@workspace:types/libmsi-1.0": - version: 0.0.0-use.local - resolution: "@girs/libmsi-1.0@workspace:types/libmsi-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/libosinfo-1.0@workspace:types/libosinfo-1.0": - version: 0.0.0-use.local - resolution: "@girs/libosinfo-1.0@workspace:types/libosinfo-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/libvirtgconfig-1.0@workspace:^, @girs/libvirtgconfig-1.0@workspace:types/libvirtgconfig-1.0": - version: 0.0.0-use.local - resolution: "@girs/libvirtgconfig-1.0@workspace:types/libvirtgconfig-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/libvirtglib-1.0@workspace:^, @girs/libvirtglib-1.0@workspace:types/libvirtglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/libvirtglib-1.0@workspace:types/libvirtglib-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/libvirtgobject-1.0@workspace:types/libvirtgobject-1.0": - version: 0.0.0-use.local - resolution: "@girs/libvirtgobject-1.0@workspace:types/libvirtgobject-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libvirtgconfig-1.0": "workspace:^" - "@girs/libvirtglib-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/libxml2-2.0@workspace:^, @girs/libxml2-2.0@workspace:types/libxml2-2.0": - version: 0.0.0-use.local - resolution: "@girs/libxml2-2.0@workspace:types/libxml2-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/manette-0.2@workspace:types/manette-0.2": - version: 0.0.0-use.local - resolution: "@girs/manette-0.2@workspace:types/manette-0.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gudev-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mash-0.2@workspace:types/mash-0.2": - version: 0.0.0-use.local - resolution: "@girs/mash-0.2@workspace:types/mash-0.2" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - "@girs/pangoft2-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mbim-1.0@workspace:types/mbim-1.0": - version: 0.0.0-use.local - resolution: "@girs/mbim-1.0@workspace:types/mbim-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mediaart-1.0@workspace:types/mediaart-1.0": - version: 0.0.0-use.local - resolution: "@girs/mediaart-1.0@workspace:types/mediaart-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mediaart-2.0@workspace:types/mediaart-2.0": - version: 0.0.0-use.local - resolution: "@girs/mediaart-2.0@workspace:types/mediaart-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/meta-10@workspace:types/meta-10": - version: 0.0.0-use.local - resolution: "@girs/meta-10@workspace:types/meta-10" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-10": "workspace:^" - "@girs/cogl-10": "workspace:^" - "@girs/coglpango-10": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/meta-11@workspace:^, @girs/meta-11@workspace:types/meta-11": - version: 0.0.0-use.local - resolution: "@girs/meta-11@workspace:types/meta-11" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-11": "workspace:^" - "@girs/cogl-11": "workspace:^" - "@girs/coglpango-11": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/meta-12@workspace:^, @girs/meta-12@workspace:types/meta-12": - version: 0.0.0-use.local - resolution: "@girs/meta-12@workspace:types/meta-12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-12": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/coglpango-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/meta-13@workspace:^, @girs/meta-13@workspace:types/meta-13": - version: 0.0.0-use.local - resolution: "@girs/meta-13@workspace:types/meta-13" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-13": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/coglpango-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/mtk-13": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/metatest-12@workspace:types/metatest-12": - version: 0.0.0-use.local - resolution: "@girs/metatest-12@workspace:types/metatest-12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-12": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/coglpango-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-12": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/metatest-13@workspace:types/metatest-13": - version: 0.0.0-use.local - resolution: "@girs/metatest-13@workspace:types/metatest-13" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-13": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/coglpango-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-13": "workspace:^" - "@girs/mtk-13": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/modemmanager-1.0@workspace:types/modemmanager-1.0": - version: 0.0.0-use.local - resolution: "@girs/modemmanager-1.0@workspace:types/modemmanager-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mtk-13@workspace:^, @girs/mtk-13@workspace:types/mtk-13": - version: 0.0.0-use.local - resolution: "@girs/mtk-13@workspace:types/mtk-13" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mx-1.0@workspace:types/mx-1.0": - version: 0.0.0-use.local - resolution: "@girs/mx-1.0@workspace:types/mx-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - "@girs/pangoft2-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mx-2.0@workspace:types/mx-2.0": - version: 0.0.0-use.local - resolution: "@girs/mx-2.0@workspace:types/mx-2.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - "@girs/pangoft2-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/mxgtk-1.0@workspace:types/mxgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/mxgtk-1.0@workspace:types/mxgtk-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-2.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/nautilus-3.0@workspace:types/nautilus-3.0": - version: 0.0.0-use.local - resolution: "@girs/nautilus-3.0@workspace:types/nautilus-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/networkmanager-1.0@workspace:^, @girs/networkmanager-1.0@workspace:types/networkmanager-1.0": - version: 0.0.0-use.local - resolution: "@girs/networkmanager-1.0@workspace:types/networkmanager-1.0" - dependencies: - "@girs/dbusglib-1.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/nice-0.1@workspace:types/nice-0.1": - version: 0.0.0-use.local - resolution: "@girs/nice-0.1@workspace:types/nice-0.1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/nm-1.0@workspace:^, @girs/nm-1.0@workspace:types/nm-1.0": - version: 0.0.0-use.local - resolution: "@girs/nm-1.0@workspace:types/nm-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/nma-1.0@workspace:types/nma-1.0": - version: 0.0.0-use.local - resolution: "@girs/nma-1.0@workspace:types/nma-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/nm-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/nmclient-1.0@workspace:^, @girs/nmclient-1.0@workspace:types/nmclient-1.0": - version: 0.0.0-use.local - resolution: "@girs/nmclient-1.0@workspace:types/nmclient-1.0" - dependencies: - "@girs/dbusglib-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/networkmanager-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/nmgtk-1.0@workspace:types/nmgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/nmgtk-1.0@workspace:types/nmgtk-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/dbusglib-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/networkmanager-1.0": "workspace:^" - "@girs/nmclient-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/node-accounts-1.0@workspace:types/node-accounts-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-accounts-1.0@workspace:types/node-accounts-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-accountsservice-1.0@workspace:types/node-accountsservice-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-accountsservice-1.0@workspace:types/node-accountsservice-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-adw-1@workspace:types/node-adw-1": - version: 0.0.0-use.local - resolution: "@girs/node-adw-1@workspace:types/node-adw-1" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-amtk-4@workspace:types/node-amtk-4": - version: 0.0.0-use.local - resolution: "@girs/node-amtk-4@workspace:types/node-amtk-4" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-amtk-5@workspace:^, @girs/node-amtk-5@workspace:types/node-amtk-5": - version: 0.0.0-use.local - resolution: "@girs/node-amtk-5@workspace:types/node-amtk-5" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-anjuta-3.0@workspace:^, @girs/node-anjuta-3.0@workspace:types/node-anjuta-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-anjuta-3.0@workspace:types/node-anjuta-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gdl-3": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-anthy-9000@workspace:types/node-anthy-9000": - version: 0.0.0-use.local - resolution: "@girs/node-anthy-9000@workspace:types/node-anthy-9000" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-appindicator3-0.1@workspace:types/node-appindicator3-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-appindicator3-0.1@workspace:types/node-appindicator3-0.1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-appstream-1.0@workspace:types/node-appstream-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-appstream-1.0@workspace:types/node-appstream-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-appstreambuilder-1.0@workspace:types/node-appstreambuilder-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-appstreambuilder-1.0@workspace:types/node-appstreambuilder-1.0" - dependencies: - "@girs/node-appstreamglib-1.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-appstreamglib-1.0@workspace:^, @girs/node-appstreamglib-1.0@workspace:types/node-appstreamglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-appstreamglib-1.0@workspace:types/node-appstreamglib-1.0" - dependencies: - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-arrow-1.0@workspace:^, @girs/node-arrow-1.0@workspace:types/node-arrow-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-arrow-1.0@workspace:types/node-arrow-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-arrowcuda-1.0@workspace:^, @girs/node-arrowcuda-1.0@workspace:types/node-arrowcuda-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-arrowcuda-1.0@workspace:types/node-arrowcuda-1.0" - dependencies: - "@girs/node-arrow-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-arrowdataset-1.0@workspace:types/node-arrowdataset-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-arrowdataset-1.0@workspace:types/node-arrowdataset-1.0" - dependencies: - "@girs/node-arrow-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-arrowflight-1.0@workspace:types/node-arrowflight-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-arrowflight-1.0@workspace:types/node-arrowflight-1.0" - dependencies: - "@girs/node-arrow-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-atk-1.0@workspace:^, @girs/node-atk-1.0@workspace:types/node-atk-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-atk-1.0@workspace:types/node-atk-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-atspi-2.0@workspace:types/node-atspi-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-atspi-2.0@workspace:types/node-atspi-2.0" - dependencies: - "@girs/node-dbus-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-babl-0.1@workspace:^, @girs/node-babl-0.1@workspace:types/node-babl-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-babl-0.1@workspace:types/node-babl-0.1" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-bamf-3@workspace:types/node-bamf-3": - version: 0.0.0-use.local - resolution: "@girs/node-bamf-3@workspace:types/node-bamf-3" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-builder-1.0@workspace:types/node-builder-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-builder-1.0@workspace:types/node-builder-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-dazzle-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-girepository-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-ide-1.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-peas-1.0": "workspace:^" - "@girs/node-template-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-bump-0.1@workspace:types/node-bump-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-bump-0.1@workspace:types/node-bump-0.1" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cairo-1.0@workspace:^, @girs/node-cairo-1.0@workspace:types/node-cairo-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-cairo-1.0@workspace:types/node-cairo-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cally-1.0@workspace:types/node-cally-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-cally-1.0@workspace:types/node-cally-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cally-10@workspace:types/node-cally-10": - version: 0.0.0-use.local - resolution: "@girs/node-cally-10@workspace:types/node-cally-10" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-10": "workspace:^" - "@girs/node-cogl-10": "workspace:^" - "@girs/node-coglpango-10": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cally-11@workspace:^, @girs/node-cally-11@workspace:types/node-cally-11": - version: 0.0.0-use.local - resolution: "@girs/node-cally-11@workspace:types/node-cally-11" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-11": "workspace:^" - "@girs/node-cogl-11": "workspace:^" - "@girs/node-coglpango-11": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cally-12@workspace:^, @girs/node-cally-12@workspace:types/node-cally-12": - version: 0.0.0-use.local - resolution: "@girs/node-cally-12@workspace:types/node-cally-12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-12": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-coglpango-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cally-13@workspace:^, @girs/node-cally-13@workspace:types/node-cally-13": - version: 0.0.0-use.local - resolution: "@girs/node-cally-13@workspace:types/node-cally-13" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-13": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-coglpango-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-mtk-13": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-camel-1.2@workspace:^, @girs/node-camel-1.2@workspace:types/node-camel-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-camel-1.2@workspace:types/node-camel-1.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-caribou-1.0@workspace:types/node-caribou-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-caribou-1.0@workspace:types/node-caribou-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-champlain-0.12@workspace:^, @girs/node-champlain-0.12@workspace:types/node-champlain-0.12": - version: 0.0.0-use.local - resolution: "@girs/node-champlain-0.12@workspace:types/node-champlain-0.12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cheese-3.0@workspace:types/node-cheese-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-cheese-3.0@workspace:types/node-cheese-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cloudproviders-0.3@workspace:types/node-cloudproviders-0.3": - version: 0.0.0-use.local - resolution: "@girs/node-cloudproviders-0.3@workspace:types/node-cloudproviders-0.3" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-clutter-1.0@workspace:^, @girs/node-clutter-1.0@workspace:types/node-clutter-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-clutter-1.0@workspace:types/node-clutter-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-clutter-10@workspace:^, @girs/node-clutter-10@workspace:types/node-clutter-10": - version: 0.0.0-use.local - resolution: "@girs/node-clutter-10@workspace:types/node-clutter-10" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-10": "workspace:^" - "@girs/node-coglpango-10": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-clutter-11@workspace:^, @girs/node-clutter-11@workspace:types/node-clutter-11": - version: 0.0.0-use.local - resolution: "@girs/node-clutter-11@workspace:types/node-clutter-11" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-11": "workspace:^" - "@girs/node-coglpango-11": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-clutter-12@workspace:^, @girs/node-clutter-12@workspace:types/node-clutter-12": - version: 0.0.0-use.local - resolution: "@girs/node-clutter-12@workspace:types/node-clutter-12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-coglpango-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-clutter-13@workspace:^, @girs/node-clutter-13@workspace:types/node-clutter-13": - version: 0.0.0-use.local - resolution: "@girs/node-clutter-13@workspace:types/node-clutter-13" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-coglpango-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-mtk-13": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cluttergdk-1.0@workspace:types/node-cluttergdk-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-cluttergdk-1.0@workspace:types/node-cluttergdk-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cluttergst-1.0@workspace:types/node-cluttergst-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-cluttergst-1.0@workspace:types/node-cluttergst-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gstaudio-0.10": "workspace:^" - "@girs/node-gstbase-0.10": "workspace:^" - "@girs/node-gstinterfaces-0.10": "workspace:^" - "@girs/node-gstvideo-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cluttergst-2.0@workspace:types/node-cluttergst-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-cluttergst-2.0@workspace:types/node-cluttergst-2.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cluttergst-3.0@workspace:types/node-cluttergst-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-cluttergst-3.0@workspace:types/node-cluttergst-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-clutterx11-1.0@workspace:types/node-clutterx11-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-clutterx11-1.0@workspace:types/node-clutterx11-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cogl-1.0@workspace:^, @girs/node-cogl-1.0@workspace:types/node-cogl-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-cogl-1.0@workspace:types/node-cogl-1.0" - dependencies: - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cogl-10@workspace:^, @girs/node-cogl-10@workspace:types/node-cogl-10": - version: 0.0.0-use.local - resolution: "@girs/node-cogl-10@workspace:types/node-cogl-10" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cogl-11@workspace:^, @girs/node-cogl-11@workspace:types/node-cogl-11": - version: 0.0.0-use.local - resolution: "@girs/node-cogl-11@workspace:types/node-cogl-11" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cogl-12@workspace:^, @girs/node-cogl-12@workspace:types/node-cogl-12": - version: 0.0.0-use.local - resolution: "@girs/node-cogl-12@workspace:types/node-cogl-12" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cogl-13@workspace:^, @girs/node-cogl-13@workspace:types/node-cogl-13": - version: 0.0.0-use.local - resolution: "@girs/node-cogl-13@workspace:types/node-cogl-13" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-cogl-2.0@workspace:^, @girs/node-cogl-2.0@workspace:types/node-cogl-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-cogl-2.0@workspace:types/node-cogl-2.0" - dependencies: - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglgst-2.0@workspace:types/node-coglgst-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-coglgst-2.0@workspace:types/node-coglgst-2.0" - dependencies: - "@girs/node-cogl-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglpango-1.0@workspace:^, @girs/node-coglpango-1.0@workspace:types/node-coglpango-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-coglpango-1.0@workspace:types/node-coglpango-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglpango-10@workspace:^, @girs/node-coglpango-10@workspace:types/node-coglpango-10": - version: 0.0.0-use.local - resolution: "@girs/node-coglpango-10@workspace:types/node-coglpango-10" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-10": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglpango-11@workspace:^, @girs/node-coglpango-11@workspace:types/node-coglpango-11": - version: 0.0.0-use.local - resolution: "@girs/node-coglpango-11@workspace:types/node-coglpango-11" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-11": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglpango-12@workspace:^, @girs/node-coglpango-12@workspace:types/node-coglpango-12": - version: 0.0.0-use.local - resolution: "@girs/node-coglpango-12@workspace:types/node-coglpango-12" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglpango-13@workspace:^, @girs/node-coglpango-13@workspace:types/node-coglpango-13": - version: 0.0.0-use.local - resolution: "@girs/node-coglpango-13@workspace:types/node-coglpango-13" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-coglpango-2.0@workspace:types/node-coglpango-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-coglpango-2.0@workspace:types/node-coglpango-2.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cogl-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-colord-1.0@workspace:^, @girs/node-colord-1.0@workspace:types/node-colord-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-colord-1.0@workspace:types/node-colord-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-colordgtk-1.0@workspace:types/node-colordgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-colordgtk-1.0@workspace:types/node-colordgtk-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-colord-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-colorhug-1.0@workspace:types/node-colorhug-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-colorhug-1.0@workspace:types/node-colorhug-1.0" - dependencies: - "@girs/node-colord-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gusb-1.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dazzle-1.0@workspace:^, @girs/node-dazzle-1.0@workspace:types/node-dazzle-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-dazzle-1.0@workspace:types/node-dazzle-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dbus-1.0@workspace:^, @girs/node-dbus-1.0@workspace:types/node-dbus-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-dbus-1.0@workspace:types/node-dbus-1.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dbusglib-1.0@workspace:^, @girs/node-dbusglib-1.0@workspace:types/node-dbusglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-dbusglib-1.0@workspace:types/node-dbusglib-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dbusmenu-0.4@workspace:^, @girs/node-dbusmenu-0.4@workspace:types/node-dbusmenu-0.4": - version: 0.0.0-use.local - resolution: "@girs/node-dbusmenu-0.4@workspace:types/node-dbusmenu-0.4" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dbusmenugtk-0.4@workspace:types/node-dbusmenugtk-0.4": - version: 0.0.0-use.local - resolution: "@girs/node-dbusmenugtk-0.4@workspace:types/node-dbusmenugtk-0.4" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-dbusmenu-0.4": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-2.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dbusmenugtk3-0.4@workspace:types/node-dbusmenugtk3-0.4": - version: 0.0.0-use.local - resolution: "@girs/node-dbusmenugtk3-0.4@workspace:types/node-dbusmenugtk3-0.4" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-dbusmenu-0.4": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dee-1.0@workspace:^, @girs/node-dee-1.0@workspace:types/node-dee-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-dee-1.0@workspace:types/node-dee-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-devhelp-3.0@workspace:types/node-devhelp-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-devhelp-3.0@workspace:types/node-devhelp-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-4.1": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - "@girs/node-webkit2-4.1": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dex-1@workspace:types/node-dex-1": - version: 0.0.0-use.local - resolution: "@girs/node-dex-1@workspace:types/node-dex-1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-dmap-3.0@workspace:types/node-dmap-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-dmap-3.0@workspace:types/node-dmap-3.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ebackend-1.2@workspace:^, @girs/node-ebackend-1.2@workspace:types/node-ebackend-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-ebackend-1.2@workspace:types/node-ebackend-1.2" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ebook-1.2@workspace:types/node-ebook-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-ebook-1.2@workspace:types/node-ebook-1.2" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ebookcontacts-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ebookcontacts-1.2@workspace:^, @girs/node-ebookcontacts-1.2@workspace:types/node-ebookcontacts-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-ebookcontacts-1.2@workspace:types/node-ebookcontacts-1.2" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ecal-2.0@workspace:^, @girs/node-ecal-2.0@workspace:types/node-ecal-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-ecal-2.0@workspace:types/node-ecal-2.0" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-icalglib-3.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ecalendar-1.2@workspace:types/node-ecalendar-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-ecalendar-1.2@workspace:types/node-ecalendar-1.2" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-edatabook-1.2@workspace:types/node-edatabook-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-edatabook-1.2@workspace:types/node-edatabook-1.2" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ebackend-1.2": "workspace:^" - "@girs/node-ebookcontacts-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-edatacal-2.0@workspace:types/node-edatacal-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-edatacal-2.0@workspace:types/node-edatacal-2.0" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ebackend-1.2": "workspace:^" - "@girs/node-ecal-2.0": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-icalglib-3.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-edataserver-1.2@workspace:^, @girs/node-edataserver-1.2@workspace:types/node-edataserver-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-edataserver-1.2@workspace:types/node-edataserver-1.2" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-edataserverui-1.2@workspace:types/node-edataserverui-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-edataserverui-1.2@workspace:types/node-edataserverui-1.2" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ecal-2.0": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-icalglib-3.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-edataserverui4-1.0@workspace:types/node-edataserverui4-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-edataserverui4-1.0@workspace:types/node-edataserverui4-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ecal-2.0": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-icalglib-3.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-egg-1.0@workspace:types/node-egg-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-egg-1.0@workspace:types/node-egg-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-eog-3.0@workspace:types/node-eog-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-eog-3.0@workspace:types/node-eog-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-epc-1.0@workspace:^, @girs/node-epc-1.0@workspace:types/node-epc-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-epc-1.0@workspace:types/node-epc-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-epcui-1.0@workspace:types/node-epcui-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-epcui-1.0@workspace:types/node-epcui-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-epc-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-evincedocument-3.0@workspace:^, @girs/node-evincedocument-3.0@workspace:types/node-evincedocument-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-evincedocument-3.0@workspace:types/node-evincedocument-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-evinceview-3.0@workspace:types/node-evinceview-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-evinceview-3.0@workspace:types/node-evinceview-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-evincedocument-3.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-farstream-0.1@workspace:types/node-farstream-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-farstream-0.1@workspace:types/node-farstream-0.1" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-farstream-0.2@workspace:^, @girs/node-farstream-0.2@workspace:types/node-farstream-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-farstream-0.2@workspace:types/node-farstream-0.2" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-flatpak-1.0@workspace:types/node-flatpak-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-flatpak-1.0@workspace:types/node-flatpak-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folks-0.6@workspace:^, @girs/node-folks-0.6@workspace:types/node-folks-0.6": - version: 0.0.0-use.local - resolution: "@girs/node-folks-0.6@workspace:types/node-folks-0.6" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folks-0.7@workspace:^, @girs/node-folks-0.7@workspace:types/node-folks-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-folks-0.7@workspace:types/node-folks-0.7" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folksdummy-0.6@workspace:types/node-folksdummy-0.6": - version: 0.0.0-use.local - resolution: "@girs/node-folksdummy-0.6@workspace:types/node-folksdummy-0.6" - dependencies: - "@girs/node-folks-0.6": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folksdummy-0.7@workspace:types/node-folksdummy-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-folksdummy-0.7@workspace:types/node-folksdummy-0.7" - dependencies: - "@girs/node-folks-0.7": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folkseds-0.6@workspace:types/node-folkseds-0.6": - version: 0.0.0-use.local - resolution: "@girs/node-folkseds-0.6@workspace:types/node-folkseds-0.6" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ebookcontacts-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-folks-0.6": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folkseds-0.7@workspace:types/node-folkseds-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-folkseds-0.7@workspace:types/node-folkseds-0.7" - dependencies: - "@girs/node-camel-1.2": "workspace:^" - "@girs/node-ebookcontacts-1.2": "workspace:^" - "@girs/node-edataserver-1.2": "workspace:^" - "@girs/node-folks-0.7": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folkslibsocialweb-0.6@workspace:types/node-folkslibsocialweb-0.6": - version: 0.0.0-use.local - resolution: "@girs/node-folkslibsocialweb-0.6@workspace:types/node-folkslibsocialweb-0.6" - dependencies: - "@girs/node-folks-0.6": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-socialwebclient-0.25": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folkstelepathy-0.6@workspace:types/node-folkstelepathy-0.6": - version: 0.0.0-use.local - resolution: "@girs/node-folkstelepathy-0.6@workspace:types/node-folkstelepathy-0.6" - dependencies: - "@girs/node-folks-0.6": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-folkstelepathy-0.7@workspace:types/node-folkstelepathy-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-folkstelepathy-0.7@workspace:types/node-folkstelepathy-0.7" - dependencies: - "@girs/node-folks-0.7": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-fontconfig-2.0@workspace:^, @girs/node-fontconfig-2.0@workspace:types/node-fontconfig-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-fontconfig-2.0@workspace:types/node-fontconfig-2.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-freetype2-2.0@workspace:^, @girs/node-freetype2-2.0@workspace:types/node-freetype2-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-freetype2-2.0@workspace:types/node-freetype2-2.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-fwupd-2.0@workspace:types/node-fwupd-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-fwupd-2.0@workspace:types/node-fwupd-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gandiva-1.0@workspace:types/node-gandiva-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gandiva-1.0@workspace:types/node-gandiva-1.0" - dependencies: - "@girs/node-arrow-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcab-1.0@workspace:types/node-gcab-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gcab-1.0@workspace:types/node-gcab-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcalc-1@workspace:types/node-gcalc-1": - version: 0.0.0-use.local - resolution: "@girs/node-gcalc-1@workspace:types/node-gcalc-1" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcalc-2@workspace:^, @girs/node-gcalc-2@workspace:types/node-gcalc-2": - version: 0.0.0-use.local - resolution: "@girs/node-gcalc-2@workspace:types/node-gcalc-2" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gck-1@workspace:^, @girs/node-gck-1@workspace:types/node-gck-1": - version: 0.0.0-use.local - resolution: "@girs/node-gck-1@workspace:types/node-gck-1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gck-2@workspace:^, @girs/node-gck-2@workspace:types/node-gck-2": - version: 0.0.0-use.local - resolution: "@girs/node-gck-2@workspace:types/node-gck-2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gconf-2.0@workspace:^, @girs/node-gconf-2.0@workspace:types/node-gconf-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gconf-2.0@workspace:types/node-gconf-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcr-3@workspace:^, @girs/node-gcr-3@workspace:types/node-gcr-3": - version: 0.0.0-use.local - resolution: "@girs/node-gcr-3@workspace:types/node-gcr-3" - dependencies: - "@girs/node-gck-1": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcr-4@workspace:^, @girs/node-gcr-4@workspace:types/node-gcr-4": - version: 0.0.0-use.local - resolution: "@girs/node-gcr-4@workspace:types/node-gcr-4" - dependencies: - "@girs/node-gck-2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcrgtk3-4@workspace:types/node-gcrgtk3-4": - version: 0.0.0-use.local - resolution: "@girs/node-gcrgtk3-4@workspace:types/node-gcrgtk3-4" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gck-2": "workspace:^" - "@girs/node-gcr-4": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcrgtk4-4@workspace:types/node-gcrgtk4-4": - version: 0.0.0-use.local - resolution: "@girs/node-gcrgtk4-4@workspace:types/node-gcrgtk4-4" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gck-2": "workspace:^" - "@girs/node-gcr-4": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gcrui-3@workspace:types/node-gcrui-3": - version: 0.0.0-use.local - resolution: "@girs/node-gcrui-3@workspace:types/node-gcrui-3" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gck-1": "workspace:^" - "@girs/node-gcr-3": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gd-1.0@workspace:types/node-gd-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gd-1.0@workspace:types/node-gd-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gda-5.0@workspace:^, @girs/node-gda-5.0@workspace:types/node-gda-5.0": - version: 0.0.0-use.local - resolution: "@girs/node-gda-5.0@workspace:types/node-gda-5.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gda-6.0@workspace:^, @girs/node-gda-6.0@workspace:types/node-gda-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-gda-6.0@workspace:types/node-gda-6.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdata-0.0@workspace:types/node-gdata-0.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdata-0.0@workspace:types/node-gdata-0.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-goa-1.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdaui-5.0@workspace:types/node-gdaui-5.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdaui-5.0@workspace:types/node-gdaui-5.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gda-5.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdaui-6.0@workspace:types/node-gdaui-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdaui-6.0@workspace:types/node-gdaui-6.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gda-6.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdesktopenums-3.0@workspace:^, @girs/node-gdesktopenums-3.0@workspace:types/node-gdesktopenums-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdesktopenums-3.0@workspace:types/node-gdesktopenums-3.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdk-2.0@workspace:^, @girs/node-gdk-2.0@workspace:types/node-gdk-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdk-2.0@workspace:types/node-gdk-2.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdk-3.0@workspace:^, @girs/node-gdk-3.0@workspace:types/node-gdk-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdk-3.0@workspace:types/node-gdk-3.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdk-4.0@workspace:^, @girs/node-gdk-4.0@workspace:types/node-gdk-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdk-4.0@workspace:types/node-gdk-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdkpixbuf-2.0@workspace:^, @girs/node-gdkpixbuf-2.0@workspace:types/node-gdkpixbuf-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdkpixbuf-2.0@workspace:types/node-gdkpixbuf-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdkpixdata-2.0@workspace:types/node-gdkpixdata-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdkpixdata-2.0@workspace:types/node-gdkpixdata-2.0" - dependencies: - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdkwayland-4.0@workspace:types/node-gdkwayland-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdkwayland-4.0@workspace:types/node-gdkwayland-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdkx11-2.0@workspace:types/node-gdkx11-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdkx11-2.0@workspace:types/node-gdkx11-2.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdkx11-3.0@workspace:types/node-gdkx11-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdkx11-3.0@workspace:types/node-gdkx11-3.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdkx11-4.0@workspace:types/node-gdkx11-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdkx11-4.0@workspace:types/node-gdkx11-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdl-3@workspace:^, @girs/node-gdl-3@workspace:types/node-gdl-3": - version: 0.0.0-use.local - resolution: "@girs/node-gdl-3@workspace:types/node-gdl-3" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gdm-1.0@workspace:types/node-gdm-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gdm-1.0@workspace:types/node-gdm-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gedit-3.0@workspace:types/node-gedit-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gedit-3.0@workspace:types/node-gedit-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-4": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gee-0.8@workspace:^, @girs/node-gee-0.8@workspace:types/node-gee-0.8": - version: 0.0.0-use.local - resolution: "@girs/node-gee-0.8@workspace:types/node-gee-0.8" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gee-1.0@workspace:types/node-gee-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gee-1.0@workspace:types/node-gee-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gegl-0.3@workspace:types/node-gegl-0.3": - version: 0.0.0-use.local - resolution: "@girs/node-gegl-0.3@workspace:types/node-gegl-0.3" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gegl-0.4@workspace:^, @girs/node-gegl-0.4@workspace:types/node-gegl-0.4": - version: 0.0.0-use.local - resolution: "@girs/node-gegl-0.4@workspace:types/node-gegl-0.4" - dependencies: - "@girs/node-babl-0.1": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-geglgtk3-0.1@workspace:types/node-geglgtk3-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-geglgtk3-0.1@workspace:types/node-geglgtk3-0.1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-babl-0.1": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gegl-0.4": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-geoclue-2.0@workspace:types/node-geoclue-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-geoclue-2.0@workspace:types/node-geoclue-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-geocodeglib-1.0@workspace:^, @girs/node-geocodeglib-1.0@workspace:types/node-geocodeglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-geocodeglib-1.0@workspace:types/node-geocodeglib-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-geocodeglib-2.0@workspace:types/node-geocodeglib-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-geocodeglib-2.0@workspace:types/node-geocodeglib-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gepub-0.5@workspace:types/node-gepub-0.5": - version: 0.0.0-use.local - resolution: "@girs/node-gepub-0.5@workspace:types/node-gepub-0.5" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-4.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - "@girs/node-webkit2-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ges-1.0@workspace:types/node-ges-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-ges-1.0@workspace:types/node-ges-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gexiv2-0.10@workspace:types/node-gexiv2-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gexiv2-0.10@workspace:types/node-gexiv2-0.10" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gfbgraph-0.2@workspace:types/node-gfbgraph-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-gfbgraph-0.2@workspace:types/node-gfbgraph-0.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-rest-0.7": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gfbgraph-0.3@workspace:types/node-gfbgraph-0.3": - version: 0.0.0-use.local - resolution: "@girs/node-gfbgraph-0.3@workspace:types/node-gfbgraph-0.3" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-rest-0.7": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ggit-1.0@workspace:^, @girs/node-ggit-1.0@workspace:types/node-ggit-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-ggit-1.0@workspace:types/node-ggit-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gio-2.0@workspace:^, @girs/node-gio-2.0@workspace:types/node-gio-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gio-2.0@workspace:types/node-gio-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-girepository-2.0@workspace:^, @girs/node-girepository-2.0@workspace:types/node-girepository-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-girepository-2.0@workspace:types/node-girepository-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gitg-1.0@workspace:^, @girs/node-gitg-1.0@workspace:types/node-gitg-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gitg-1.0@workspace:types/node-gitg-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-ggit-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gitgext-1.0@workspace:types/node-gitgext-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gitgext-1.0@workspace:types/node-gitgext-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-ggit-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gitg-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gjsdbus-1.0@workspace:types/node-gjsdbus-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gjsdbus-1.0@workspace:types/node-gjsdbus-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gkbd-3.0@workspace:types/node-gkbd-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gkbd-3.0@workspace:types/node-gkbd-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xkl-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gl-1.0@workspace:^, @girs/node-gl-1.0@workspace:types/node-gl-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gl-1.0@workspace:types/node-gl-1.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gladeui-2.0@workspace:types/node-gladeui-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gladeui-2.0@workspace:types/node-gladeui-2.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-glib-2.0@workspace:^, @girs/node-glib-2.0@workspace:types/node-glib-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-glib-2.0@workspace:types/node-glib-2.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gmenu-3.0@workspace:types/node-gmenu-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gmenu-3.0@workspace:types/node-gmenu-3.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gmime-3.0@workspace:types/node-gmime-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gmime-3.0@workspace:types/node-gmime-3.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gmodule-2.0@workspace:^, @girs/node-gmodule-2.0@workspace:types/node-gmodule-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gmodule-2.0@workspace:types/node-gmodule-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomeautoar-0.1@workspace:^, @girs/node-gnomeautoar-0.1@workspace:types/node-gnomeautoar-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-gnomeautoar-0.1@workspace:types/node-gnomeautoar-0.1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomeautoargtk-0.1@workspace:types/node-gnomeautoargtk-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-gnomeautoargtk-0.1@workspace:types/node-gnomeautoargtk-0.1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gnomeautoar-0.1": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomebg-4.0@workspace:types/node-gnomebg-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomebg-4.0@workspace:types/node-gnomebg-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gnomedesktop-4.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomebluetooth-1.0@workspace:types/node-gnomebluetooth-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomebluetooth-1.0@workspace:types/node-gnomebluetooth-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomebluetooth-3.0@workspace:types/node-gnomebluetooth-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomebluetooth-3.0@workspace:types/node-gnomebluetooth-3.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomedesktop-3.0@workspace:types/node-gnomedesktop-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomedesktop-3.0@workspace:types/node-gnomedesktop-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomedesktop-4.0@workspace:^, @girs/node-gnomedesktop-4.0@workspace:types/node-gnomedesktop-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomedesktop-4.0@workspace:types/node-gnomedesktop-4.0" - dependencies: - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomekeyring-1.0@workspace:types/node-gnomekeyring-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomekeyring-1.0@workspace:types/node-gnomekeyring-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomemaps-1.0@workspace:types/node-gnomemaps-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomemaps-1.0@workspace:types/node-gnomemaps-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-champlain-0.12": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-geocodeglib-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-rest-0.7": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gnomerr-4.0@workspace:types/node-gnomerr-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gnomerr-4.0@workspace:types/node-gnomerr-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gnomedesktop-4.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-goa-1.0@workspace:^, @girs/node-goa-1.0@workspace:types/node-goa-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-goa-1.0@workspace:types/node-goa-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gobject-2.0@workspace:^, @girs/node-gobject-2.0@workspace:types/node-gobject-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gobject-2.0@workspace:types/node-gobject-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-goocanvas-2.0@workspace:types/node-goocanvas-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-goocanvas-2.0@workspace:types/node-goocanvas-2.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-goocanvas-3.0@workspace:types/node-goocanvas-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-goocanvas-3.0@workspace:types/node-goocanvas-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-govirt-1.0@workspace:types/node-govirt-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-govirt-1.0@workspace:types/node-govirt-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-rest-0.7": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gpseq-1.0@workspace:types/node-gpseq-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gpseq-1.0@workspace:types/node-gpseq-1.0" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-granite-1.0@workspace:types/node-granite-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-granite-1.0@workspace:types/node-granite-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-granite-7.0@workspace:types/node-granite-7.0": - version: 0.0.0-use.local - resolution: "@girs/node-granite-7.0@workspace:types/node-granite-7.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-graphene-1.0@workspace:^, @girs/node-graphene-1.0@workspace:types/node-graphene-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-graphene-1.0@workspace:types/node-graphene-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grl-0.1@workspace:types/node-grl-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-grl-0.1@workspace:types/node-grl-0.1" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grl-0.2@workspace:^, @girs/node-grl-0.2@workspace:types/node-grl-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-grl-0.2@workspace:types/node-grl-0.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grl-0.3@workspace:^, @girs/node-grl-0.3@workspace:types/node-grl-0.3": - version: 0.0.0-use.local - resolution: "@girs/node-grl-0.3@workspace:types/node-grl-0.3" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grlnet-0.1@workspace:types/node-grlnet-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-grlnet-0.1@workspace:types/node-grlnet-0.1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grlnet-0.2@workspace:types/node-grlnet-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-grlnet-0.2@workspace:types/node-grlnet-0.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grlnet-0.3@workspace:types/node-grlnet-0.3": - version: 0.0.0-use.local - resolution: "@girs/node-grlnet-0.3@workspace:types/node-grlnet-0.3" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grlpls-0.2@workspace:types/node-grlpls-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-grlpls-0.2@workspace:types/node-grlpls-0.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-grl-0.2": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grlpls-0.3@workspace:types/node-grlpls-0.3": - version: 0.0.0-use.local - resolution: "@girs/node-grlpls-0.3@workspace:types/node-grlpls-0.3" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-grl-0.3": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-grss-0.7@workspace:types/node-grss-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-grss-0.7@workspace:types/node-grss-0.7" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsf-1@workspace:types/node-gsf-1": - version: 0.0.0-use.local - resolution: "@girs/node-gsf-1@workspace:types/node-gsf-1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsignon-1.0@workspace:types/node-gsignon-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsignon-1.0@workspace:types/node-gsignon-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsignond-1.0@workspace:types/node-gsignond-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsignond-1.0@workspace:types/node-gsignond-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsk-4.0@workspace:^, @girs/node-gsk-4.0@workspace:types/node-gsk-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsk-4.0@workspace:types/node-gsk-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsound-1.0@workspace:types/node-gsound-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsound-1.0@workspace:types/node-gsound-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gspell-1@workspace:types/node-gspell-1": - version: 0.0.0-use.local - resolution: "@girs/node-gspell-1@workspace:types/node-gspell-1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gssdp-1.0@workspace:^, @girs/node-gssdp-1.0@workspace:types/node-gssdp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gssdp-1.0@workspace:types/node-gssdp-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gssdp-1.2@workspace:^, @girs/node-gssdp-1.2@workspace:types/node-gssdp-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-gssdp-1.2@workspace:types/node-gssdp-1.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gssdp-1.6@workspace:^, @girs/node-gssdp-1.6@workspace:types/node-gssdp-1.6": - version: 0.0.0-use.local - resolution: "@girs/node-gssdp-1.6@workspace:types/node-gssdp-1.6" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gst-0.10@workspace:^, @girs/node-gst-0.10@workspace:types/node-gst-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gst-0.10@workspace:types/node-gst-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gst-1.0@workspace:^, @girs/node-gst-1.0@workspace:types/node-gst-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gst-1.0@workspace:types/node-gst-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstallocators-1.0@workspace:types/node-gstallocators-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstallocators-1.0@workspace:types/node-gstallocators-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstapp-1.0@workspace:types/node-gstapp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstapp-1.0@workspace:types/node-gstapp-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstaudio-0.10@workspace:^, @girs/node-gstaudio-0.10@workspace:types/node-gstaudio-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gstaudio-0.10@workspace:types/node-gstaudio-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gstbase-0.10": "workspace:^" - "@girs/node-gstinterfaces-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstaudio-1.0@workspace:^, @girs/node-gstaudio-1.0@workspace:types/node-gstaudio-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstaudio-1.0@workspace:types/node-gstaudio-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstbadallocators-1.0@workspace:types/node-gstbadallocators-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstbadallocators-1.0@workspace:types/node-gstbadallocators-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstbadaudio-1.0@workspace:types/node-gstbadaudio-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstbadaudio-1.0@workspace:types/node-gstbadaudio-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstbase-0.10@workspace:^, @girs/node-gstbase-0.10@workspace:types/node-gstbase-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gstbase-0.10@workspace:types/node-gstbase-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstbase-1.0@workspace:^, @girs/node-gstbase-1.0@workspace:types/node-gstbase-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstbase-1.0@workspace:types/node-gstbase-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstcheck-1.0@workspace:types/node-gstcheck-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstcheck-1.0@workspace:types/node-gstcheck-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstcodecs-1.0@workspace:types/node-gstcodecs-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstcodecs-1.0@workspace:types/node-gstcodecs-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstcontroller-1.0@workspace:types/node-gstcontroller-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstcontroller-1.0@workspace:types/node-gstcontroller-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstfft-1.0@workspace:types/node-gstfft-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstfft-1.0@workspace:types/node-gstfft-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstgl-1.0@workspace:^, @girs/node-gstgl-1.0@workspace:types/node-gstgl-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstgl-1.0@workspace:types/node-gstgl-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstglegl-1.0@workspace:types/node-gstglegl-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstglegl-1.0@workspace:types/node-gstglegl-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstgl-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstglwayland-1.0@workspace:types/node-gstglwayland-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstglwayland-1.0@workspace:types/node-gstglwayland-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstgl-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstglx11-1.0@workspace:types/node-gstglx11-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstglx11-1.0@workspace:types/node-gstglx11-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstgl-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstinsertbin-1.0@workspace:types/node-gstinsertbin-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstinsertbin-1.0@workspace:types/node-gstinsertbin-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstinterfaces-0.10@workspace:^, @girs/node-gstinterfaces-0.10@workspace:types/node-gstinterfaces-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gstinterfaces-0.10@workspace:types/node-gstinterfaces-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstmpegts-1.0@workspace:types/node-gstmpegts-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstmpegts-1.0@workspace:types/node-gstmpegts-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstnet-1.0@workspace:^, @girs/node-gstnet-1.0@workspace:types/node-gstnet-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstnet-1.0@workspace:types/node-gstnet-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstpbutils-0.10@workspace:^, @girs/node-gstpbutils-0.10@workspace:types/node-gstpbutils-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gstpbutils-0.10@workspace:types/node-gstpbutils-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstpbutils-1.0@workspace:^, @girs/node-gstpbutils-1.0@workspace:types/node-gstpbutils-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstpbutils-1.0@workspace:types/node-gstpbutils-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstplay-1.0@workspace:types/node-gstplay-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstplay-1.0@workspace:types/node-gstplay-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gsttag-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstplayer-1.0@workspace:types/node-gstplayer-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstplayer-1.0@workspace:types/node-gstplayer-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gsttag-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstriff-1.0@workspace:types/node-gstriff-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstriff-1.0@workspace:types/node-gstriff-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstrtp-1.0@workspace:types/node-gstrtp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstrtp-1.0@workspace:types/node-gstrtp-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstrtsp-1.0@workspace:^, @girs/node-gstrtsp-1.0@workspace:types/node-gstrtsp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstrtsp-1.0@workspace:types/node-gstrtsp-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstsdp-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstrtspserver-1.0@workspace:types/node-gstrtspserver-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstrtspserver-1.0@workspace:types/node-gstrtspserver-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstnet-1.0": "workspace:^" - "@girs/node-gstrtsp-1.0": "workspace:^" - "@girs/node-gstsdp-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstsdp-1.0@workspace:^, @girs/node-gstsdp-1.0@workspace:types/node-gstsdp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstsdp-1.0@workspace:types/node-gstsdp-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsttag-0.10@workspace:^, @girs/node-gsttag-0.10@workspace:types/node-gsttag-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gsttag-0.10@workspace:types/node-gsttag-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsttag-1.0@workspace:^, @girs/node-gsttag-1.0@workspace:types/node-gsttag-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsttag-1.0@workspace:types/node-gsttag-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsttranscoder-1.0@workspace:types/node-gsttranscoder-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsttranscoder-1.0@workspace:types/node-gsttranscoder-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstvideo-0.10@workspace:^, @girs/node-gstvideo-0.10@workspace:types/node-gstvideo-0.10": - version: 0.0.0-use.local - resolution: "@girs/node-gstvideo-0.10@workspace:types/node-gstvideo-0.10" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gstbase-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstvideo-1.0@workspace:^, @girs/node-gstvideo-1.0@workspace:types/node-gstvideo-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstvideo-1.0@workspace:types/node-gstvideo-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstvulkan-1.0@workspace:types/node-gstvulkan-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstvulkan-1.0@workspace:types/node-gstvulkan-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-vulkan-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gstwebrtc-1.0@workspace:types/node-gstwebrtc-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gstwebrtc-1.0@workspace:types/node-gstwebrtc-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstsdp-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gsystem-1.0@workspace:types/node-gsystem-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gsystem-1.0@workspace:types/node-gsystem-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtef-2@workspace:types/node-gtef-2": - version: 0.0.0-use.local - resolution: "@girs/node-gtef-2@workspace:types/node-gtef-2" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtk-2.0@workspace:^, @girs/node-gtk-2.0@workspace:types/node-gtk-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtk-2.0@workspace:types/node-gtk-2.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtk-3.0@workspace:^, @girs/node-gtk-3.0@workspace:types/node-gtk-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtk-3.0@workspace:types/node-gtk-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtk-4.0@workspace:^, @girs/node-gtk-4.0@workspace:types/node-gtk-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtk-4.0@workspace:types/node-gtk-4.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtk@workspace:^, @girs/node-gtk@workspace:types/node-gtk": - version: 0.0.0-use.local - resolution: "@girs/node-gtk@workspace:types/node-gtk" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtkchamplain-0.12@workspace:types/node-gtkchamplain-0.12": - version: 0.0.0-use.local - resolution: "@girs/node-gtkchamplain-0.12@workspace:types/node-gtkchamplain-0.12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-champlain-0.12": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtkclutter-1.0@workspace:types/node-gtkclutter-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtkclutter-1.0@workspace:types/node-gtkclutter-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtksource-3.0@workspace:^, @girs/node-gtksource-3.0@workspace:types/node-gtksource-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtksource-3.0@workspace:types/node-gtksource-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtksource-4@workspace:^, @girs/node-gtksource-4@workspace:types/node-gtksource-4": - version: 0.0.0-use.local - resolution: "@girs/node-gtksource-4@workspace:types/node-gtksource-4" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtksource-5@workspace:types/node-gtksource-5": - version: 0.0.0-use.local - resolution: "@girs/node-gtksource-5@workspace:types/node-gtksource-5" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtkvnc-2.0@workspace:types/node-gtkvnc-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtkvnc-2.0@workspace:types/node-gtkvnc-2.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gvnc-1.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gtop-2.0@workspace:types/node-gtop-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gtop-2.0@workspace:types/node-gtop-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gucharmap-2.90@workspace:types/node-gucharmap-2.90": - version: 0.0.0-use.local - resolution: "@girs/node-gucharmap-2.90@workspace:types/node-gucharmap-2.90" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gudev-1.0@workspace:^, @girs/node-gudev-1.0@workspace:types/node-gudev-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gudev-1.0@workspace:types/node-gudev-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-guestfs-1.0@workspace:types/node-guestfs-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-guestfs-1.0@workspace:types/node-guestfs-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnp-1.0@workspace:types/node-gupnp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gupnp-1.0@workspace:types/node-gupnp-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnp-1.2@workspace:^, @girs/node-gupnp-1.2@workspace:types/node-gupnp-1.2": - version: 0.0.0-use.local - resolution: "@girs/node-gupnp-1.2@workspace:types/node-gupnp-1.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.2": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnp-1.6@workspace:^, @girs/node-gupnp-1.6@workspace:types/node-gupnp-1.6": - version: 0.0.0-use.local - resolution: "@girs/node-gupnp-1.6@workspace:types/node-gupnp-1.6" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.6": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnpav-1.0@workspace:^, @girs/node-gupnpav-1.0@workspace:types/node-gupnpav-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gupnpav-1.0@workspace:types/node-gupnpav-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnpdlna-1.0@workspace:types/node-gupnpdlna-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gupnpdlna-1.0@workspace:types/node-gupnpdlna-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnpdlna-2.0@workspace:^, @girs/node-gupnpdlna-2.0@workspace:types/node-gupnpdlna-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gupnpdlna-2.0@workspace:types/node-gupnpdlna-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnpdlnagst-2.0@workspace:types/node-gupnpdlnagst-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-gupnpdlnagst-2.0@workspace:types/node-gupnpdlnagst-2.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstaudio-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gstpbutils-1.0": "workspace:^" - "@girs/node-gstvideo-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnpdlna-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gupnpigd-1.0@workspace:types/node-gupnpigd-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gupnpigd-1.0@workspace:types/node-gupnpigd-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gusb-1.0@workspace:^, @girs/node-gusb-1.0@workspace:types/node-gusb-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gusb-1.0@workspace:types/node-gusb-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gvc-1.0@workspace:^, @girs/node-gvc-1.0@workspace:types/node-gvc-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gvc-1.0@workspace:types/node-gvc-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gvnc-1.0@workspace:^, @girs/node-gvnc-1.0@workspace:types/node-gvnc-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gvnc-1.0@workspace:types/node-gvnc-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gvncpulse-1.0@workspace:types/node-gvncpulse-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gvncpulse-1.0@workspace:types/node-gvncpulse-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gvnc-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gweather-3.0@workspace:types/node-gweather-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-gweather-3.0@workspace:types/node-gweather-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gweather-4.0@workspace:types/node-gweather-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-gweather-4.0@workspace:types/node-gweather-4.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gxml-0.14@workspace:types/node-gxml-0.14": - version: 0.0.0-use.local - resolution: "@girs/node-gxml-0.14@workspace:types/node-gxml-0.14" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gxml-0.16@workspace:types/node-gxml-0.16": - version: 0.0.0-use.local - resolution: "@girs/node-gxml-0.16@workspace:types/node-gxml-0.16" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gxml-0.18@workspace:types/node-gxml-0.18": - version: 0.0.0-use.local - resolution: "@girs/node-gxml-0.18@workspace:types/node-gxml-0.18" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gxml-0.20@workspace:^, @girs/node-gxml-0.20@workspace:types/node-gxml-0.20": - version: 0.0.0-use.local - resolution: "@girs/node-gxml-0.20@workspace:types/node-gxml-0.20" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gxps-0.1@workspace:types/node-gxps-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-gxps-0.1@workspace:types/node-gxps-0.1" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-gxps-1.0@workspace:types/node-gxps-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-gxps-1.0@workspace:types/node-gxps-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-handy-0.0@workspace:types/node-handy-0.0": - version: 0.0.0-use.local - resolution: "@girs/node-handy-0.0@workspace:types/node-handy-0.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-handy-1@workspace:types/node-handy-1": - version: 0.0.0-use.local - resolution: "@girs/node-handy-1@workspace:types/node-handy-1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-harfbuzz-0.0@workspace:^, @girs/node-harfbuzz-0.0@workspace:types/node-harfbuzz-0.0": - version: 0.0.0-use.local - resolution: "@girs/node-harfbuzz-0.0@workspace:types/node-harfbuzz-0.0" - dependencies: - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ianjuta-3.0@workspace:types/node-ianjuta-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-ianjuta-3.0@workspace:types/node-ianjuta-3.0" - dependencies: - "@girs/node-anjuta-3.0": "workspace:^" - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gdl-3": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ibus-1.0@workspace:types/node-ibus-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-ibus-1.0@workspace:types/node-ibus-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ical-3.0@workspace:types/node-ical-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-ical-3.0@workspace:types/node-ical-3.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-icalglib-3.0@workspace:^, @girs/node-icalglib-3.0@workspace:types/node-icalglib-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-icalglib-3.0@workspace:types/node-icalglib-3.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ide-1.0@workspace:^, @girs/node-ide-1.0@workspace:types/node-ide-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-ide-1.0@workspace:types/node-ide-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-dazzle-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-girepository-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-peas-1.0": "workspace:^" - "@girs/node-template-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-javascriptcore-4.0@workspace:^, @girs/node-javascriptcore-4.0@workspace:types/node-javascriptcore-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-javascriptcore-4.0@workspace:types/node-javascriptcore-4.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-javascriptcore-4.1@workspace:^, @girs/node-javascriptcore-4.1@workspace:types/node-javascriptcore-4.1": - version: 0.0.0-use.local - resolution: "@girs/node-javascriptcore-4.1@workspace:types/node-javascriptcore-4.1" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-javascriptcore-5.0@workspace:^, @girs/node-javascriptcore-5.0@workspace:types/node-javascriptcore-5.0": - version: 0.0.0-use.local - resolution: "@girs/node-javascriptcore-5.0@workspace:types/node-javascriptcore-5.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-javascriptcore-6.0@workspace:^, @girs/node-javascriptcore-6.0@workspace:types/node-javascriptcore-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-javascriptcore-6.0@workspace:types/node-javascriptcore-6.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-jscore-3.0@workspace:types/node-jscore-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-jscore-3.0@workspace:types/node-jscore-3.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-json-1.0@workspace:^, @girs/node-json-1.0@workspace:types/node-json-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-json-1.0@workspace:types/node-json-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-jsonrpc-1.0@workspace:types/node-jsonrpc-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-jsonrpc-1.0@workspace:types/node-jsonrpc-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-libmsi-1.0@workspace:types/node-libmsi-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-libmsi-1.0@workspace:types/node-libmsi-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-libosinfo-1.0@workspace:types/node-libosinfo-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-libosinfo-1.0@workspace:types/node-libosinfo-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-libvirtgconfig-1.0@workspace:^, @girs/node-libvirtgconfig-1.0@workspace:types/node-libvirtgconfig-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-libvirtgconfig-1.0@workspace:types/node-libvirtgconfig-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-libvirtglib-1.0@workspace:^, @girs/node-libvirtglib-1.0@workspace:types/node-libvirtglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-libvirtglib-1.0@workspace:types/node-libvirtglib-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-libvirtgobject-1.0@workspace:types/node-libvirtgobject-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-libvirtgobject-1.0@workspace:types/node-libvirtgobject-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libvirtgconfig-1.0": "workspace:^" - "@girs/node-libvirtglib-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-libxml2-2.0@workspace:^, @girs/node-libxml2-2.0@workspace:types/node-libxml2-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-libxml2-2.0@workspace:types/node-libxml2-2.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-manette-0.2@workspace:types/node-manette-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-manette-0.2@workspace:types/node-manette-0.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gudev-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mash-0.2@workspace:types/node-mash-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-mash-0.2@workspace:types/node-mash-0.2" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - "@girs/node-pangoft2-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mbim-1.0@workspace:types/node-mbim-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-mbim-1.0@workspace:types/node-mbim-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mediaart-1.0@workspace:types/node-mediaart-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-mediaart-1.0@workspace:types/node-mediaart-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mediaart-2.0@workspace:types/node-mediaart-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-mediaart-2.0@workspace:types/node-mediaart-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-meta-10@workspace:types/node-meta-10": - version: 0.0.0-use.local - resolution: "@girs/node-meta-10@workspace:types/node-meta-10" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-10": "workspace:^" - "@girs/node-cogl-10": "workspace:^" - "@girs/node-coglpango-10": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-meta-11@workspace:^, @girs/node-meta-11@workspace:types/node-meta-11": - version: 0.0.0-use.local - resolution: "@girs/node-meta-11@workspace:types/node-meta-11" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-11": "workspace:^" - "@girs/node-cogl-11": "workspace:^" - "@girs/node-coglpango-11": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-meta-12@workspace:^, @girs/node-meta-12@workspace:types/node-meta-12": - version: 0.0.0-use.local - resolution: "@girs/node-meta-12@workspace:types/node-meta-12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-12": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-coglpango-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-meta-13@workspace:^, @girs/node-meta-13@workspace:types/node-meta-13": - version: 0.0.0-use.local - resolution: "@girs/node-meta-13@workspace:types/node-meta-13" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-13": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-coglpango-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-mtk-13": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-metatest-12@workspace:types/node-metatest-12": - version: 0.0.0-use.local - resolution: "@girs/node-metatest-12@workspace:types/node-metatest-12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-12": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-coglpango-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-12": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-metatest-13@workspace:types/node-metatest-13": - version: 0.0.0-use.local - resolution: "@girs/node-metatest-13@workspace:types/node-metatest-13" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-13": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-coglpango-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-13": "workspace:^" - "@girs/node-mtk-13": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-modemmanager-1.0@workspace:types/node-modemmanager-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-modemmanager-1.0@workspace:types/node-modemmanager-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mtk-13@workspace:^, @girs/node-mtk-13@workspace:types/node-mtk-13": - version: 0.0.0-use.local - resolution: "@girs/node-mtk-13@workspace:types/node-mtk-13" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mx-1.0@workspace:types/node-mx-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-mx-1.0@workspace:types/node-mx-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - "@girs/node-pangoft2-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mx-2.0@workspace:types/node-mx-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-mx-2.0@workspace:types/node-mx-2.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - "@girs/node-pangoft2-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-mxgtk-1.0@workspace:types/node-mxgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-mxgtk-1.0@workspace:types/node-mxgtk-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-2.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-2.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-nautilus-3.0@workspace:types/node-nautilus-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-nautilus-3.0@workspace:types/node-nautilus-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-networkmanager-1.0@workspace:^, @girs/node-networkmanager-1.0@workspace:types/node-networkmanager-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-networkmanager-1.0@workspace:types/node-networkmanager-1.0" - dependencies: - "@girs/node-dbusglib-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-nice-0.1@workspace:types/node-nice-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-nice-0.1@workspace:types/node-nice-0.1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-nm-1.0@workspace:^, @girs/node-nm-1.0@workspace:types/node-nm-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-nm-1.0@workspace:types/node-nm-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-nma-1.0@workspace:types/node-nma-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-nma-1.0@workspace:types/node-nma-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-nm-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-nmclient-1.0@workspace:^, @girs/node-nmclient-1.0@workspace:types/node-nmclient-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-nmclient-1.0@workspace:types/node-nmclient-1.0" - dependencies: - "@girs/node-dbusglib-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-networkmanager-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-nmgtk-1.0@workspace:types/node-nmgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-nmgtk-1.0@workspace:types/node-nmgtk-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-dbusglib-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-networkmanager-1.0": "workspace:^" - "@girs/node-nmclient-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-notify-0.7@workspace:types/node-notify-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-notify-0.7@workspace:types/node-notify-0.7" - dependencies: - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-ostree-1.0@workspace:types/node-ostree-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-ostree-1.0@workspace:types/node-ostree-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-p11kit-1.0@workspace:types/node-p11kit-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-p11kit-1.0@workspace:types/node-p11kit-1.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-packagekitglib-1.0@workspace:^, @girs/node-packagekitglib-1.0@workspace:types/node-packagekitglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-packagekitglib-1.0@workspace:types/node-packagekitglib-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-packagekitplugin-1.0@workspace:types/node-packagekitplugin-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-packagekitplugin-1.0@workspace:types/node-packagekitplugin-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-packagekitglib-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-panelapplet-4.0@workspace:types/node-panelapplet-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-panelapplet-4.0@workspace:types/node-panelapplet-4.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gconf-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pango-1.0@workspace:^, @girs/node-pango-1.0@workspace:types/node-pango-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pango-1.0@workspace:types/node-pango-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pangocairo-1.0@workspace:^, @girs/node-pangocairo-1.0@workspace:types/node-pangocairo-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pangocairo-1.0@workspace:types/node-pangocairo-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pangofc-1.0@workspace:^, @girs/node-pangofc-1.0@workspace:types/node-pangofc-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pangofc-1.0@workspace:types/node-pangofc-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pangoft2-1.0@workspace:^, @girs/node-pangoft2-1.0@workspace:types/node-pangoft2-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pangoft2-1.0@workspace:types/node-pangoft2-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pangoot-1.0@workspace:^, @girs/node-pangoot-1.0@workspace:types/node-pangoot-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pangoot-1.0@workspace:types/node-pangoot-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pangoxft-1.0@workspace:types/node-pangoxft-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pangoxft-1.0@workspace:types/node-pangoxft-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - "@girs/node-pangoft2-1.0": "workspace:^" - "@girs/node-pangoot-1.0": "workspace:^" - "@girs/node-xft-2.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-parquet-1.0@workspace:types/node-parquet-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-parquet-1.0@workspace:types/node-parquet-1.0" - dependencies: - "@girs/node-arrow-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-peas-1.0@workspace:^, @girs/node-peas-1.0@workspace:types/node-peas-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-peas-1.0@workspace:types/node-peas-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-girepository-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-peas-2@workspace:types/node-peas-2": - version: 0.0.0-use.local - resolution: "@girs/node-peas-2@workspace:types/node-peas-2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-peasgtk-1.0@workspace:types/node-peasgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-peasgtk-1.0@workspace:types/node-peasgtk-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-girepository-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-peas-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-plasma-1.0@workspace:types/node-plasma-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-plasma-1.0@workspace:types/node-plasma-1.0" - dependencies: - "@girs/node-arrow-1.0": "workspace:^" - "@girs/node-arrowcuda-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-pnl-1.0@workspace:types/node-pnl-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-pnl-1.0@workspace:types/node-pnl-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-polkit-1.0@workspace:^, @girs/node-polkit-1.0@workspace:types/node-polkit-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-polkit-1.0@workspace:types/node-polkit-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-polkitagent-1.0@workspace:^, @girs/node-polkitagent-1.0@workspace:types/node-polkitagent-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-polkitagent-1.0@workspace:types/node-polkitagent-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-polkit-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-poppler-0.18@workspace:types/node-poppler-0.18": - version: 0.0.0-use.local - resolution: "@girs/node-poppler-0.18@workspace:types/node-poppler-0.18" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-qmi-1.0@workspace:types/node-qmi-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-qmi-1.0@workspace:types/node-qmi-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-qrtr-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-qrtr-1.0@workspace:^, @girs/node-qrtr-1.0@workspace:types/node-qrtr-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-qrtr-1.0@workspace:types/node-qrtr-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rest-0.7@workspace:^, @girs/node-rest-0.7@workspace:types/node-rest-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-rest-0.7@workspace:types/node-rest-0.7" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rest-1.0@workspace:^, @girs/node-rest-1.0@workspace:types/node-rest-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-rest-1.0@workspace:types/node-rest-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-restextras-0.7@workspace:types/node-restextras-0.7": - version: 0.0.0-use.local - resolution: "@girs/node-restextras-0.7@workspace:types/node-restextras-0.7" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rest-0.7": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-restextras-1.0@workspace:types/node-restextras-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-restextras-1.0@workspace:types/node-restextras-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-rest-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-retro-0.14@workspace:types/node-retro-0.14": - version: 0.0.0-use.local - resolution: "@girs/node-retro-0.14@workspace:types/node-retro-0.14" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-retro-1@workspace:types/node-retro-1": - version: 0.0.0-use.local - resolution: "@girs/node-retro-1@workspace:types/node-retro-1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-retro-2@workspace:types/node-retro-2": - version: 0.0.0-use.local - resolution: "@girs/node-retro-2@workspace:types/node-retro-2" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rsvg-2.0@workspace:types/node-rsvg-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-rsvg-2.0@workspace:types/node-rsvg-2.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelcore-2.6@workspace:^, @girs/node-rygelcore-2.6@workspace:types/node-rygelcore-2.6": - version: 0.0.0-use.local - resolution: "@girs/node-rygelcore-2.6@workspace:types/node-rygelcore-2.6" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.2": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.2": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelcore-2.8@workspace:^, @girs/node-rygelcore-2.8@workspace:types/node-rygelcore-2.8": - version: 0.0.0-use.local - resolution: "@girs/node-rygelcore-2.8@workspace:types/node-rygelcore-2.8" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.6": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.6": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelrenderer-2.6@workspace:^, @girs/node-rygelrenderer-2.6@workspace:types/node-rygelrenderer-2.6": - version: 0.0.0-use.local - resolution: "@girs/node-rygelrenderer-2.6@workspace:types/node-rygelrenderer-2.6" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.2": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.2": "workspace:^" - "@girs/node-gupnpav-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rygelcore-2.6": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelrenderer-2.8@workspace:^, @girs/node-rygelrenderer-2.8@workspace:types/node-rygelrenderer-2.8": - version: 0.0.0-use.local - resolution: "@girs/node-rygelrenderer-2.8@workspace:types/node-rygelrenderer-2.8" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.6": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.6": "workspace:^" - "@girs/node-gupnpav-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rygelcore-2.8": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelrenderergst-2.6@workspace:types/node-rygelrenderergst-2.6": - version: 0.0.0-use.local - resolution: "@girs/node-rygelrenderergst-2.6@workspace:types/node-rygelrenderergst-2.6" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.2": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.2": "workspace:^" - "@girs/node-gupnpav-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rygelcore-2.6": "workspace:^" - "@girs/node-rygelrenderer-2.6": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelrenderergst-2.8@workspace:types/node-rygelrenderergst-2.8": - version: 0.0.0-use.local - resolution: "@girs/node-rygelrenderergst-2.8@workspace:types/node-rygelrenderergst-2.8" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.6": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.6": "workspace:^" - "@girs/node-gupnpav-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rygelcore-2.8": "workspace:^" - "@girs/node-rygelrenderer-2.8": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelserver-2.6@workspace:types/node-rygelserver-2.6": - version: 0.0.0-use.local - resolution: "@girs/node-rygelserver-2.6@workspace:types/node-rygelserver-2.6" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.2": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.2": "workspace:^" - "@girs/node-gupnpav-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rygelcore-2.6": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-rygelserver-2.8@workspace:types/node-rygelserver-2.8": - version: 0.0.0-use.local - resolution: "@girs/node-rygelserver-2.8@workspace:types/node-rygelserver-2.8" - dependencies: - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gssdp-1.6": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gupnp-1.6": "workspace:^" - "@girs/node-gupnpav-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-rygelcore-2.8": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-secret-1@workspace:^, @girs/node-secret-1@workspace:types/node-secret-1": - version: 0.0.0-use.local - resolution: "@girs/node-secret-1@workspace:types/node-secret-1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-secretunstable-0@workspace:types/node-secretunstable-0": - version: 0.0.0-use.local - resolution: "@girs/node-secretunstable-0@workspace:types/node-secretunstable-0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-secret-1": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-shell-0.1@workspace:types/node-shell-0.1": - version: 0.0.0-use.local - resolution: "@girs/node-shell-0.1@workspace:types/node-shell-0.1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cally-11": "workspace:^" - "@girs/node-clutter-11": "workspace:^" - "@girs/node-cogl-11": "workspace:^" - "@girs/node-coglpango-11": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gck-1": "workspace:^" - "@girs/node-gcr-3": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gvc-1.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-11": "workspace:^" - "@girs/node-nm-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-polkit-1.0": "workspace:^" - "@girs/node-polkitagent-1.0": "workspace:^" - "@girs/node-st-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-shell-12@workspace:types/node-shell-12": - version: 0.0.0-use.local - resolution: "@girs/node-shell-12@workspace:types/node-shell-12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cally-12": "workspace:^" - "@girs/node-clutter-12": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-coglpango-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gck-2": "workspace:^" - "@girs/node-gcr-4": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gvc-1.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-12": "workspace:^" - "@girs/node-nm-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-polkit-1.0": "workspace:^" - "@girs/node-polkitagent-1.0": "workspace:^" - "@girs/node-st-12": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-shell-13@workspace:types/node-shell-13": - version: 0.0.0-use.local - resolution: "@girs/node-shell-13@workspace:types/node-shell-13" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cally-13": "workspace:^" - "@girs/node-clutter-13": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-coglpango-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gck-2": "workspace:^" - "@girs/node-gcr-4": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gvc-1.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-13": "workspace:^" - "@girs/node-mtk-13": "workspace:^" - "@girs/node-nm-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-polkit-1.0": "workspace:^" - "@girs/node-polkitagent-1.0": "workspace:^" - "@girs/node-st-13": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-shew-0@workspace:types/node-shew-0": - version: 0.0.0-use.local - resolution: "@girs/node-shew-0@workspace:types/node-shew-0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-shumate-1.0@workspace:types/node-shumate-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-shumate-1.0@workspace:types/node-shumate-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-signon-2.0@workspace:types/node-signon-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-signon-2.0@workspace:types/node-signon-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-snapd-1@workspace:types/node-snapd-1": - version: 0.0.0-use.local - resolution: "@girs/node-snapd-1@workspace:types/node-snapd-1" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-socialwebclient-0.25@workspace:^, @girs/node-socialwebclient-0.25@workspace:types/node-socialwebclient-0.25": - version: 0.0.0-use.local - resolution: "@girs/node-socialwebclient-0.25@workspace:types/node-socialwebclient-0.25" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-soup-2.4@workspace:^, @girs/node-soup-2.4@workspace:types/node-soup-2.4": - version: 0.0.0-use.local - resolution: "@girs/node-soup-2.4@workspace:types/node-soup-2.4" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-soup-3.0@workspace:^, @girs/node-soup-3.0@workspace:types/node-soup-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-soup-3.0@workspace:types/node-soup-3.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-soupgnome-2.4@workspace:types/node-soupgnome-2.4": - version: 0.0.0-use.local - resolution: "@girs/node-soupgnome-2.4@workspace:types/node-soupgnome-2.4" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-spiceclientglib-2.0@workspace:^, @girs/node-spiceclientglib-2.0@workspace:types/node-spiceclientglib-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-spiceclientglib-2.0@workspace:types/node-spiceclientglib-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-spiceclientgtk-3.0@workspace:types/node-spiceclientgtk-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-spiceclientgtk-3.0@workspace:types/node-spiceclientgtk-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gstbase-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-spiceclientglib-2.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-st-1.0@workspace:^, @girs/node-st-1.0@workspace:types/node-st-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-st-1.0@workspace:types/node-st-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cally-11": "workspace:^" - "@girs/node-clutter-11": "workspace:^" - "@girs/node-cogl-11": "workspace:^" - "@girs/node-coglpango-11": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-11": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-st-12@workspace:^, @girs/node-st-12@workspace:types/node-st-12": - version: 0.0.0-use.local - resolution: "@girs/node-st-12@workspace:types/node-st-12" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cally-12": "workspace:^" - "@girs/node-clutter-12": "workspace:^" - "@girs/node-cogl-12": "workspace:^" - "@girs/node-coglpango-12": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-12": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-st-13@workspace:^, @girs/node-st-13@workspace:types/node-st-13": - version: 0.0.0-use.local - resolution: "@girs/node-st-13@workspace:types/node-st-13" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-cally-13": "workspace:^" - "@girs/node-clutter-13": "workspace:^" - "@girs/node-cogl-13": "workspace:^" - "@girs/node-coglpango-13": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdesktopenums-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-meta-13": "workspace:^" - "@girs/node-mtk-13": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xfixes-4.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-sushi-1.0@workspace:types/node-sushi-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-sushi-1.0@workspace:types/node-sushi-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-clutter-1.0": "workspace:^" - "@girs/node-cogl-1.0": "workspace:^" - "@girs/node-coglpango-1.0": "workspace:^" - "@girs/node-evincedocument-3.0": "workspace:^" - "@girs/node-fontconfig-2.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-gl-1.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-0.10": "workspace:^" - "@girs/node-gstbase-0.10": "workspace:^" - "@girs/node-gstpbutils-0.10": "workspace:^" - "@girs/node-gsttag-0.10": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-pangofc-1.0": "workspace:^" - "@girs/node-pangoft2-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-telepathyfarstream-0.6@workspace:types/node-telepathyfarstream-0.6": - version: 0.0.0-use.local - resolution: "@girs/node-telepathyfarstream-0.6@workspace:types/node-telepathyfarstream-0.6" - dependencies: - "@girs/node-farstream-0.2": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gst-1.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-telepathyglib-0.12@workspace:^, @girs/node-telepathyglib-0.12@workspace:types/node-telepathyglib-0.12": - version: 0.0.0-use.local - resolution: "@girs/node-telepathyglib-0.12@workspace:types/node-telepathyglib-0.12" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-telepathylogger-0.2@workspace:types/node-telepathylogger-0.2": - version: 0.0.0-use.local - resolution: "@girs/node-telepathylogger-0.2@workspace:types/node-telepathylogger-0.2" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-template-1.0@workspace:^, @girs/node-template-1.0@workspace:types/node-template-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-template-1.0@workspace:types/node-template-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-tepl-4@workspace:types/node-tepl-4": - version: 0.0.0-use.local - resolution: "@girs/node-tepl-4@workspace:types/node-tepl-4" - dependencies: - "@girs/node-amtk-5": "workspace:^" - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-4": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-tepl-5@workspace:types/node-tepl-5": - version: 0.0.0-use.local - resolution: "@girs/node-tepl-5@workspace:types/node-tepl-5" - dependencies: - "@girs/node-amtk-5": "workspace:^" - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-4": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-tepl-6@workspace:types/node-tepl-6": - version: 0.0.0-use.local - resolution: "@girs/node-tepl-6@workspace:types/node-tepl-6" - dependencies: - "@girs/node-amtk-5": "workspace:^" - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-gtksource-4": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-timezonemap-1.0@workspace:types/node-timezonemap-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-timezonemap-1.0@workspace:types/node-timezonemap-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-totem-1.0@workspace:types/node-totem-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-totem-1.0@workspace:types/node-totem-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-totemplparser-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-totemplparser-1.0@workspace:^, @girs/node-totemplparser-1.0@workspace:types/node-totemplparser-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-totemplparser-1.0@workspace:types/node-totemplparser-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-tracker-1.0@workspace:^, @girs/node-tracker-1.0@workspace:types/node-tracker-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-tracker-1.0@workspace:types/node-tracker-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-tracker-2.0@workspace:types/node-tracker-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-tracker-2.0@workspace:types/node-tracker-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-tracker-3.0@workspace:types/node-tracker-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-tracker-3.0@workspace:types/node-tracker-3.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-trackercontrol-1.0@workspace:types/node-trackercontrol-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-trackercontrol-1.0@workspace:types/node-trackercontrol-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-trackercontrol-2.0@workspace:types/node-trackercontrol-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-trackercontrol-2.0@workspace:types/node-trackercontrol-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-trackerminer-1.0@workspace:types/node-trackerminer-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-trackerminer-1.0@workspace:types/node-trackerminer-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-tracker-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-trackerminer-2.0@workspace:types/node-trackerminer-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-trackerminer-2.0@workspace:types/node-trackerminer-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-udisks-2.0@workspace:types/node-udisks-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-udisks-2.0@workspace:types/node-udisks-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-uhm-0.0@workspace:types/node-uhm-0.0": - version: 0.0.0-use.local - resolution: "@girs/node-uhm-0.0@workspace:types/node-uhm-0.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-unique-3.0@workspace:types/node-unique-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-unique-3.0@workspace:types/node-unique-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-unity-6.0@workspace:types/node-unity-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-unity-6.0@workspace:types/node-unity-6.0" - dependencies: - "@girs/node-dbusmenu-0.4": "workspace:^" - "@girs/node-dee-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-unity-7.0@workspace:^, @girs/node-unity-7.0@workspace:types/node-unity-7.0": - version: 0.0.0-use.local - resolution: "@girs/node-unity-7.0@workspace:types/node-unity-7.0" - dependencies: - "@girs/node-dbusmenu-0.4": "workspace:^" - "@girs/node-dee-1.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-unityextras-7.0@workspace:types/node-unityextras-7.0": - version: 0.0.0-use.local - resolution: "@girs/node-unityextras-7.0@workspace:types/node-unityextras-7.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-unity-7.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-upowerglib-1.0@workspace:types/node-upowerglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-upowerglib-1.0@workspace:types/node-upowerglib-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vda-1@workspace:^, @girs/node-vda-1@workspace:types/node-vda-1": - version: 0.0.0-use.local - resolution: "@girs/node-vda-1@workspace:types/node-vda-1" - dependencies: - "@girs/node-gcalc-2": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gxml-0.20": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vgda-1@workspace:^, @girs/node-vgda-1@workspace:types/node-vgda-1": - version: 0.0.0-use.local - resolution: "@girs/node-vgda-1@workspace:types/node-vgda-1" - dependencies: - "@girs/node-gcalc-2": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gxml-0.20": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-vda-1": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vgpg-1@workspace:types/node-vgpg-1": - version: 0.0.0-use.local - resolution: "@girs/node-vgpg-1@workspace:types/node-vgpg-1" - dependencies: - "@girs/node-gcalc-2": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gxml-0.20": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-vda-1": "workspace:^" - "@girs/node-vgda-1": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vgsl-1@workspace:types/node-vgsl-1": - version: 0.0.0-use.local - resolution: "@girs/node-vgsl-1@workspace:types/node-vgsl-1" - dependencies: - "@girs/node-gcalc-2": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gxml-0.20": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-vda-1": "workspace:^" - "@girs/node-vgda-1": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vips-8.0@workspace:types/node-vips-8.0": - version: 0.0.0-use.local - resolution: "@girs/node-vips-8.0@workspace:types/node-vips-8.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vpg-1@workspace:types/node-vpg-1": - version: 0.0.0-use.local - resolution: "@girs/node-vpg-1@workspace:types/node-vpg-1" - dependencies: - "@girs/node-gcalc-2": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gxml-0.20": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-vda-1": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vsqlite-1@workspace:types/node-vsqlite-1": - version: 0.0.0-use.local - resolution: "@girs/node-vsqlite-1@workspace:types/node-vsqlite-1" - dependencies: - "@girs/node-gcalc-2": "workspace:^" - "@girs/node-gee-0.8": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gxml-0.20": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-libxml2-2.0": "workspace:^" - "@girs/node-vda-1": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vte-2.91@workspace:types/node-vte-2.91": - version: 0.0.0-use.local - resolution: "@girs/node-vte-2.91@workspace:types/node-vte-2.91" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vte-3.91@workspace:types/node-vte-3.91": - version: 0.0.0-use.local - resolution: "@girs/node-vte-3.91@workspace:types/node-vte-3.91" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vte-4-2.91@workspace:types/node-vte-4-2.91": - version: 0.0.0-use.local - resolution: "@girs/node-vte-4-2.91@workspace:types/node-vte-4-2.91" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-vulkan-1.0@workspace:^, @girs/node-vulkan-1.0@workspace:types/node-vulkan-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-vulkan-1.0@workspace:types/node-vulkan-1.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit-6.0@workspace:types/node-webkit-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkit-6.0@workspace:types/node-webkit-6.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-6.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit2-4.0@workspace:^, @girs/node-webkit2-4.0@workspace:types/node-webkit2-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkit2-4.0@workspace:types/node-webkit2-4.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-4.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit2-4.1@workspace:^, @girs/node-webkit2-4.1@workspace:types/node-webkit2-4.1": - version: 0.0.0-use.local - resolution: "@girs/node-webkit2-4.1@workspace:types/node-webkit2-4.1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-4.1": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit2-5.0@workspace:types/node-webkit2-5.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkit2-5.0@workspace:types/node-webkit2-5.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-5.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit2webextension-4.0@workspace:types/node-webkit2webextension-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkit2webextension-4.0@workspace:types/node-webkit2webextension-4.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-4.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit2webextension-4.1@workspace:types/node-webkit2webextension-4.1": - version: 0.0.0-use.local - resolution: "@girs/node-webkit2webextension-4.1@workspace:types/node-webkit2webextension-4.1" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-4.1": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkit2webextension-5.0@workspace:types/node-webkit2webextension-5.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkit2webextension-5.0@workspace:types/node-webkit2webextension-5.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-5.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkitwebextension-6.0@workspace:types/node-webkitwebextension-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkitwebextension-6.0@workspace:types/node-webkitwebextension-6.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-6.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-webkitwebprocessextension-6.0@workspace:types/node-webkitwebprocessextension-6.0": - version: 0.0.0-use.local - resolution: "@girs/node-webkitwebprocessextension-6.0@workspace:types/node-webkitwebprocessextension-6.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-javascriptcore-6.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-soup-3.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-win32-1.0@workspace:types/node-win32-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-win32-1.0@workspace:types/node-win32-1.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-wnck-3.0@workspace:types/node-wnck-3.0": - version: 0.0.0-use.local - resolution: "@girs/node-wnck-3.0@workspace:types/node-wnck-3.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xdp-1.0@workspace:^, @girs/node-xdp-1.0@workspace:types/node-xdp-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-xdp-1.0@workspace:types/node-xdp-1.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xdpgtk3-1.0@workspace:types/node-xdpgtk3-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-xdpgtk3-1.0@workspace:types/node-xdpgtk3-1.0" - dependencies: - "@girs/node-atk-1.0": "workspace:^" - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-3.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-3.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-xdp-1.0": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xdpgtk4-1.0@workspace:types/node-xdpgtk4-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-xdpgtk4-1.0@workspace:types/node-xdpgtk4-1.0" - dependencies: - "@girs/node-cairo-1.0": "workspace:^" - "@girs/node-freetype2-2.0": "workspace:^" - "@girs/node-gdk-4.0": "workspace:^" - "@girs/node-gdkpixbuf-2.0": "workspace:^" - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gmodule-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-graphene-1.0": "workspace:^" - "@girs/node-gsk-4.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-gtk-4.0": "workspace:^" - "@girs/node-harfbuzz-0.0": "workspace:^" - "@girs/node-pango-1.0": "workspace:^" - "@girs/node-pangocairo-1.0": "workspace:^" - "@girs/node-xdp-1.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xfixes-4.0@workspace:^, @girs/node-xfixes-4.0@workspace:types/node-xfixes-4.0": - version: 0.0.0-use.local - resolution: "@girs/node-xfixes-4.0@workspace:types/node-xfixes-4.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xft-2.0@workspace:^, @girs/node-xft-2.0@workspace:types/node-xft-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-xft-2.0@workspace:types/node-xft-2.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xkl-1.0@workspace:^, @girs/node-xkl-1.0@workspace:types/node-xkl-1.0": - version: 0.0.0-use.local - resolution: "@girs/node-xkl-1.0@workspace:types/node-xkl-1.0" - dependencies: - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-xlib-2.0": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xlib-2.0@workspace:^, @girs/node-xlib-2.0@workspace:types/node-xlib-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-xlib-2.0@workspace:types/node-xlib-2.0" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-xrandr-1.3@workspace:types/node-xrandr-1.3": - version: 0.0.0-use.local - resolution: "@girs/node-xrandr-1.3@workspace:types/node-xrandr-1.3" - dependencies: - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-zeitgeist-2.0@workspace:types/node-zeitgeist-2.0": - version: 0.0.0-use.local - resolution: "@girs/node-zeitgeist-2.0@workspace:types/node-zeitgeist-2.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/node-zpj-0.0@workspace:types/node-zpj-0.0": - version: 0.0.0-use.local - resolution: "@girs/node-zpj-0.0@workspace:types/node-zpj-0.0" - dependencies: - "@girs/node-gio-2.0": "workspace:^" - "@girs/node-glib-2.0": "workspace:^" - "@girs/node-gobject-2.0": "workspace:^" - "@girs/node-gtk": "workspace:^" - "@girs/node-json-1.0": "workspace:^" - "@girs/node-rest-0.7": "workspace:^" - "@girs/node-soup-2.4": "workspace:^" - typescript: "npm:*" - peerDependencies: - node-gtk: "*" - languageName: unknown - linkType: soft - -"@girs/notify-0.7@workspace:types/notify-0.7": - version: 0.0.0-use.local - resolution: "@girs/notify-0.7@workspace:types/notify-0.7" - dependencies: - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/ostree-1.0@workspace:types/ostree-1.0": - version: 0.0.0-use.local - resolution: "@girs/ostree-1.0@workspace:types/ostree-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/p11kit-1.0@workspace:types/p11kit-1.0": - version: 0.0.0-use.local - resolution: "@girs/p11kit-1.0@workspace:types/p11kit-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/packagekitglib-1.0@workspace:^, @girs/packagekitglib-1.0@workspace:types/packagekitglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/packagekitglib-1.0@workspace:types/packagekitglib-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/packagekitplugin-1.0@workspace:types/packagekitplugin-1.0": - version: 0.0.0-use.local - resolution: "@girs/packagekitplugin-1.0@workspace:types/packagekitplugin-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/packagekitglib-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/panelapplet-4.0@workspace:types/panelapplet-4.0": - version: 0.0.0-use.local - resolution: "@girs/panelapplet-4.0@workspace:types/panelapplet-4.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gconf-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pango-1.0@workspace:^, @girs/pango-1.0@workspace:types/pango-1.0": - version: 0.0.0-use.local - resolution: "@girs/pango-1.0@workspace:types/pango-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pangocairo-1.0@workspace:^, @girs/pangocairo-1.0@workspace:types/pangocairo-1.0": - version: 0.0.0-use.local - resolution: "@girs/pangocairo-1.0@workspace:types/pangocairo-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pangofc-1.0@workspace:^, @girs/pangofc-1.0@workspace:types/pangofc-1.0": - version: 0.0.0-use.local - resolution: "@girs/pangofc-1.0@workspace:types/pangofc-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pangoft2-1.0@workspace:^, @girs/pangoft2-1.0@workspace:types/pangoft2-1.0": - version: 0.0.0-use.local - resolution: "@girs/pangoft2-1.0@workspace:types/pangoft2-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pangoot-1.0@workspace:^, @girs/pangoot-1.0@workspace:types/pangoot-1.0": - version: 0.0.0-use.local - resolution: "@girs/pangoot-1.0@workspace:types/pangoot-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pangoxft-1.0@workspace:types/pangoxft-1.0": - version: 0.0.0-use.local - resolution: "@girs/pangoxft-1.0@workspace:types/pangoxft-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - "@girs/pangoft2-1.0": "workspace:^" - "@girs/pangoot-1.0": "workspace:^" - "@girs/xft-2.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/parquet-1.0@workspace:types/parquet-1.0": - version: 0.0.0-use.local - resolution: "@girs/parquet-1.0@workspace:types/parquet-1.0" - dependencies: - "@girs/arrow-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/peas-1.0@workspace:^, @girs/peas-1.0@workspace:types/peas-1.0": - version: 0.0.0-use.local - resolution: "@girs/peas-1.0@workspace:types/peas-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/girepository-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/peas-2@workspace:types/peas-2": - version: 0.0.0-use.local - resolution: "@girs/peas-2@workspace:types/peas-2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/peasgtk-1.0@workspace:types/peasgtk-1.0": - version: 0.0.0-use.local - resolution: "@girs/peasgtk-1.0@workspace:types/peasgtk-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/girepository-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/peas-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/plasma-1.0@workspace:types/plasma-1.0": - version: 0.0.0-use.local - resolution: "@girs/plasma-1.0@workspace:types/plasma-1.0" - dependencies: - "@girs/arrow-1.0": "workspace:^" - "@girs/arrowcuda-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/pnl-1.0@workspace:types/pnl-1.0": - version: 0.0.0-use.local - resolution: "@girs/pnl-1.0@workspace:types/pnl-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/polkit-1.0@workspace:^, @girs/polkit-1.0@workspace:types/polkit-1.0": - version: 0.0.0-use.local - resolution: "@girs/polkit-1.0@workspace:types/polkit-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/polkitagent-1.0@workspace:^, @girs/polkitagent-1.0@workspace:types/polkitagent-1.0": - version: 0.0.0-use.local - resolution: "@girs/polkitagent-1.0@workspace:types/polkitagent-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/polkit-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/poppler-0.18@workspace:types/poppler-0.18": - version: 0.0.0-use.local - resolution: "@girs/poppler-0.18@workspace:types/poppler-0.18" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/qmi-1.0@workspace:types/qmi-1.0": - version: 0.0.0-use.local - resolution: "@girs/qmi-1.0@workspace:types/qmi-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/qrtr-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/qrtr-1.0@workspace:^, @girs/qrtr-1.0@workspace:types/qrtr-1.0": - version: 0.0.0-use.local - resolution: "@girs/qrtr-1.0@workspace:types/qrtr-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rest-0.7@workspace:^, @girs/rest-0.7@workspace:types/rest-0.7": - version: 0.0.0-use.local - resolution: "@girs/rest-0.7@workspace:types/rest-0.7" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rest-1.0@workspace:^, @girs/rest-1.0@workspace:types/rest-1.0": - version: 0.0.0-use.local - resolution: "@girs/rest-1.0@workspace:types/rest-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/restextras-0.7@workspace:types/restextras-0.7": - version: 0.0.0-use.local - resolution: "@girs/restextras-0.7@workspace:types/restextras-0.7" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rest-0.7": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/restextras-1.0@workspace:types/restextras-1.0": - version: 0.0.0-use.local - resolution: "@girs/restextras-1.0@workspace:types/restextras-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/rest-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/retro-0.14@workspace:types/retro-0.14": - version: 0.0.0-use.local - resolution: "@girs/retro-0.14@workspace:types/retro-0.14" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/retro-1@workspace:types/retro-1": - version: 0.0.0-use.local - resolution: "@girs/retro-1@workspace:types/retro-1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/retro-2@workspace:types/retro-2": - version: 0.0.0-use.local - resolution: "@girs/retro-2@workspace:types/retro-2" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rsvg-2.0@workspace:types/rsvg-2.0": - version: 0.0.0-use.local - resolution: "@girs/rsvg-2.0@workspace:types/rsvg-2.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelcore-2.6@workspace:^, @girs/rygelcore-2.6@workspace:types/rygelcore-2.6": - version: 0.0.0-use.local - resolution: "@girs/rygelcore-2.6@workspace:types/rygelcore-2.6" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.2": "workspace:^" - "@girs/gupnp-1.2": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelcore-2.8@workspace:^, @girs/rygelcore-2.8@workspace:types/rygelcore-2.8": - version: 0.0.0-use.local - resolution: "@girs/rygelcore-2.8@workspace:types/rygelcore-2.8" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.6": "workspace:^" - "@girs/gupnp-1.6": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelrenderer-2.6@workspace:^, @girs/rygelrenderer-2.6@workspace:types/rygelrenderer-2.6": - version: 0.0.0-use.local - resolution: "@girs/rygelrenderer-2.6@workspace:types/rygelrenderer-2.6" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.2": "workspace:^" - "@girs/gupnp-1.2": "workspace:^" - "@girs/gupnpav-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rygelcore-2.6": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelrenderer-2.8@workspace:^, @girs/rygelrenderer-2.8@workspace:types/rygelrenderer-2.8": - version: 0.0.0-use.local - resolution: "@girs/rygelrenderer-2.8@workspace:types/rygelrenderer-2.8" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.6": "workspace:^" - "@girs/gupnp-1.6": "workspace:^" - "@girs/gupnpav-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rygelcore-2.8": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelrenderergst-2.6@workspace:types/rygelrenderergst-2.6": - version: 0.0.0-use.local - resolution: "@girs/rygelrenderergst-2.6@workspace:types/rygelrenderergst-2.6" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.2": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gupnp-1.2": "workspace:^" - "@girs/gupnpav-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rygelcore-2.6": "workspace:^" - "@girs/rygelrenderer-2.6": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelrenderergst-2.8@workspace:types/rygelrenderergst-2.8": - version: 0.0.0-use.local - resolution: "@girs/rygelrenderergst-2.8@workspace:types/rygelrenderergst-2.8" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.6": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gupnp-1.6": "workspace:^" - "@girs/gupnpav-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rygelcore-2.8": "workspace:^" - "@girs/rygelrenderer-2.8": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelserver-2.6@workspace:types/rygelserver-2.6": - version: 0.0.0-use.local - resolution: "@girs/rygelserver-2.6@workspace:types/rygelserver-2.6" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.2": "workspace:^" - "@girs/gupnp-1.2": "workspace:^" - "@girs/gupnpav-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rygelcore-2.6": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/rygelserver-2.8@workspace:types/rygelserver-2.8": - version: 0.0.0-use.local - resolution: "@girs/rygelserver-2.8@workspace:types/rygelserver-2.8" - dependencies: - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gssdp-1.6": "workspace:^" - "@girs/gupnp-1.6": "workspace:^" - "@girs/gupnpav-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/rygelcore-2.8": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/secret-1@workspace:^, @girs/secret-1@workspace:types/secret-1": - version: 0.0.0-use.local - resolution: "@girs/secret-1@workspace:types/secret-1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/secretunstable-0@workspace:types/secretunstable-0": - version: 0.0.0-use.local - resolution: "@girs/secretunstable-0@workspace:types/secretunstable-0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/secret-1": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/shell-0.1@workspace:types/shell-0.1": - version: 0.0.0-use.local - resolution: "@girs/shell-0.1@workspace:types/shell-0.1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cally-11": "workspace:^" - "@girs/clutter-11": "workspace:^" - "@girs/cogl-11": "workspace:^" - "@girs/coglpango-11": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gck-1": "workspace:^" - "@girs/gcr-3": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gvc-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-11": "workspace:^" - "@girs/nm-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/polkit-1.0": "workspace:^" - "@girs/polkitagent-1.0": "workspace:^" - "@girs/st-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/shell-12@workspace:types/shell-12": - version: 0.0.0-use.local - resolution: "@girs/shell-12@workspace:types/shell-12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cally-12": "workspace:^" - "@girs/clutter-12": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/coglpango-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gck-2": "workspace:^" - "@girs/gcr-4": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gvc-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-12": "workspace:^" - "@girs/nm-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/polkit-1.0": "workspace:^" - "@girs/polkitagent-1.0": "workspace:^" - "@girs/st-12": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/shell-13@workspace:types/shell-13": - version: 0.0.0-use.local - resolution: "@girs/shell-13@workspace:types/shell-13" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cally-13": "workspace:^" - "@girs/clutter-13": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/coglpango-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gck-2": "workspace:^" - "@girs/gcr-4": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gvc-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-13": "workspace:^" - "@girs/mtk-13": "workspace:^" - "@girs/nm-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/polkit-1.0": "workspace:^" - "@girs/polkitagent-1.0": "workspace:^" - "@girs/st-13": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/shew-0@workspace:types/shew-0": - version: 0.0.0-use.local - resolution: "@girs/shew-0@workspace:types/shew-0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/shumate-1.0@workspace:types/shumate-1.0": - version: 0.0.0-use.local - resolution: "@girs/shumate-1.0@workspace:types/shumate-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/signon-2.0@workspace:types/signon-2.0": - version: 0.0.0-use.local - resolution: "@girs/signon-2.0@workspace:types/signon-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/snapd-1@workspace:types/snapd-1": - version: 0.0.0-use.local - resolution: "@girs/snapd-1@workspace:types/snapd-1" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/socialwebclient-0.25@workspace:^, @girs/socialwebclient-0.25@workspace:types/socialwebclient-0.25": - version: 0.0.0-use.local - resolution: "@girs/socialwebclient-0.25@workspace:types/socialwebclient-0.25" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/soup-2.4@workspace:^, @girs/soup-2.4@workspace:types/soup-2.4": - version: 0.0.0-use.local - resolution: "@girs/soup-2.4@workspace:types/soup-2.4" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/soup-3.0@workspace:^, @girs/soup-3.0@workspace:types/soup-3.0": - version: 0.0.0-use.local - resolution: "@girs/soup-3.0@workspace:types/soup-3.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/soupgnome-2.4@workspace:types/soupgnome-2.4": - version: 0.0.0-use.local - resolution: "@girs/soupgnome-2.4@workspace:types/soupgnome-2.4" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/spiceclientglib-2.0@workspace:^, @girs/spiceclientglib-2.0@workspace:types/spiceclientglib-2.0": - version: 0.0.0-use.local - resolution: "@girs/spiceclientglib-2.0@workspace:types/spiceclientglib-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/spiceclientgtk-3.0@workspace:types/spiceclientgtk-3.0": - version: 0.0.0-use.local - resolution: "@girs/spiceclientgtk-3.0@workspace:types/spiceclientgtk-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/gstbase-1.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/spiceclientglib-2.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/st-1.0@workspace:^, @girs/st-1.0@workspace:types/st-1.0": - version: 0.0.0-use.local - resolution: "@girs/st-1.0@workspace:types/st-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cally-11": "workspace:^" - "@girs/clutter-11": "workspace:^" - "@girs/cogl-11": "workspace:^" - "@girs/coglpango-11": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-11": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/st-12@workspace:^, @girs/st-12@workspace:types/st-12": - version: 0.0.0-use.local - resolution: "@girs/st-12@workspace:types/st-12" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cally-12": "workspace:^" - "@girs/clutter-12": "workspace:^" - "@girs/cogl-12": "workspace:^" - "@girs/coglpango-12": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-12": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/st-13@workspace:^, @girs/st-13@workspace:types/st-13": - version: 0.0.0-use.local - resolution: "@girs/st-13@workspace:types/st-13" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/cally-13": "workspace:^" - "@girs/clutter-13": "workspace:^" - "@girs/cogl-13": "workspace:^" - "@girs/coglpango-13": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdesktopenums-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/meta-13": "workspace:^" - "@girs/mtk-13": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xfixes-4.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/sushi-1.0@workspace:types/sushi-1.0": - version: 0.0.0-use.local - resolution: "@girs/sushi-1.0@workspace:types/sushi-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/clutter-1.0": "workspace:^" - "@girs/cogl-1.0": "workspace:^" - "@girs/coglpango-1.0": "workspace:^" - "@girs/evincedocument-3.0": "workspace:^" - "@girs/fontconfig-2.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/gl-1.0": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-0.10": "workspace:^" - "@girs/gstbase-0.10": "workspace:^" - "@girs/gstpbutils-0.10": "workspace:^" - "@girs/gsttag-0.10": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/pangofc-1.0": "workspace:^" - "@girs/pangoft2-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/telepathyfarstream-0.6@workspace:types/telepathyfarstream-0.6": - version: 0.0.0-use.local - resolution: "@girs/telepathyfarstream-0.6@workspace:types/telepathyfarstream-0.6" - dependencies: - "@girs/farstream-0.2": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gst-1.0": "workspace:^" - "@girs/telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/telepathyglib-0.12@workspace:^, @girs/telepathyglib-0.12@workspace:types/telepathyglib-0.12": - version: 0.0.0-use.local - resolution: "@girs/telepathyglib-0.12@workspace:types/telepathyglib-0.12" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/telepathylogger-0.2@workspace:types/telepathylogger-0.2": - version: 0.0.0-use.local - resolution: "@girs/telepathylogger-0.2@workspace:types/telepathylogger-0.2" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/telepathyglib-0.12": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/template-1.0@workspace:^, @girs/template-1.0@workspace:types/template-1.0": - version: 0.0.0-use.local - resolution: "@girs/template-1.0@workspace:types/template-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/tepl-4@workspace:types/tepl-4": - version: 0.0.0-use.local - resolution: "@girs/tepl-4@workspace:types/tepl-4" - dependencies: - "@girs/amtk-5": "workspace:^" - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-4": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/tepl-5@workspace:types/tepl-5": - version: 0.0.0-use.local - resolution: "@girs/tepl-5@workspace:types/tepl-5" - dependencies: - "@girs/amtk-5": "workspace:^" - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-4": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/tepl-6@workspace:types/tepl-6": - version: 0.0.0-use.local - resolution: "@girs/tepl-6@workspace:types/tepl-6" - dependencies: - "@girs/amtk-5": "workspace:^" - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/gtksource-4": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/timezonemap-1.0@workspace:types/timezonemap-1.0": - version: 0.0.0-use.local - resolution: "@girs/timezonemap-1.0@workspace:types/timezonemap-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/totem-1.0@workspace:types/totem-1.0": - version: 0.0.0-use.local - resolution: "@girs/totem-1.0@workspace:types/totem-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/totemplparser-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/totemplparser-1.0@workspace:^, @girs/totemplparser-1.0@workspace:types/totemplparser-1.0": - version: 0.0.0-use.local - resolution: "@girs/totemplparser-1.0@workspace:types/totemplparser-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/tracker-1.0@workspace:^, @girs/tracker-1.0@workspace:types/tracker-1.0": - version: 0.0.0-use.local - resolution: "@girs/tracker-1.0@workspace:types/tracker-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/tracker-2.0@workspace:types/tracker-2.0": - version: 0.0.0-use.local - resolution: "@girs/tracker-2.0@workspace:types/tracker-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/tracker-3.0@workspace:types/tracker-3.0": - version: 0.0.0-use.local - resolution: "@girs/tracker-3.0@workspace:types/tracker-3.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/trackercontrol-1.0@workspace:types/trackercontrol-1.0": - version: 0.0.0-use.local - resolution: "@girs/trackercontrol-1.0@workspace:types/trackercontrol-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/trackercontrol-2.0@workspace:types/trackercontrol-2.0": - version: 0.0.0-use.local - resolution: "@girs/trackercontrol-2.0@workspace:types/trackercontrol-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/trackerminer-1.0@workspace:types/trackerminer-1.0": - version: 0.0.0-use.local - resolution: "@girs/trackerminer-1.0@workspace:types/trackerminer-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/tracker-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/trackerminer-2.0@workspace:types/trackerminer-2.0": - version: 0.0.0-use.local - resolution: "@girs/trackerminer-2.0@workspace:types/trackerminer-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/udisks-2.0@workspace:types/udisks-2.0": - version: 0.0.0-use.local - resolution: "@girs/udisks-2.0@workspace:types/udisks-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/uhm-0.0@workspace:types/uhm-0.0": - version: 0.0.0-use.local - resolution: "@girs/uhm-0.0@workspace:types/uhm-0.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/unique-3.0@workspace:types/unique-3.0": - version: 0.0.0-use.local - resolution: "@girs/unique-3.0@workspace:types/unique-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/unity-6.0@workspace:types/unity-6.0": - version: 0.0.0-use.local - resolution: "@girs/unity-6.0@workspace:types/unity-6.0" - dependencies: - "@girs/dbusmenu-0.4": "workspace:^" - "@girs/dee-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/unity-7.0@workspace:^, @girs/unity-7.0@workspace:types/unity-7.0": - version: 0.0.0-use.local - resolution: "@girs/unity-7.0@workspace:types/unity-7.0" - dependencies: - "@girs/dbusmenu-0.4": "workspace:^" - "@girs/dee-1.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/unityextras-7.0@workspace:types/unityextras-7.0": - version: 0.0.0-use.local - resolution: "@girs/unityextras-7.0@workspace:types/unityextras-7.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/unity-7.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/upowerglib-1.0@workspace:types/upowerglib-1.0": - version: 0.0.0-use.local - resolution: "@girs/upowerglib-1.0@workspace:types/upowerglib-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vda-1@workspace:^, @girs/vda-1@workspace:types/vda-1": - version: 0.0.0-use.local - resolution: "@girs/vda-1@workspace:types/vda-1" - dependencies: - "@girs/gcalc-2": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gxml-0.20": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vgda-1@workspace:^, @girs/vgda-1@workspace:types/vgda-1": - version: 0.0.0-use.local - resolution: "@girs/vgda-1@workspace:types/vgda-1" - dependencies: - "@girs/gcalc-2": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gxml-0.20": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/vda-1": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vgpg-1@workspace:types/vgpg-1": - version: 0.0.0-use.local - resolution: "@girs/vgpg-1@workspace:types/vgpg-1" - dependencies: - "@girs/gcalc-2": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gxml-0.20": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/vda-1": "workspace:^" - "@girs/vgda-1": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vgsl-1@workspace:types/vgsl-1": - version: 0.0.0-use.local - resolution: "@girs/vgsl-1@workspace:types/vgsl-1" - dependencies: - "@girs/gcalc-2": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gxml-0.20": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/vda-1": "workspace:^" - "@girs/vgda-1": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vips-8.0@workspace:types/vips-8.0": - version: 0.0.0-use.local - resolution: "@girs/vips-8.0@workspace:types/vips-8.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vpg-1@workspace:types/vpg-1": - version: 0.0.0-use.local - resolution: "@girs/vpg-1@workspace:types/vpg-1" - dependencies: - "@girs/gcalc-2": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gxml-0.20": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/vda-1": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vsqlite-1@workspace:types/vsqlite-1": - version: 0.0.0-use.local - resolution: "@girs/vsqlite-1@workspace:types/vsqlite-1" - dependencies: - "@girs/gcalc-2": "workspace:^" - "@girs/gee-0.8": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gxml-0.20": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/libxml2-2.0": "workspace:^" - "@girs/vda-1": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vte-2.91@workspace:types/vte-2.91": - version: 0.0.0-use.local - resolution: "@girs/vte-2.91@workspace:types/vte-2.91" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vte-3.91@workspace:types/vte-3.91": - version: 0.0.0-use.local - resolution: "@girs/vte-3.91@workspace:types/vte-3.91" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vte-4-2.91@workspace:types/vte-4-2.91": - version: 0.0.0-use.local - resolution: "@girs/vte-4-2.91@workspace:types/vte-4-2.91" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/vulkan-1.0@workspace:^, @girs/vulkan-1.0@workspace:types/vulkan-1.0": - version: 0.0.0-use.local - resolution: "@girs/vulkan-1.0@workspace:types/vulkan-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit-6.0@workspace:types/webkit-6.0": - version: 0.0.0-use.local - resolution: "@girs/webkit-6.0@workspace:types/webkit-6.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-6.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit2-4.0@workspace:^, @girs/webkit2-4.0@workspace:types/webkit2-4.0": - version: 0.0.0-use.local - resolution: "@girs/webkit2-4.0@workspace:types/webkit2-4.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-4.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit2-4.1@workspace:^, @girs/webkit2-4.1@workspace:types/webkit2-4.1": - version: 0.0.0-use.local - resolution: "@girs/webkit2-4.1@workspace:types/webkit2-4.1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-4.1": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit2-5.0@workspace:types/webkit2-5.0": - version: 0.0.0-use.local - resolution: "@girs/webkit2-5.0@workspace:types/webkit2-5.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-5.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit2webextension-4.0@workspace:types/webkit2webextension-4.0": - version: 0.0.0-use.local - resolution: "@girs/webkit2webextension-4.0@workspace:types/webkit2webextension-4.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-4.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-2.4": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit2webextension-4.1@workspace:types/webkit2webextension-4.1": - version: 0.0.0-use.local - resolution: "@girs/webkit2webextension-4.1@workspace:types/webkit2webextension-4.1" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-4.1": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkit2webextension-5.0@workspace:types/webkit2webextension-5.0": - version: 0.0.0-use.local - resolution: "@girs/webkit2webextension-5.0@workspace:types/webkit2webextension-5.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-5.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkitwebextension-6.0@workspace:types/webkitwebextension-6.0": - version: 0.0.0-use.local - resolution: "@girs/webkitwebextension-6.0@workspace:types/webkitwebextension-6.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-6.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/webkitwebprocessextension-6.0@workspace:types/webkitwebprocessextension-6.0": - version: 0.0.0-use.local - resolution: "@girs/webkitwebprocessextension-6.0@workspace:types/webkitwebprocessextension-6.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/javascriptcore-6.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/soup-3.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/win32-1.0@workspace:types/win32-1.0": - version: 0.0.0-use.local - resolution: "@girs/win32-1.0@workspace:types/win32-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/wnck-3.0@workspace:types/wnck-3.0": - version: 0.0.0-use.local - resolution: "@girs/wnck-3.0@workspace:types/wnck-3.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xdp-1.0@workspace:^, @girs/xdp-1.0@workspace:types/xdp-1.0": - version: 0.0.0-use.local - resolution: "@girs/xdp-1.0@workspace:types/xdp-1.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xdpgtk3-1.0@workspace:types/xdpgtk3-1.0": - version: 0.0.0-use.local - resolution: "@girs/xdpgtk3-1.0@workspace:types/xdpgtk3-1.0" - dependencies: - "@girs/atk-1.0": "workspace:^" - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-3.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/gtk-3.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/xdp-1.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xdpgtk4-1.0@workspace:types/xdpgtk4-1.0": - version: 0.0.0-use.local - resolution: "@girs/xdpgtk4-1.0@workspace:types/xdpgtk4-1.0" - dependencies: - "@girs/cairo-1.0": "workspace:^" - "@girs/freetype2-2.0": "workspace:^" - "@girs/gdk-4.0": "workspace:^" - "@girs/gdkpixbuf-2.0": "workspace:^" - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gmodule-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/graphene-1.0": "workspace:^" - "@girs/gsk-4.0": "workspace:^" - "@girs/gtk-4.0": "workspace:^" - "@girs/harfbuzz-0.0": "workspace:^" - "@girs/pango-1.0": "workspace:^" - "@girs/pangocairo-1.0": "workspace:^" - "@girs/xdp-1.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xfixes-4.0@workspace:^, @girs/xfixes-4.0@workspace:types/xfixes-4.0": - version: 0.0.0-use.local - resolution: "@girs/xfixes-4.0@workspace:types/xfixes-4.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xft-2.0@workspace:^, @girs/xft-2.0@workspace:types/xft-2.0": - version: 0.0.0-use.local - resolution: "@girs/xft-2.0@workspace:types/xft-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xkl-1.0@workspace:^, @girs/xkl-1.0@workspace:types/xkl-1.0": - version: 0.0.0-use.local - resolution: "@girs/xkl-1.0@workspace:types/xkl-1.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/xlib-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xlib-2.0@workspace:^, @girs/xlib-2.0@workspace:types/xlib-2.0": - version: 0.0.0-use.local - resolution: "@girs/xlib-2.0@workspace:types/xlib-2.0" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/xrandr-1.3@workspace:types/xrandr-1.3": - version: 0.0.0-use.local - resolution: "@girs/xrandr-1.3@workspace:types/xrandr-1.3" - dependencies: - "@girs/gjs": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/zeitgeist-2.0@workspace:types/zeitgeist-2.0": - version: 0.0.0-use.local - resolution: "@girs/zeitgeist-2.0@workspace:types/zeitgeist-2.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - typescript: "npm:*" - languageName: unknown - linkType: soft - -"@girs/zpj-0.0@workspace:types/zpj-0.0": - version: 0.0.0-use.local - resolution: "@girs/zpj-0.0@workspace:types/zpj-0.0" - dependencies: - "@girs/gio-2.0": "workspace:^" - "@girs/gjs": "workspace:^" - "@girs/glib-2.0": "workspace:^" - "@girs/gobject-2.0": "workspace:^" - "@girs/json-1.0": "workspace:^" - "@girs/rest-0.7": "workspace:^" - "@girs/soup-2.4": "workspace:^" - typescript: "npm:*" + "@types/xml2js": "npm:^0.4.4" + fast-xml-parser: "npm:^3.17.5" + typescript: "npm:5.1.3" languageName: unknown linkType: soft @@ -16656,6 +1398,15 @@ __metadata: languageName: node linkType: hard +"@types/xml2js@npm:^0.4.4": + version: 0.4.13 + resolution: "@types/xml2js@npm:0.4.13" + dependencies: + "@types/node": "npm:*" + checksum: 10/3dda8f82d86ac16d14b9da9125f2f4ea5a5c8958324daa744c0eb7d6d7f975d7c62dd5e1ac8a40bf8fdcf1b73f3f7bc39f4bd72c89c0c2f0a8d7711c8dfa91d4 + languageName: node + linkType: hard + "@types/yargs-parser@npm:*": version: 21.0.2 resolution: "@types/yargs-parser@npm:21.0.2" @@ -18350,6 +3101,17 @@ __metadata: languageName: node linkType: hard +"fast-xml-parser@npm:^3.17.5": + version: 3.21.1 + resolution: "fast-xml-parser@npm:3.21.1" + dependencies: + strnum: "npm:^1.0.4" + bin: + xml2js: cli.js + checksum: 10/f9adbd8ae772473e7dec92bccfe93d3a752deec66c3d89479746ef01bfa12788bc4e5e611ec0250f69d85cc07a560e33a8d8c679673a8a69bb6e8da0234a9d40 + languageName: node + linkType: hard + "fastest-levenshtein@npm:^1.0.12": version: 1.0.16 resolution: "fastest-levenshtein@npm:1.0.16" @@ -20762,6 +5524,13 @@ __metadata: languageName: node linkType: hard +"strnum@npm:^1.0.4": + version: 1.0.5 + resolution: "strnum@npm:1.0.5" + checksum: 10/d3117975db8372d4d7b2c07601ed2f65bf21cc48d741f37a8617b76370d228f2ec26336e53791ebc3638264d23ca54e6c241f57f8c69bd4941c63c79440525ca + languageName: node + linkType: hard + "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" @@ -21462,7 +6231,17 @@ __metadata: languageName: node linkType: hard -"typescript@npm:*, typescript@npm:5.2.2": +"typescript@npm:5.1.3": + version: 5.1.3 + resolution: "typescript@npm:5.1.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/2d656e635d85a8354955d4f63e5835f5217b1d2b0cea7d82409e324bd7d24f68883e43208a9b250b764bbf2833d83878c05de55dbe4b8b73996b2025c6e50140 + languageName: node + linkType: hard + +"typescript@npm:5.2.2": version: 5.2.2 resolution: "typescript@npm:5.2.2" bin: @@ -21472,7 +6251,17 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A*#optional!builtin, typescript@patch:typescript@npm%3A5.2.2#optional!builtin": +"typescript@patch:typescript@npm%3A5.1.3#optional!builtin": + version: 5.1.3 + resolution: "typescript@patch:typescript@npm%3A5.1.3#optional!builtin::version=5.1.3&hash=5da071" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/dade91ba4155d0e9eb58a83cfec0d8271fefedc87b106443c396f9961aa8b231f8585d283b126a8373897aff7823da7874ce5c0b3b18a548b51ffb474f01565e + languageName: node + linkType: hard + +"typescript@patch:typescript@npm%3A5.2.2#optional!builtin": version: 5.2.2 resolution: "typescript@patch:typescript@npm%3A5.2.2#optional!builtin::version=5.2.2&hash=f3b441" bin: From c52e91133c8f2e2168ab21bf21f0091ce4f1ace4 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 11:07:35 -0700 Subject: [PATCH 03/53] Migrate to @gi.ts/parser with updated types for ts-for-gir --- packages/cli/package.json | 1 + packages/cli/src/module-loader.ts | 6 +- packages/lib/src/conflict-resolver.ts | 56 +- packages/lib/src/gir-module.ts | 2 +- packages/lib/src/types/gir-alias-element.ts | 15 +- packages/lib/src/types/gir-any-type.ts | 7 - packages/lib/src/types/gir-array-type.ts | 23 - .../lib/src/types/gir-bitfield-element.ts | 18 +- packages/lib/src/types/gir-boolean.ts | 1 - packages/lib/src/types/gir-boxed-element.ts | 19 - packages/lib/src/types/gir-c-include.ts | 7 - packages/lib/src/types/gir-callable-attrs.ts | 19 - .../src/types/gir-callable-param-element.ts | 47 +- packages/lib/src/types/gir-callable-param.ts | 9 - packages/lib/src/types/gir-callable-params.ts | 8 + packages/lib/src/types/gir-callable-return.ts | 24 +- .../lib/src/types/gir-callback-element.ts | 25 +- packages/lib/src/types/gir-class-element.ts | 56 +- .../lib/src/types/gir-constant-element.ts | 17 +- .../lib/src/types/gir-constructor-element.ts | 15 +- packages/lib/src/types/gir-direction.ts | 7 - packages/lib/src/types/gir-doc-element.ts | 73 --- packages/lib/src/types/gir-enum-element.ts | 25 +- packages/lib/src/types/gir-field-element.ts | 29 +- .../lib/src/types/gir-function-element.ts | 16 +- packages/lib/src/types/gir-implements.ts | 9 - packages/lib/src/types/gir-include.ts | 9 - packages/lib/src/types/gir-info-attrs.ts | 16 - packages/lib/src/types/gir-info-elements.ts | 8 - .../lib/src/types/gir-instance-parameter.ts | 22 +- .../lib/src/types/gir-interface-element.ts | 40 +- packages/lib/src/types/gir-member-element.ts | 19 +- packages/lib/src/types/gir-method-element.ts | 23 +- packages/lib/src/types/gir-namespace.ts | 46 +- packages/lib/src/types/gir-package.ts | 7 - packages/lib/src/types/gir-prerequisite.ts | 5 - .../lib/src/types/gir-property-element.ts | 33 +- packages/lib/src/types/gir-record-element.ts | 32 +- packages/lib/src/types/gir-repository.ts | 20 +- packages/lib/src/types/gir-signal.ts | 29 +- .../src/types/gir-transfer-ownership-type.ts | 5 - .../lib/src/types/gir-transfer-ownership.ts | 10 - packages/lib/src/types/gir-type.ts | 16 - packages/lib/src/types/gir-union-element.ts | 23 +- packages/lib/src/types/gir-var-args.ts | 6 - packages/lib/src/types/gir-virtual-method.ts | 19 +- packages/lib/src/types/index.ts | 44 +- packages/lib/src/types/parsed-gir.ts | 5 +- packages/parser/.eslintrc.cjs | 26 + packages/parser/.prettierrc.json | 8 + packages/parser/package.json | 6 + packages/parser/src/lib.ts | 2 +- packages/parser/src/parser.ts | 14 +- packages/parser/src/xml.ts | 573 ++++++++++-------- packages/parser/tsconfig.json | 4 +- yarn.lock | 9 +- 56 files changed, 530 insertions(+), 1083 deletions(-) delete mode 100644 packages/lib/src/types/gir-any-type.ts delete mode 100644 packages/lib/src/types/gir-array-type.ts delete mode 100644 packages/lib/src/types/gir-boolean.ts delete mode 100644 packages/lib/src/types/gir-boxed-element.ts delete mode 100644 packages/lib/src/types/gir-c-include.ts delete mode 100644 packages/lib/src/types/gir-callable-attrs.ts delete mode 100644 packages/lib/src/types/gir-callable-param.ts create mode 100644 packages/lib/src/types/gir-callable-params.ts delete mode 100644 packages/lib/src/types/gir-direction.ts delete mode 100644 packages/lib/src/types/gir-doc-element.ts delete mode 100644 packages/lib/src/types/gir-implements.ts delete mode 100644 packages/lib/src/types/gir-include.ts delete mode 100644 packages/lib/src/types/gir-info-attrs.ts delete mode 100644 packages/lib/src/types/gir-info-elements.ts delete mode 100644 packages/lib/src/types/gir-package.ts delete mode 100644 packages/lib/src/types/gir-prerequisite.ts delete mode 100644 packages/lib/src/types/gir-transfer-ownership-type.ts delete mode 100644 packages/lib/src/types/gir-transfer-ownership.ts delete mode 100644 packages/lib/src/types/gir-type.ts delete mode 100644 packages/lib/src/types/gir-var-args.ts create mode 100644 packages/parser/.eslintrc.cjs create mode 100644 packages/parser/.prettierrc.json diff --git a/packages/cli/package.json b/packages/cli/package.json index e8e8892ef..8c60ecd2f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -68,6 +68,7 @@ "typescript": "5.2.2" }, "dependencies": { + "@gi.ts/parser": "workspace:^", "@ts-for-gir/generator-base": "workspace:^", "@ts-for-gir/generator-html-doc": "workspace:^", "@ts-for-gir/generator-typescript": "workspace:^", diff --git a/packages/cli/src/module-loader.ts b/packages/cli/src/module-loader.ts index 83fdebb62..04cff26a5 100644 --- a/packages/cli/src/module-loader.ts +++ b/packages/cli/src/module-loader.ts @@ -7,8 +7,7 @@ import glob from 'tiny-glob' import { basename } from 'path' import { readFile } from 'fs/promises' import { bold } from 'colorette' -import * as xml2js from 'xml2js' -import * as parser from '@gi.ts/parser' +import { parser } from '@gi.ts/parser' import { DependencyManager, ResolveType, @@ -23,7 +22,6 @@ import { Config } from './config.js' import type { GirModulesGroupedMap, - ParsedGir, GenerateConfig, GirModuleResolvedBy, GirModulesGrouped, @@ -387,7 +385,7 @@ export class ModuleLoader { this.log.log(`Parsing ${dependency.path}...`) const fileContents = await readFile(dependency.path, 'utf8') - const result = (await xml2js.parseStringPromise(fileContents)) as ParsedGir + const result = parser.parseGir(fileContents) const girModule = new GirModule(result, this.config) // Figure out transitive module dependencies this.extendDependencyMapByGirModule(girModule) diff --git a/packages/lib/src/conflict-resolver.ts b/packages/lib/src/conflict-resolver.ts index dab28add0..baaa62276 100644 --- a/packages/lib/src/conflict-resolver.ts +++ b/packages/lib/src/conflict-resolver.ts @@ -3,34 +3,34 @@ import { Logger } from './logger.js' import { NO_TSDATA } from './messages.js' import { isEqual, merge, clone, typesContainsOptional } from './utils.js' import { SIGNAL_METHOD_NAMES, MAX_CLASS_PARENT_DEPTH } from './constants.js' -import { GirDirection } from './types/gir-direction.js' - -import type { - Environment, - GirClassElement, - GirRecordElement, - GirUnionElement, - GirInterfaceElement, - GirCallableParamElement, - GirMethodElement, - GirVirtualMethodElement, - GirConstructorElement, - GirFunctionElement, - GirPropertyElement, - GirFieldElement, - TsSignal, - TsFunction, - TsProperty, - TsVar, - TsTypeSeparator, - TsType, - TsClass, - TsParameter, - TypeGirFunction, - TypeGirProperty, - ConflictChildElement, - ConflictGroupedElements, - ConflictGroupedElement, + +import { + type Environment, + type GirClassElement, + type GirRecordElement, + type GirUnionElement, + type GirInterfaceElement, + type GirCallableParamElement, + type GirMethodElement, + type GirVirtualMethodElement, + type GirConstructorElement, + type GirFunctionElement, + type GirPropertyElement, + type GirFieldElement, + type TsSignal, + type TsFunction, + type TsProperty, + type TsVar, + type TsTypeSeparator, + type TsType, + type TsClass, + type TsParameter, + type TypeGirFunction, + type TypeGirProperty, + type ConflictChildElement, + type ConflictGroupedElements, + type ConflictGroupedElement, + GirDirection, } from './types/index.js' /** diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index 6db7378fe..a91892fbd 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -175,7 +175,7 @@ export class GirModule { xml: ParsedGir, private readonly config: GenerateConfig, ) { - this.repo = xml.repository + this.repo = xml.repository[0] if (!this.repo.namespace || !this.repo.namespace.length) { throw new Error(`Namespace not found!`) diff --git a/packages/lib/src/types/gir-alias-element.ts b/packages/lib/src/types/gir-alias-element.ts index f566538bf..66336ac3a 100644 --- a/packages/lib/src/types/gir-alias-element.ts +++ b/packages/lib/src/types/gir-alias-element.ts @@ -1,15 +1,6 @@ -import { GirInfoAttrs, GirInfoElements, GirType, PartOfClass, TsAlias } from './index.js' - -export interface GirAliasElement extends PartOfClass, GirInfoElements { - /** Type's name substitution, representing a typedef in C */ - $: GirInfoAttrs & { - /** the new name or typedef'd name */ - name: string - /** the corresponding C type's name */ - 'c:type'?: string - } - /** Other elements an alias can contain */ - type?: GirType[] +import { PartOfClass, TsAlias } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirAliasElement extends PartOfClass, parser.GirAliasElement { _tsData?: TsAlias } diff --git a/packages/lib/src/types/gir-any-type.ts b/packages/lib/src/types/gir-any-type.ts deleted file mode 100644 index 9a7d0c579..000000000 --- a/packages/lib/src/types/gir-any-type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { GirType, GirArrayType } from './index.js' - -//A generic grammar element to represent either a simple Type or an Array of the same Type -export interface GirAnyType { - type?: GirType[] - array?: GirArrayType[] -} diff --git a/packages/lib/src/types/gir-array-type.ts b/packages/lib/src/types/gir-array-type.ts deleted file mode 100644 index aa359c026..000000000 --- a/packages/lib/src/types/gir-array-type.ts +++ /dev/null @@ -1,23 +0,0 @@ -// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts - -import { GirInfoAttrs, GirUnparsedNumber, GirBoolean, GirType } from './index.js' - -export interface GirArrayType { - /** An array type of data where each element is of the same type */ - $: GirInfoAttrs & { - /** name of the array type */ - name?: string - /** Binary attribute, true if the last element of the array is zero. For example, in an array of pointers, the last pointer would be NULL */ - 'zero-terminated'?: GirBoolean - /** size of an array of predetermined fixed size. For example a C array declared as char arr[5]. */ - 'fixed-size'?: GirUnparsedNumber /** integer */ - /** Binary attribute which is GirBoolean (false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: GirBoolean - /** 0-based index of parameter element that specifies the length of the array */ - length?: GirUnparsedNumber /** integer */ - /** the C representation of the array type */ - 'c:type'?: string - } - array?: GirArrayType[] - type?: GirType[] -} diff --git a/packages/lib/src/types/gir-bitfield-element.ts b/packages/lib/src/types/gir-bitfield-element.ts index c8b3bb80c..e5812f85e 100644 --- a/packages/lib/src/types/gir-bitfield-element.ts +++ b/packages/lib/src/types/gir-bitfield-element.ts @@ -1,20 +1,8 @@ -import { GirInfoAttrs, GirFunctionElement, GirInfoElements, GirMemberElement, TsEnum, PartOfModule } from './index.js' - -export interface GirBitfieldElement extends PartOfModule, GirInfoElements { - /** element defining a bit field (as in C) */ - $: GirInfoAttrs & { - /** name of the bit field */ - name: string - /** corresponding C type of the bit field type */ - 'c:type': string - /** GObject compatible type name */ - 'glib:type-name'?: string - /** function to retrieve the GObject compatible type of the element */ - 'glib:get-type'?: string - } +import { TsEnum, PartOfModule, GirMemberElement, GirFunctionElement } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirBitfieldElement extends PartOfModule, parser.GirBitfieldElement { member: GirMemberElement[] function: GirFunctionElement[] - _tsData?: TsEnum } diff --git a/packages/lib/src/types/gir-boolean.ts b/packages/lib/src/types/gir-boolean.ts deleted file mode 100644 index 9fd908484..000000000 --- a/packages/lib/src/types/gir-boolean.ts +++ /dev/null @@ -1 +0,0 @@ -export type GirBoolean = '0' | '1' diff --git a/packages/lib/src/types/gir-boxed-element.ts b/packages/lib/src/types/gir-boxed-element.ts deleted file mode 100644 index f9cd3a6a1..000000000 --- a/packages/lib/src/types/gir-boxed-element.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { GirInfoAttrs, GirFunctionElement } from './index.js' - -export interface GirBoxedElement { - /** Boxed type (wrapper to opaque C structures registered by the type system) */ - $: GirInfoAttrs & { - /** GObject compatible type name of the boxed type */ - 'glib:name': string - /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefix'?: string - /** GObject compatible type name of the boxed type */ - 'glib:type-name'?: string - /** Function to get the GObject compatible type of the boxed type */ - 'glib:get-type'?: string - } - - /* Other elements a Boxed type can contain */ - - function?: GirFunctionElement[] -} diff --git a/packages/lib/src/types/gir-c-include.ts b/packages/lib/src/types/gir-c-include.ts deleted file mode 100644 index 4e7b5a0d7..000000000 --- a/packages/lib/src/types/gir-c-include.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface GirCInclude { - /** Dependant C header file which should be included in C programs */ - $: { - /** File name of the C header file. The path can be relative. */ - name: string - } -} diff --git a/packages/lib/src/types/gir-callable-attrs.ts b/packages/lib/src/types/gir-callable-attrs.ts deleted file mode 100644 index 26d7749fa..000000000 --- a/packages/lib/src/types/gir-callable-attrs.ts +++ /dev/null @@ -1,19 +0,0 @@ -// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts - -import { GirBoolean } from './gir-boolean' - -/** Attributes of a Callable (functions, callbacks, closures, etc...) */ -export interface GirCallableAttrs { - /** name of the Callable */ - name: string - //C identifier in the source code of the Callable - 'c:identifier'?: string - /** Callable it is shadowed by. For example, in C++, only one version of an overloaded callable will appear */ - 'shadowed-by'?: string - /** Callable it shadows. For example, in C++, only one version of an overloaded callable will appear */ - shadows?: string - /** Binary attribute, true if the callable can throw an error */ - throws?: GirBoolean - /** if for backward compatibility reason the callable has a name in the source code but should be known by another one, this attribute contains the new name */ - 'moved-to'?: string[] -} diff --git a/packages/lib/src/types/gir-callable-param-element.ts b/packages/lib/src/types/gir-callable-param-element.ts index 61a8a4d73..43901dc5a 100644 --- a/packages/lib/src/types/gir-callable-param-element.ts +++ b/packages/lib/src/types/gir-callable-param-element.ts @@ -1,47 +1,6 @@ -import type { - GirBoolean, - GirUnparsedNumber, - GirInfoAttrs, - GirDocElement, - GirAnyType, - GirTransferOwnership, - GirDirection, - GirVarArgs, - PartOfClass, - TsParameter, -} from './index.js' - -export interface GirCallableParamElement extends PartOfClass, GirDocElement, GirAnyType { - /** parameter element of a list of parameters */ - $: GirInfoAttrs & - Partial & { - /** name of the parameter */ - name?: string - /** Binary attribute, `true` if the parameter can have a null value */ - nullable?: GirBoolean - /** @deprecated Replaced by {@link allow-none} */ - 'null-ok'?: GirBoolean - /** @deprecated Replaced by {@link nullable} and {@link optional} */ - 'allow-none'?: GirBoolean - /** Binary attribute which is GirBoolean(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: GirBoolean - /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ - closure?: GirUnparsedNumber /** integer */ - /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ - destroy?: GirUnparsedNumber /** integer */ - /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocation (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ - scope?: 'notified' | 'async' | 'call' - /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ - direction?: GirDirection - /** Binary attribute, `true` if the caller should allocate the parameter before calling the callable */ - 'caller-allocates'?: GirBoolean - /** Binary attribute, `true` if the parameter is optional */ - optional?: GirBoolean - /** Binary attribute, `true` if the parameter can be omitted from the introspected output */ - skip?: GirBoolean - } - - varargs?: GirVarArgs[] +import type { PartOfClass, TsParameter } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirCallableParamElement extends PartOfClass, parser.GirCallableParamElement { _tsData?: TsParameter } diff --git a/packages/lib/src/types/gir-callable-param.ts b/packages/lib/src/types/gir-callable-param.ts deleted file mode 100644 index 8966bd920..000000000 --- a/packages/lib/src/types/gir-callable-param.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { GirCallableParamElement, GirInstanceParameter } from './index.js' - -// Refer to https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Support_for_GObject_closures -export interface GirCallableParams { - /** parameters element of a callable, that is in general parameters of a function or similar */ - parameter: GirCallableParamElement[] - /** instance-parameter is a parameter of a C function which is an instance of an existing object. So the callable is surely a method of a class, and this parameter points to the instance of the object. In C++, this would be equivalent to the pointer this which is not passed to the method, in Python it's equivalent to self. */ - 'instance-parameter'?: GirInstanceParameter[] -} diff --git a/packages/lib/src/types/gir-callable-params.ts b/packages/lib/src/types/gir-callable-params.ts new file mode 100644 index 000000000..fd52f7d0a --- /dev/null +++ b/packages/lib/src/types/gir-callable-params.ts @@ -0,0 +1,8 @@ +import * as parser from '@gi.ts/parser' +import { GirCallableParamElement } from './gir-callable-param-element' +import { GirInstanceParameter } from './gir-instance-parameter' + +export interface GirCallableParams extends parser.GirCallableParams { + parameter: GirCallableParamElement[] + 'instance-parameter'?: GirInstanceParameter[] +} diff --git a/packages/lib/src/types/gir-callable-return.ts b/packages/lib/src/types/gir-callable-return.ts index 5d781b14c..319991dfc 100644 --- a/packages/lib/src/types/gir-callable-return.ts +++ b/packages/lib/src/types/gir-callable-return.ts @@ -1,25 +1,7 @@ -import { PartOfClass, GirTransferOwnership, GirDocElement, GirAnyType, GirUnparsedNumber, GirBoolean } from './index.js' - -export interface GirCallableReturn extends PartOfClass, GirAnyType, GirDocElement { - /** return value of a callable */ - $: { - name?: string - /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: GirBoolean - /** Binary attribute, true if the parameter can have a null value */ - nullable?: GirBoolean - /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ - closure?: GirUnparsedNumber /** integer */ - /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocationi (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ - scope?: 'notified' | 'async' | 'call' - /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ - destroy?: GirUnparsedNumber /** integer */ - /** Binary attribute, true if the parameter can be omitted from the introspected output */ - skip?: GirBoolean - /** @deprecated Replaced by nullable and optional */ - 'allow-none'?: GirBoolean - } & Partial +import { PartOfClass } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirCallableReturn extends PartOfClass, parser.GirCallableReturn { // CUSTOM girTypeName?: 'callable-return' } diff --git a/packages/lib/src/types/gir-callback-element.ts b/packages/lib/src/types/gir-callback-element.ts index 57b8b6864..78e329b68 100644 --- a/packages/lib/src/types/gir-callback-element.ts +++ b/packages/lib/src/types/gir-callback-element.ts @@ -1,26 +1,7 @@ -import { - GirBoolean, - GirInfoElements, - GirInfoAttrs, - GirCallableParams, - GirCallableReturn, - PartOfModule, - TsCallback, -} from './index.js' - -export interface GirCallbackElement extends PartOfModule, GirInfoElements { - /** A callback closure, that is a function called when a signal is emitted (as an answer to that signal) */ - $: GirInfoAttrs & { - /** name of the callback */ - name: string - /** the C type returned by the callback closure (i.e. function) */ - 'c:type'?: string - /** Binary attribute, true if the callback can throw an error */ - throws?: GirBoolean - } - - /* Other elements a property can contain */ +import { GirCallableParams, GirCallableReturn, PartOfModule, TsCallback } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirCallbackElement extends PartOfModule, parser.GirCallbackElement { parameters?: [GirCallableParams] 'return-value'?: GirCallableReturn[] diff --git a/packages/lib/src/types/gir-class-element.ts b/packages/lib/src/types/gir-class-element.ts index 589e8c8f1..aadfe713a 100644 --- a/packages/lib/src/types/gir-class-element.ts +++ b/packages/lib/src/types/gir-class-element.ts @@ -1,58 +1,22 @@ -import type { - GirBoolean, - GirInfoElements, - GirInfoAttrs, - PartOfModule, +import { + GirCallbackElement, + GirConstantElement, GirConstructorElement, + GirFieldElement, + GirFunctionElement, GirImplements, GirMethodElement, - GirFunctionElement, - GirVirtualMethodElement, - GirFieldElement, GirPropertyElement, + GirRecordElement, GirSignalElement, GirUnionElement, - GirConstantElement, - GirRecordElement, - GirCallbackElement, + GirVirtualMethodElement, + PartOfModule, TsClass, } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirClassElement extends PartOfModule, GirInfoElements { - /** GObject inherited class definition */ - $: GirInfoAttrs & { - /** Name of the class */ - name: string - /** GObject compatible type name of the class */ - 'glib:type-name': string - /** Function to get the GObject compatible type of the class */ - 'glib:get-type': string - /** Name of the parent class if any */ - parent?: string - /** GObject compatible C structure defining the class */ - 'glib:type-struct'?: string - /** GObject compatible function to reference or increase the reference count of the class */ - 'glib:ref-func'?: string - /** GObject compatible function to unreference or decrease the reference count of the class */ - 'glib:unref-func'?: string - /** GObject compatible function to set a value of a property of the class */ - 'glib:set-value-func'?: string - /** GObject compatible function to get a value of a property of the class */ - 'glib:get-value-func'?: string - /** C type of the class */ - 'c:type'?: string - /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefix'?: string - /** Binary attribute to declare the class abstract or not */ - abstract?: GirBoolean - /** Binary attribute to declare the class fundamental or not (top-level class which do not derives from any other type) */ - 'glib:fundamental'?: GirBoolean - /** Binary attribute to declare the class final or not (non-derivable class in a derivable hierarchy) */ - final: GirBoolean - } - - /* Other elements a class can contain */ - +export interface GirClassElement extends PartOfModule, parser.GirClassElement { implements?: GirImplements[] constructor?: GirConstructorElement[] method?: GirMethodElement[] diff --git a/packages/lib/src/types/gir-constant-element.ts b/packages/lib/src/types/gir-constant-element.ts index e72ccf900..e42dc17d5 100644 --- a/packages/lib/src/types/gir-constant-element.ts +++ b/packages/lib/src/types/gir-constant-element.ts @@ -1,17 +1,6 @@ -import type { GirInfoElements, GirAnyType, GirInfoAttrs, PartOfModule, TsVar } from './index.js' - -export interface GirConstantElement extends PartOfModule, GirInfoElements, GirAnyType { - /** A constant entity, similar to const variable in C */ - $: GirInfoAttrs & { - /** name of the constant */ - name: string - /** value of the constant */ - value: string - /** corresponding C type of the constant in C */ - 'c:type'?: string - /** corresponding C identifier in the source code */ - 'c:identifier'?: string - } +import type { PartOfModule, TsVar } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirConstantElement extends PartOfModule, parser.GirConstantElement { _tsData?: TsVar } diff --git a/packages/lib/src/types/gir-constructor-element.ts b/packages/lib/src/types/gir-constructor-element.ts index 5571699f7..231a96f1f 100644 --- a/packages/lib/src/types/gir-constructor-element.ts +++ b/packages/lib/src/types/gir-constructor-element.ts @@ -1,16 +1,7 @@ -import { - GirInfoAttrs, - GirCallableAttrs, - GirCallableParams, - GirCallableReturn, - PartOfClass, - TsFunction, -} from './index.js' - -export interface GirConstructorElement extends PartOfClass { - /** A constructor of a class */ - $: GirInfoAttrs & GirCallableAttrs +import { GirCallableParams, GirCallableReturn, PartOfClass, TsFunction } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirConstructorElement extends parser.GirConstructorElement, PartOfClass { parameters?: [GirCallableParams] 'return-value'?: GirCallableReturn[] diff --git a/packages/lib/src/types/gir-direction.ts b/packages/lib/src/types/gir-direction.ts deleted file mode 100644 index 1b93b8087..000000000 --- a/packages/lib/src/types/gir-direction.ts +++ /dev/null @@ -1,7 +0,0 @@ -export enum GirDirection { - In = 'in', - Inout = 'inout', - Out = 'out', - /** @deprecated */ - InOut = 'in-out', -} diff --git a/packages/lib/src/types/gir-doc-element.ts b/packages/lib/src/types/gir-doc-element.ts deleted file mode 100644 index 3b625b844..000000000 --- a/packages/lib/src/types/gir-doc-element.ts +++ /dev/null @@ -1,73 +0,0 @@ -// Documentation of elements -// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts -export interface GirDocElement { - /** Version of the documentation */ - 'doc-version'?: [ - { - $: { - /** Preserve the original formatting of the documentation from the source code */ - 'xml:space'?: 'preserve' - /** Preserve the original formatting of the documentation from the source code. Recommended to use this instead of xml:space */ - 'xml:whitespace'?: 'preserve' - } - /** the text of the version of the documentation */ - _: string - }, - ] - /** give the stability of the documentation */ - 'doc-stability'?: [ - { - $: { - /** Preserve the original formatting of the documentation from the source code */ - 'xml:space'?: 'preserve' - /** Preserve the original formatting of the documentation from the source code. Recommended to use this instead of xml:space */ - 'xml:whitespace'?: 'preserve' - /** a text value about the stability of the documentation. Usually a simple description like stable or unstable */ - } - _: string - }, - ] - /** documentation of an element */ - doc: [ - { - $: { - /** Preserve the original formatting of the documentation from the source code */ - 'xml:space'?: 'preserve' - /** Keep the whitespace as they were in the source code */ - 'xml:whitespace'?: 'preserve' - /** The file containing this documentation */ - filename: string - /** The first line of the documentation in the source code */ - line: string - /** The first column of the documentation in the source code */ - column: string - /** the text of the documentation */ - } - _: string - }, - ] - /** Deprecated documentation of an element. Kept for historical reasons in general */ - 'doc-deprecated': [ - { - $: { - /** Preserve the original formatting of the documentation from the source code */ - 'xml:space'?: 'preserve' - /** Keep the whitespace as they were in the source code */ - 'xml:whitespace'?: 'preserve' - /** the text of the deprecated documentation */ - } - _: string - }, - ] - /** Position of the documentation in the original source code */ - 'source-position': [ - { - /** File name of the source of the documentation */ - filename: string - /** The first line of the documentation in the source code */ - line: string - /** The first column of the documentation in the source code */ - column: string[] - }, - ] -} diff --git a/packages/lib/src/types/gir-enum-element.ts b/packages/lib/src/types/gir-enum-element.ts index c1e39cdd7..85979ef4d 100644 --- a/packages/lib/src/types/gir-enum-element.ts +++ b/packages/lib/src/types/gir-enum-element.ts @@ -1,26 +1,7 @@ -import type { - GirFunctionElement, - GirMemberElement, - GirInfoAttrs, - GirInfoElements, - PartOfModule, - TsEnum, -} from './index.js' +import type { GirFunctionElement, GirMemberElement, PartOfModule, TsEnum } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirEnumElement extends PartOfModule, GirInfoElements { - /** element defining a enumeration type similar to enum in C/C++ */ - $: GirInfoAttrs & { - /** name of the enumeration */ - name: string - /** corresponding C type of the enumeration type */ - 'c:type': string - /** GObject compatible type name */ - 'glib:type-name'?: string - /** function to retrieve the GObject compatible type of the element */ - 'glib:get-type'?: string - /** Error domain of this enumeration in a stringified form */ - 'glib:error-domain'?: string - } +export interface GirEnumElement extends PartOfModule, parser.GirEnumElement { member?: GirMemberElement[] function?: GirFunctionElement[] diff --git a/packages/lib/src/types/gir-field-element.ts b/packages/lib/src/types/gir-field-element.ts index 19b4d291a..9ec9b35fd 100644 --- a/packages/lib/src/types/gir-field-element.ts +++ b/packages/lib/src/types/gir-field-element.ts @@ -1,30 +1,7 @@ -import { - GirInfoElements, - GirAnyType, - GirInfoAttrs, - GirBoolean, - GirUnparsedNumber, - GirCallbackElement, - PartOfClass, - TsVar, -} from './index.js' +import { GirCallbackElement, PartOfClass, TsVar } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirFieldElement extends PartOfClass, GirInfoElements, GirAnyType { - /** A field of struct of union structure, that is a C bit field, that is a fixed length in bits variable */ - $: GirInfoAttrs & { - /** name of the field */ - name: string - /** Binary attribute, true if the field is writeable */ - writable?: GirBoolean - /** Binary attribute, true if the field is readable */ - readable?: GirBoolean - /** Binary attribute, true if the field is private to the structure or has public ("0") visibility */ - private?: GirBoolean - /** number of bits of the field */ - bits?: GirUnparsedNumber /** integer */ - } - - /* Other elements a property can contain */ +export interface GirFieldElement extends PartOfClass, parser.GirFieldElement { callback?: GirCallbackElement[] _tsData?: TsVar diff --git a/packages/lib/src/types/gir-function-element.ts b/packages/lib/src/types/gir-function-element.ts index fba57fbaa..2edd89fc0 100644 --- a/packages/lib/src/types/gir-function-element.ts +++ b/packages/lib/src/types/gir-function-element.ts @@ -1,17 +1,7 @@ -import type { - GirCallableAttrs, - GirInfoAttrs, - GirDocElement, - PartOfClass, - GirCallableParams, - GirCallableReturn, - TsMethod, -} from './index.js' - -export interface GirFunctionElement extends PartOfClass, GirDocElement { - /** element defining a standalone function (as usual in most programming languages) */ - $: GirInfoAttrs & GirCallableAttrs +import type { GirCallableParams, GirCallableReturn, PartOfClass, TsMethod } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirFunctionElement extends PartOfClass, parser.GirFunctionElement { parameters?: [GirCallableParams] 'return-value'?: GirCallableReturn[] diff --git a/packages/lib/src/types/gir-implements.ts b/packages/lib/src/types/gir-implements.ts deleted file mode 100644 index 356372991..000000000 --- a/packages/lib/src/types/gir-implements.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { GirInfoAttrs } from './index.js' - -export interface GirImplements { - /** Give the name of the interface it implements. This element is generally used within a class element */ - $: GirInfoAttrs & { - /** name of the interface implemented by a class */ - name: string - } -} diff --git a/packages/lib/src/types/gir-include.ts b/packages/lib/src/types/gir-include.ts deleted file mode 100644 index a1115ce12..000000000 --- a/packages/lib/src/types/gir-include.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface GirInclude { - /** Dependant namespace to include with the current namespace. For example, Gtk will need the namespace GLib */ - $: { - /** name of the dependant namespace to include */ - name: string - /** version of the dependant namespace to use */ - version?: string - } -} diff --git a/packages/lib/src/types/gir-info-attrs.ts b/packages/lib/src/types/gir-info-attrs.ts deleted file mode 100644 index 27b59a6d4..000000000 --- a/packages/lib/src/types/gir-info-attrs.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { GirBoolean } from './gir-boolean' - -// Some base information for most elements like version, deprecation, stability, if they are introspectable or not, etc... -// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts -export interface GirInfoAttrs { - /** Binary attribute which is GirBoolean(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: GirBoolean - /** Binary attribute which isBinaryOption (true) if the element has been deprecated */ - deprecated?: string - /** Version number from which this element is deprecated */ - 'deprecated-version'?: string - /** version number of an element */ - version?: string - /** give the statibility status of the element. Can take the values "Stable", "Unstable" or "Private" */ - stability?: string[] -} diff --git a/packages/lib/src/types/gir-info-elements.ts b/packages/lib/src/types/gir-info-elements.ts deleted file mode 100644 index 7dbf2de41..000000000 --- a/packages/lib/src/types/gir-info-elements.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { GirAnnotation } from './gir-annotation' -import { GirDocElement } from './gir-doc-element' - -// Information about elements can be a documentation of annotations -// https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts -export interface GirInfoElements extends GirDocElement { - annotation: GirAnnotation[] -} diff --git a/packages/lib/src/types/gir-instance-parameter.ts b/packages/lib/src/types/gir-instance-parameter.ts index f8243e0f2..fa93ccf7e 100644 --- a/packages/lib/src/types/gir-instance-parameter.ts +++ b/packages/lib/src/types/gir-instance-parameter.ts @@ -1,27 +1,11 @@ -import { GirBoolean, GirAnyType, GirTransferOwnership, GirDirection, GirType, TsInstanceParameter } from './index.js' +import { TsInstanceParameter } from './index.js' +import * as parser from '@gi.ts/parser' /** * instance-parameter is a parameter of a C function which is an instance of an existing object. * So the callable is surely a method of a class, and this parameter points to the instance of the object. * In C++, this would be equivalent to the pointer this which is not passed to the method, in Python it's equivalent to self. **/ -export interface GirInstanceParameter extends GirAnyType { - $: Partial<{ - /** name of the instance-parameter */ name: string - /** Binary attribute, true if the parameter can have a null value */ - nullable?: GirBoolean - /** @deprecated Replaced by nullable and optional */ - 'allow-none'?: GirBoolean - /** @deprecated Replaced by {@link allow-none} */ - 'null-ok'?: GirBoolean - /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ - direction?: GirDirection - /** Binary attribute, true if the caller should allocate the parameter before calling the callable */ - 'caller-allocates'?: GirBoolean - }> & - Partial - type?: GirType[] - - // CUSTOM +export interface GirInstanceParameter extends parser.GirInstanceParameter { _tsData?: TsInstanceParameter } diff --git a/packages/lib/src/types/gir-interface-element.ts b/packages/lib/src/types/gir-interface-element.ts index 8e66582de..b0a383adc 100644 --- a/packages/lib/src/types/gir-interface-element.ts +++ b/packages/lib/src/types/gir-interface-element.ts @@ -1,45 +1,25 @@ import { - GirInfoElements, - GirPrerequisite, - GirImplements, + GirCallbackElement, + GirConstantElement, GirConstructorElement, - GirMethodElement, - GirVirtualMethodElement, - GirFunctionElement, GirFieldElement, + GirFunctionElement, + GirImplements, + GirMethodElement, + GirPrerequisite, GirPropertyElement, - GirCallbackElement, - GirConstantElement, GirSignalElement, + GirVirtualMethodElement, PartOfModule, TsClass, } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirInterfaceElement extends PartOfModule, GirInfoElements { - /** Abstract interface to other classes */ - $: { - //Attributes of an Interface (see definition below) - - /** name of the interface */ - name: string - /** Type name compatible with the GObject type system */ - 'glib:type-name': string - /** Function to get the GObject compatible type of the interface */ - 'glib:get-type': string - /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefix'?: string - /** Corresponding C type */ - 'c:type'?: string - /** GObject compatible C structure defining the Interface */ - 'glib:type-struct'?: string - } - - //Other elements an interface can contain - +export interface GirInterfaceElement extends PartOfModule, parser.GirInterfaceElement { prerequisite?: GirPrerequisite[] implements?: GirImplements[] function?: GirFunctionElement[] - constructors?: GirConstructorElement[] // Typed as optional + constructors?: GirConstructorElement[] method?: GirMethodElement[] 'virtual-method'?: GirVirtualMethodElement[] field?: GirFieldElement[] diff --git a/packages/lib/src/types/gir-member-element.ts b/packages/lib/src/types/gir-member-element.ts index 43ee391e8..7ac4bd87b 100644 --- a/packages/lib/src/types/gir-member-element.ts +++ b/packages/lib/src/types/gir-member-element.ts @@ -1,19 +1,8 @@ -import { GirInfoElements, GirInfoAttrs, TsMember } from './index.js' +import { GirCallableParams, TsMember } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirMemberElement extends GirInfoElements { - /** element defining a member of a bit field or an enumeration */ - $: GirInfoAttrs & { - /** name of the member */ - name: string - /** value of the member */ - value: string - /** corresponding C type of the member */ - 'c:identifier': string - /** short nickname of the member (from GEnumValue/GFlagsValue) */ - 'glib:nick'?: string - /** name of the member (from GEnumValue/GFlagsValue) */ - 'glib:name'?: string - } +export interface GirMemberElement extends parser.GirMemberElement { + parameters: [GirCallableParams] _tsData?: TsMember } diff --git a/packages/lib/src/types/gir-method-element.ts b/packages/lib/src/types/gir-method-element.ts index 6d86f1897..77667666c 100644 --- a/packages/lib/src/types/gir-method-element.ts +++ b/packages/lib/src/types/gir-method-element.ts @@ -1,23 +1,8 @@ -import { - GirDocElement, - GirInfoAttrs, - GirCallableAttrs, - GirCallableParams, - GirCallableReturn, - TsMethod, - PartOfClass, -} from './index.js' - -export interface GirMethodElement extends PartOfClass, GirDocElement { - /** element defining a method from a class */ - $: GirInfoAttrs & - GirCallableAttrs & { - /** The GObject property that is set by this method */ - 'glib:set-property': string - /** The GObject property that is retrieved by this method */ - 'glib:get-property': string - } +import { GirCallableParams } from './gir-callable-params.js' +import { TsMethod, PartOfClass, GirCallableReturn } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirMethodElement extends PartOfClass, parser.GirMethodElement { parameters?: [GirCallableParams] 'return-value'?: GirCallableReturn[] diff --git a/packages/lib/src/types/gir-namespace.ts b/packages/lib/src/types/gir-namespace.ts index 4e5a1641b..dc046d9e4 100644 --- a/packages/lib/src/types/gir-namespace.ts +++ b/packages/lib/src/types/gir-namespace.ts @@ -1,37 +1,19 @@ -import { - GirInfoAttrs, - GirInterfaceElement, - GirRecordElement, - GirUnionElement, - GirEnumElement, - GirAliasElement, - GirFunctionElement, - GirClassElement, - GirBitfieldElement, - GirCallbackElement, - GirConstantElement, - GirAnnotation, - GirBoxedElement, -} from './index.js' +import * as parser from '@gi.ts/parser' -/** Namespace which maps metadata entries to C functionality. This a similar concept to namespace in C++, but for GObject-based C libraries */ -export interface GirNamespace { - $: GirInfoAttrs & { - /** name of the namespace. For example, 'Gtk' (technically optional) */ - name: string - /** version number of the namespace (technically optional) */ - version: string - /** prefixes to filter out from C identifiers for data structures and types. For example, GtkWindow will be Window. If c:symbol-prefixes is not used, then this element is used for both */ - 'c:identifier-prefixes'?: string - /** prefixes to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefixes'?: string - /** @deprecated the same as c:identifier-prefixes. Only used for backward compatibility */ - 'c:prefix'?: string - /** Path to the shared library implementing the namespace. It can be a comma-separated list, with relative path only */ - 'shared-library'?: string - } +import { GirBoxedElement } from '@gi.ts/parser' +import { GirAliasElement } from './gir-alias-element' +import { GirBitfieldElement } from './gir-bitfield-element' +import { GirCallbackElement } from './gir-callback-element' +import { GirClassElement } from './gir-class-element' +import { GirFunctionElement } from './gir-function-element' +import { GirRecordElement } from './gir-record-element' +import { GirUnionElement } from './gir-union-element' +import { GirConstantElement } from './gir-constant-element' +import { GirAnnotation } from './gir-annotation' +import { GirInterfaceElement } from './gir-interface-element' +import { GirEnumElement } from './gir-enum-element' - /* Other elements a namespace can contain */ +export interface GirNamespace extends parser.GirNamespace { alias?: GirAliasElement[] class?: GirClassElement[] interface?: GirInterfaceElement[] diff --git a/packages/lib/src/types/gir-package.ts b/packages/lib/src/types/gir-package.ts deleted file mode 100644 index 457b211cf..000000000 --- a/packages/lib/src/types/gir-package.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface GirPackage { - /** @deprecated package name containing the library */ - $: { - /** name of the package */ - name: string - } -} diff --git a/packages/lib/src/types/gir-prerequisite.ts b/packages/lib/src/types/gir-prerequisite.ts deleted file mode 100644 index f2a7f25e4..000000000 --- a/packages/lib/src/types/gir-prerequisite.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface GirPrerequisite { - $: { - name?: string - } -} diff --git a/packages/lib/src/types/gir-property-element.ts b/packages/lib/src/types/gir-property-element.ts index 9605b0813..ac0413213 100644 --- a/packages/lib/src/types/gir-property-element.ts +++ b/packages/lib/src/types/gir-property-element.ts @@ -1,33 +1,6 @@ -import { - GirBoolean, - GirInfoAttrs, - GirInfoElements, - GirAnyType, - GirTransferOwnership, - PartOfClass, - TsProperty, -} from './index.js' - -export interface GirPropertyElement extends PartOfClass, GirInfoElements, GirAnyType { - /** Property, that is a variable or members with getter and setter functions */ - $: GirInfoAttrs & { - /** name of the property */ - name: string - /** Binary attribute, true if the property is writeable, that is it has a setter function */ - writable?: GirBoolean - /** Binary attribute, true if the property is readable, that is it has a getter function */ - readable?: GirBoolean - /** Binary attribute, true if the property will be set upon construction */ - construct?: GirBoolean - /** Binary attribute, true if the property can only be set upon construction */ - 'construct-only'?: GirBoolean - /** The setter function for this property */ - setter?: string - /** The getter function for this property */ - getter?: string - /** The value of the property when it is not set */ - 'default-value'?: string - } & Partial +import { PartOfClass, TsProperty } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirPropertyElement extends PartOfClass, parser.GirPropertyElement { _tsData?: TsProperty } diff --git a/packages/lib/src/types/gir-record-element.ts b/packages/lib/src/types/gir-record-element.ts index 6278798ac..0dc7c3ee2 100644 --- a/packages/lib/src/types/gir-record-element.ts +++ b/packages/lib/src/types/gir-record-element.ts @@ -1,41 +1,17 @@ import { - GirBoolean, - GirInfoElements, - GirInfoAttrs, + GirConstructorElement, GirFieldElement, GirFunctionElement, - GirUnionElement, GirMethodElement, - GirConstructorElement, GirPropertyElement, + GirUnionElement, PartOfModule, TsClass, } from './index.js' -export interface GirRecordElement extends PartOfModule, GirInfoElements { - /** Record definition, equivalent to a C struct, that is a simple structure, not a class */ - $: GirInfoAttrs & { - /** name of the record */ - name: string - /** Corresponding C type of the record */ - 'c:type'?: string - /** Binary attribute to tell if the record is disguised, i.e. whether the c:type is a typedef that doesn't look like a pointer, but is one internally */ - /** Its second meaning is "private" and is set when any typedef struct is parsed which doesn't also include a full struct with fields (https://gitlab.gnome.org/GNOME/gobject-introspection/issues/101) */ - disguised?: GirBoolean - /** GObject compatible C type of the record */ - 'glib:type-name'?: string - /** Function to get the GObject compatible type of the record */ - 'glib:get-type'?: string - /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefix'?: string - /** Binary attribute to tell if the record is foreign, that is it is not available in a g-i supported library */ - foreign?: GirBoolean - /** Name of the GObject compatible gtype this record represents. If }, this record will be hidden from generated public APIs. */ - 'glib:is-gtype-struct-for'?: string - } - - /* Other elements a record can contain */ +import * as parser from '@gi.ts/parser' +export interface GirRecordElement extends PartOfModule, parser.GirRecordElement { field?: GirFieldElement[] function?: GirFunctionElement[] union?: GirUnionElement[] diff --git a/packages/lib/src/types/gir-repository.ts b/packages/lib/src/types/gir-repository.ts index b0aa5cfff..65f0facea 100644 --- a/packages/lib/src/types/gir-repository.ts +++ b/packages/lib/src/types/gir-repository.ts @@ -1,20 +1,6 @@ -import { GirInclude, GirNamespace, GirCInclude, GirPackage } from './index.js' - -/** Root node of a GIR repository. It contains namespaces, which can in turn be implemented in several libraries */ -export interface GirRepository { - $: { - /** version number of the repository */ - version?: string - /** prefixes to filter out from C identifiers for data structures and types. For example, GtkWindow will be Window. If c:symbol-prefixes is not used, then this element is used for both */ - 'c:identifier-prefixes'?: string - /** prefixes to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefixes'?: string - } - - /* Other elements a repository can contain */ - include?: GirInclude[] - 'c:include': GirCInclude[] - package: GirPackage[] +import * as parser from '@gi.ts/parser' +import { GirNamespace } from './gir-namespace' +export interface GirRepository extends parser.GirRepository { namespace?: GirNamespace[] } diff --git a/packages/lib/src/types/gir-signal.ts b/packages/lib/src/types/gir-signal.ts index 1c22b07c1..20a34e47d 100644 --- a/packages/lib/src/types/gir-signal.ts +++ b/packages/lib/src/types/gir-signal.ts @@ -1,39 +1,18 @@ import { - GirCallableReturn, - GirBoolean, - GirInfoAttrs, - GirInfoElements, - GirCallableParams, PartOfModule, GirClassElement, GirRecordElement, GirInterfaceElement, TsSignal, + GirCallableParams, + GirCallableReturn, } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirSignalElement extends PartOfModule, GirInfoElements { - /** A signal as defined in the GObject system (https://docs.gtk.org/gobject/concepts.html#signals) */ - $: GirInfoAttrs & { - /** name of the signal */ - name: string - /** Binary attribute, true if the signal has a detailed parameter (https://docs.gtk.org/gobject/concepts.html#the-detail-argument and https://docs.gtk.org/gobject/flags.SignalFlags.html) */ - detailed?: GirBoolean - /** When to run the signal during the 5 steps of signal emission (https://docs.gtk.org/gobject/concepts.html#signal-emission and https://docs.gtk.org/gobject/flags.SignalFlags.html) */ - when?: 'first' | 'last' | 'cleanup' - /** Binary attribute, true if the signal can be freely emitted on alive objects from user code (https://docs.gtk.org/gobject/flags.SignalFlags.html) */ - action?: GirBoolean - /** Binary attribute, true if no emission hooks are supported for this signal (https://docs.gtk.org/gobject/flags.SignalFlags.html) */ - 'no-hooks'?: GirBoolean - /** Binary attribute, true if signals emitted for an object while currently being in emission for this very object will not be emitted recursively, but instead cause the first emission to be restarted (https://docs.gtk.org/gobject/flags.SignalFlags.html) */ - 'no-recurse'?: GirBoolean - } - /* Other elements a property can contain */ - +export interface GirSignalElement extends PartOfModule, parser.GirSignalElement { parameters?: [GirCallableParams] 'return-value'?: GirCallableReturn[] - // CUSTOM - /** * The class this function is defined in */ diff --git a/packages/lib/src/types/gir-transfer-ownership-type.ts b/packages/lib/src/types/gir-transfer-ownership-type.ts deleted file mode 100644 index 97671f5ea..000000000 --- a/packages/lib/src/types/gir-transfer-ownership-type.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum GirTransferOwnershipType { - Container = 'container', - Full = 'full', - None = 'none', -} diff --git a/packages/lib/src/types/gir-transfer-ownership.ts b/packages/lib/src/types/gir-transfer-ownership.ts deleted file mode 100644 index 6bf5d4de7..000000000 --- a/packages/lib/src/types/gir-transfer-ownership.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { GirTransferOwnershipType } from './gir-transfer-ownership-type' - -export interface GirTransferOwnership { - /** attributes used by many elements for the transfer of ownership, with for example, a returned value. - * - "none" if the recipient does not own the value, - * - "container" if the recipient owns the container but not the value (for arrays or lists for example), - * - "full" the recipient owns the entire value. - * For details, see https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Memory_and_lifecycle_management */ - 'transfer-ownership': GirTransferOwnershipType -} diff --git a/packages/lib/src/types/gir-type.ts b/packages/lib/src/types/gir-type.ts deleted file mode 100644 index c7abba668..000000000 --- a/packages/lib/src/types/gir-type.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { GirArrayType, GirBoolean, GirInfoAttrs, GirDocElement } from './index.js' - -export interface GirType extends GirDocElement { - /** A simple type of data (as opposed to an array) */ - $: GirInfoAttrs & { - /** name of the type */ - name?: string - /** the C representation of the type */ - 'c:type'?: string - /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: GirBoolean - } - - array?: GirArrayType[] - type: GirType[] -} diff --git a/packages/lib/src/types/gir-union-element.ts b/packages/lib/src/types/gir-union-element.ts index 38660e04b..66b8e6685 100644 --- a/packages/lib/src/types/gir-union-element.ts +++ b/packages/lib/src/types/gir-union-element.ts @@ -1,30 +1,15 @@ import type { - GirInfoElements, - GirInfoAttrs, GirConstructorElement, - GirMethodElement, - GirFunctionElement, GirFieldElement, + GirFunctionElement, + GirMethodElement, GirRecordElement, PartOfModule, TsClass, } from './index.js' +import * as parser from '@gi.ts/parser' -export interface GirUnionElement extends PartOfModule, GirInfoElements { - /** element defining a type of data being a union of type, similar to union in C/C++ but extended with fields and methods */ - $: GirInfoAttrs & { - /** name of the union */ - name?: string - /** C type defining the union */ - 'c:type'?: string - /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ - 'c:symbol-prefix'?: string - /** GObject compatible type name */ - 'glib:type-name'?: string - /** function to retrieve the GObject compatible type of the element */ - 'glib:get-type'?: string - } - +export interface GirUnionElement extends PartOfModule, parser.GirUnionElement { field?: GirFieldElement[] constructor?: GirConstructorElement[] method?: GirMethodElement[] diff --git a/packages/lib/src/types/gir-var-args.ts b/packages/lib/src/types/gir-var-args.ts deleted file mode 100644 index 818a80ad7..000000000 --- a/packages/lib/src/types/gir-var-args.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { GirInfoAttrs } from './index.js' - -export interface GirVarArgs { - /** an element, usually found in a parameter element for variadic parameter in a function or callable */ - $: GirInfoAttrs -} diff --git a/packages/lib/src/types/gir-virtual-method.ts b/packages/lib/src/types/gir-virtual-method.ts index da4f50993..1a48d7d1f 100644 --- a/packages/lib/src/types/gir-virtual-method.ts +++ b/packages/lib/src/types/gir-virtual-method.ts @@ -1,20 +1,7 @@ -import { - GirCallableAttrs, - GirInfoAttrs, - PartOfClass, - GirDocElement, - TsMethod, - GirCallableReturn, - GirCallableParams, -} from './index.js' - -export interface GirVirtualMethodElement extends PartOfClass, GirDocElement { - $: GirInfoAttrs & - GirCallableAttrs & { - /** name of the callable called when invoking this virtual method */ - invoker?: string - } +import { GirCallableParams, GirCallableReturn, PartOfClass, TsMethod } from './index.js' +import * as parser from '@gi.ts/parser' +export interface GirVirtualMethodElement extends PartOfClass, parser.GirVirtualMethodElement { parameters?: [GirCallableParams] 'return-value'?: GirCallableReturn[] diff --git a/packages/lib/src/types/index.ts b/packages/lib/src/types/index.ts index 077890dd6..907c7393a 100644 --- a/packages/lib/src/types/index.ts +++ b/packages/lib/src/types/index.ts @@ -14,50 +14,52 @@ export * from './generate-config.js' export * from './gir-alias-element.js' export * from './gir-annotation.js' export * from './gir-any-element.js' -export * from './gir-any-type.js' -export * from './gir-array-type.js' +export { + GirAnyType, + GirArrayType, + GirBoolean, + GirBoxedElement, + GirCInclude, + GirCallableAttrs, + GirDirection, + GirDocElement, + GirImplements, + GirInclude, + GirInfoAttrs, + GirInfoElements, + GirPackage, + GirPrerequisite, + GirTransferOwnership, + GirTransferOwnershipType, + GirType, + GirVarArgs, +} from '@gi.ts/parser' export * from './gir-bitfield-element.js' -export * from './gir-boolean.js' -export * from './gir-boxed-element.js' -export * from './gir-c-include.js' -export * from './gir-callable-attrs.js' + export * from './gir-callable-param-element.js' -export * from './gir-callable-param.js' +export * from './gir-callable-params.js' export * from './gir-callable-return.js' export * from './gir-callback-element.js' export * from './gir-class-element.js' export * from './gir-constant-element.js' export * from './gir-constructor-element.js' -export * from './gir-direction.js' -export * from './gir-doc-element.js' export * from './gir-enum-element.js' export * from './gir-field-element.js' export * from './gir-function-element.js' -export * from './gir-implements.js' -export * from './gir-include.js' -export * from './gir-info-attrs.js' -export * from './gir-info-elements.js' export * from './gir-instance-parameter.js' export * from './gir-interface-element.js' +export * from './gir-namespace.js' export * from './gir-member-element.js' export * from './gir-method-element.js' export * from './gir-module-resolved-by.js' export * from './gir-modules-grouped-map.js' export * from './gir-modules-grouped.js' -export * from './gir-namespace.js' -export * from './gir-package.js' -export * from './gir-prerequisite.js' export * from './gir-property-element.js' export * from './gir-record-element.js' export * from './gir-repository.js' export * from './gir-signal.js' -export * from './gir-transfer-ownership-type.js' -export * from './gir-transfer-ownership.js' -export * from './gir-type-name.js' -export * from './gir-type.js' export * from './gir-union-element.js' export * from './gir-unparsed-number.js' -export * from './gir-var-args.js' export * from './gir-virtual-method.js' export * from './inheritance-table.js' export * from './injection-callback.js' diff --git a/packages/lib/src/types/parsed-gir.ts b/packages/lib/src/types/parsed-gir.ts index 131eac889..018739f76 100644 --- a/packages/lib/src/types/parsed-gir.ts +++ b/packages/lib/src/types/parsed-gir.ts @@ -1,5 +1,6 @@ +import { GirXML } from '@gi.ts/parser' import { GirRepository } from './gir-repository' -export interface ParsedGir { - repository: GirRepository +export interface ParsedGir extends GirXML { + repository: GirRepository[] } diff --git a/packages/parser/.eslintrc.cjs b/packages/parser/.eslintrc.cjs new file mode 100644 index 000000000..5290b401a --- /dev/null +++ b/packages/parser/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "extends": [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + "rules": { + "semi": ["error", "always"], + "quotes": ["error", "double", {avoidEscape: true}], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + "camelcase": "off", + "@typescript-eslint/camelcase": "off" + }, + "parserOptions": { + "tsconfigRootDir": __dirname, + "project": ["./tsconfig.json"] + }, + "globals": { + "imports": true + } +} diff --git a/packages/parser/.prettierrc.json b/packages/parser/.prettierrc.json new file mode 100644 index 000000000..12c6cad46 --- /dev/null +++ b/packages/parser/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "all", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 + } + \ No newline at end of file diff --git a/packages/parser/package.json b/packages/parser/package.json index 67dd99991..78939d02a 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -32,6 +32,12 @@ }, "devDependencies": { "@types/xml2js": "^0.4.4", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", + "eslint": "^8.52.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.1", + "prettier": "^3.0.3", "typescript": "5.1.3" } } diff --git a/packages/parser/src/lib.ts b/packages/parser/src/lib.ts index 69b6fb48d..f5b420d83 100644 --- a/packages/parser/src/lib.ts +++ b/packages/parser/src/lib.ts @@ -1,3 +1,3 @@ export * as parser from "./parser.js"; -export * from "./xml.js"; \ No newline at end of file +export * from "./xml.js"; diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index bd9154995..5c3b97110 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -6,12 +6,12 @@ export function parseGir(contents: string): GirXML { attributeNamePrefix: "", attrNodeName: "$", // default is 'false', textNodeName: "_", - ignoreAttributes : false, - ignoreNameSpace : false, - allowBooleanAttributes : true, - parseNodeValue : true, - parseAttributeValue : false, + ignoreAttributes: false, + ignoreNameSpace: false, + allowBooleanAttributes: true, + parseNodeValue: true, + parseAttributeValue: false, trimValues: true, - arrayMode: true + arrayMode: true, }) as GirXML; -} \ No newline at end of file +} diff --git a/packages/parser/src/xml.ts b/packages/parser/src/xml.ts index 6c3d9abf7..0f826fdbf 100644 --- a/packages/parser/src/xml.ts +++ b/packages/parser/src/xml.ts @@ -6,24 +6,26 @@ // Many keys are prefixed with `glib:` in XML, this grammar preserves that syntax. -export enum Direction { +export enum GirDirection { In = "in", Inout = "inout", Out = "out", + /** @deprecated */ + InOut = "in-out", } export interface GirXML { - repository: Repository[]; + repository: GirRepository[]; } /** A type alias for fields which *should* be treated as numerical */ -type UnparsedNumber = string; +export type GirUnparsedNumber = string; /** A type alias for 'binary' (boolean) fields */ -type BinaryOption = "0" | "1"; +export type GirBoolean = "0" | "1"; /** Root node of a GIR repository. It contains namespaces, which can in turn be implemented in several libraries */ -export interface Repository { +export interface GirRepository { $: { /** version number of the repository */ version?: string; @@ -34,15 +36,15 @@ export interface Repository { }; /* Other elements a repository can contain */ - include: Include[]; - "c:include": CInclude[]; - package: Package[]; - namespace: Namespace[]; + include?: GirInclude[]; + "c:include": GirCInclude[]; + package: GirPackage[]; + namespace?: GirNamespace[]; } /** Namespace which maps metadata entries to C functionality. This a similar concept to namespace in C++, but for GObject-based C libraries */ -export interface Namespace { - $: InfoAttrs & { +export interface GirNamespace { + $: GirInfoAttrs & { /** name of the namespace. For example, 'Gtk' (technically optional) */ name: string; /** version number of the namespace (technically optional) */ @@ -51,28 +53,29 @@ export interface Namespace { "c:identifier-prefixes"?: string; /** prefixes to filter out from C functions. For example, gtk_window_new will lose gtk_ */ "c:symbol-prefixes"?: string; - /** Deprecated: the same as c:identifier-prefixes. Only used for backward compatibility */ + /** @deprecated the same as c:identifier-prefixes. Only used for backward compatibility */ "c:prefix"?: string; /** Path to the shared library implementing the namespace. It can be a comma-separated list, with relative path only */ "shared-library"?: string; }; /* Other elements a namespace can contain */ - alias?: AliasElement[]; - class?: ClassElement[]; - interface?: InterfaceElement[]; - record?: RecordElement[]; - enumeration?: EnumElement[]; - function?: FunctionElement[]; - union?: UnionElement[]; - bitfield?: BitfieldElement[]; - callback?: CallbackElement[]; - constant?: ConstantElement[]; - annotation?: Annotation[]; - ["glib:boxed"]?: BoxedElement[]; -} - -export interface Annotation { + alias?: GirAliasElement[]; + class?: GirClassElement[]; + interface?: GirInterfaceElement[]; + record?: GirRecordElement[]; + enumeration?: GirEnumElement[]; + function?: GirFunctionElement[]; + union?: GirUnionElement[]; + bitfield?: GirBitfieldElement[]; + callback?: GirCallbackElement[]; + constant?: GirConstantElement[]; + annotation?: GirAnnotation[]; + ["glib:boxed"]?: GirBoxedElement[]; +} + +// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts +export interface GirAnnotation { /** element defining an annotation from the source code, usually a user-defined annotation associated to a parameter or a return value */ $: { /** name of the attribute */ @@ -82,7 +85,7 @@ export interface Annotation { }; } -export interface CInclude { +export interface GirCInclude { /** Dependant C header file which should be included in C programs */ $: { /** File name of the C header file. The path can be relative. */ @@ -90,7 +93,7 @@ export interface CInclude { }; } -export interface Include { +export interface GirInclude { /** Dependant namespace to include with the current namespace. For example, Gtk will need the namespace GLib */ $: { /** name of the dependant namespace to include */ @@ -100,30 +103,27 @@ export interface Include { }; } -export interface Package { - /** Deprecated: package name containing the library */ +export interface GirPackage { + /** @deprecated package name containing the library */ $: { /** name of the package */ name: string; }; } -export interface AliasElement extends InfoElements { +export interface GirAliasElement extends GirInfoElements { /** Type's name substitution, representing a typedef in C */ - $: InfoAttrs & { - //Attributes of an Alias (see definition below) - + $: GirInfoAttrs & { /** the new name or typedef'd name */ name: string; /** the corresponding C type's name */ - "c:type": string; + "c:type"?: string; }; - /** Other elements an alias can contain */ - type: Type[]; + type?: GirType[]; } -export interface InterfaceElement extends InfoElements { +export interface GirInterfaceElement extends GirInfoElements { /** Abstract interface to other classes */ $: { //Attributes of an Interface (see definition below) @@ -144,22 +144,23 @@ export interface InterfaceElement extends InfoElements { //Other elements an interface can contain - prerequisite?: Prerequisite[]; - implements?: Implements[]; - function?: FunctionElement[]; - constructors?: ConstructorElement[]; // Typed as optional - method?: MethodElement[]; - "virtual-method"?: VirtualMethodElement[]; - field?: FieldElement[]; - property?: PropertyElement[]; - signal?: SignalElement[]; - callback?: CallbackElement[]; - constant?: ConstantElement[]; -} - -export interface ClassElement extends InfoElements { + prerequisite?: GirPrerequisite[]; + implements?: GirImplements[]; + function?: GirFunctionElement[]; + constructors?: GirConstructorElement[]; // Typed as optional + method?: GirMethodElement[]; + "virtual-method"?: GirVirtualMethodElement[]; + field?: GirFieldElement[]; + property?: GirPropertyElement[]; + signal?: GirSignalElement[]; + "glib:signal"?: GirSignalElement[]; + callback?: GirCallbackElement[]; + constant?: GirConstantElement[]; +} + +export interface GirClassElement extends GirInfoElements { /** GObject inherited class definition */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** Name of the class */ name: string; /** GObject compatible type name of the class */ @@ -183,30 +184,33 @@ export interface ClassElement extends InfoElements { /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ "c:symbol-prefix"?: string; /** Binary attribute to declare the class abstract or not */ - abstract?: BinaryOption | BinaryOption; + abstract?: GirBoolean; /** Binary attribute to declare the class fundamental or not (top-level class which do not derives from any other type) */ - "glib:fundamental"?: BinaryOption | BinaryOption; + "glib:fundamental"?: GirBoolean; + /** Binary attribute to declare the class final or not (non-derivable class in a derivable hierarchy) */ + final: GirBoolean; }; /* Other elements a class can contain */ - implements?: Implements[]; - "constructor"?: ConstructorElement[]; - method?: MethodElement[]; - function?: FunctionElement[]; - "virtual-method"?: VirtualMethodElement[]; - field?: FieldElement[]; - property?: PropertyElement[]; - signal?: SignalElement[]; - union?: UnionElement[]; - constant?: ConstantElement[]; - record?: RecordElement[]; - callback?: CallbackElement[]; -} - -export interface BoxedElement { + implements?: GirImplements[]; + constructor?: GirConstructorElement[]; + method?: GirMethodElement[]; + function?: GirFunctionElement[]; + "virtual-method"?: GirVirtualMethodElement[]; + field?: GirFieldElement[]; + property?: GirPropertyElement[]; + signal?: GirSignalElement[]; + "glib:signal"?: GirSignalElement[]; + union?: GirUnionElement[]; + constant?: GirConstantElement[]; + record?: GirRecordElement[]; + callback?: GirCallbackElement[]; +} + +export interface GirBoxedElement { /** Boxed type (wrapper to opaque C structures registered by the type system) */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** GObject compatible type name of the boxed type */ "glib:name": string; /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ @@ -219,19 +223,19 @@ export interface BoxedElement { /* Other elements a Boxed type can contain */ - function?: FunctionElement[]; + function?: GirFunctionElement[]; } -export interface RecordElement extends InfoElements { +export interface GirRecordElement extends GirInfoElements { /** Record definition, equivalent to a C struct, that is a simple structure, not a class */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the record */ name: string; /** Corresponding C type of the record */ "c:type"?: string; /** Binary attribute to tell if the record is disguised, i.e. whether the c:type is a typedef that doesn't look like a pointer, but is one internally */ /** Its second meaning is "private" and is set when any typedef struct is parsed which doesn't also include a full struct with fields (https://gitlab.gnome.org/GNOME/gobject-introspection/issues/101) */ - disguised?: BinaryOption | BinaryOption; + disguised?: GirBoolean; /** GObject compatible C type of the record */ "glib:type-name"?: string; /** Function to get the GObject compatible type of the record */ @@ -239,25 +243,26 @@ export interface RecordElement extends InfoElements { /** prefix to filter out from C functions. For example, gtk_window_new will lose gtk_ */ "c:symbol-prefix"?: string; /** Binary attribute to tell if the record is foreign, that is it is not available in a g-i supported library */ - foreign?: BinaryOption | BinaryOption; + foreign?: GirBoolean; /** Name of the GObject compatible gtype this record represents. If }, this record will be hidden from generated public APIs. */ "glib:is-gtype-struct-for"?: string; }; /* Other elements a record can contain */ - field?: FieldElement[]; - function?: FunctionElement[]; - union?: UnionElement[]; - method?: MethodElement[]; - "constructor"?: ConstructorElement[]; - property?: PropertyElement[]; + field?: GirFieldElement[]; + function?: GirFunctionElement[]; + union?: GirUnionElement[]; + method?: GirMethodElement[]; + constructor?: GirConstructorElement[]; + property?: GirPropertyElement[]; } -//Some base information for most elements like version, deprecation, stability, if they are introspectable or not, etc... -export interface InfoAttrs { - /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: BinaryOption | BinaryOption; +// Some base information for most elements like version, deprecation, stability, if they are introspectable or not, etc... +// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts +export interface GirInfoAttrs { + /** Binary attribute which is GirBoolean(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: GirBoolean; /** Binary attribute which isBinaryOption (true) if the element has been deprecated */ deprecated?: string; /** Version number from which this element is deprecated */ @@ -268,8 +273,9 @@ export interface InfoAttrs { stability?: string[]; } -//Documentation of elements -export interface DocElement { +// Documentation of elements +// See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts +export interface GirDocElement { /** Version of the documentation */ "doc-version"?: [ { @@ -281,7 +287,7 @@ export interface DocElement { }; /** the text of the version of the documentation */ _: string; - } + }, ]; /** give the stability of the documentation */ "doc-stability"?: [ @@ -294,7 +300,7 @@ export interface DocElement { /** a text value about the stability of the documentation. Usually a simple description like stable or unstable */ }; _: string; - } + }, ]; /** documentation of an element */ doc: [ @@ -313,7 +319,7 @@ export interface DocElement { /** the text of the documentation */ }; _: string; - } + }, ]; /** Deprecated documentation of an element. Kept for historical reasons in general */ "doc-deprecated": [ @@ -326,7 +332,7 @@ export interface DocElement { /** the text of the deprecated documentation */ }; _: string; - } + }, ]; /** Position of the documentation in the original source code */ "source-position": [ @@ -337,18 +343,19 @@ export interface DocElement { line: string; /** The first column of the documentation in the source code */ column: string[]; - } + }, ]; } -//Information about elements can be a documentation of annotations -export interface InfoElements extends DocElement { - annotation: Annotation[]; +// Information about elements can be a documentation of annotations +// https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts +export interface GirInfoElements extends GirDocElement { + annotation: GirAnnotation[]; } -export interface ConstantElement extends InfoElements, AnyType { +export interface GirConstantElement extends GirInfoElements, GirAnyType { /** A constant entity, similar to const variable in C */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the constant */ name: string; /** value of the constant */ @@ -360,162 +367,166 @@ export interface ConstantElement extends InfoElements, AnyType { }; } -export interface PropertyElement extends InfoElements, AnyType { +export interface GirPropertyElement extends GirInfoElements, GirAnyType { /** Property, that is a variable or members with getter and setter functions */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the property */ name: string; /** Binary attribute, true if the property is writeable, that is it has a setter function */ - writable?: BinaryOption | BinaryOption; + writable?: GirBoolean; /** Binary attribute, true if the property is readable, that is it has a getter function */ - readable?: BinaryOption | BinaryOption; + readable?: GirBoolean; /** Binary attribute, true if the property will be set upon construction */ - construct?: BinaryOption | BinaryOption; + construct?: GirBoolean; /** Binary attribute, true if the property can only be set upon construction */ - "construct-only"?: BinaryOption | BinaryOption; - //Define the transfer of ownership of the property element - TransferOwnership?; - }; -} - -export interface SignalElement extends InfoElements { - /** A signal as defined in the GObject system (https://developer.gnome.org/gobject/stable/signal.html) */ - $: InfoAttrs & { + "construct-only"?: GirBoolean; + /** The setter function for this property */ + setter?: string; + /** The getter function for this property */ + getter?: string; + /** The value of the property when it is not set */ + "default-value"?: string; + } & Partial; +} + +export interface GirSignalElement extends GirInfoElements { + /** A signal as defined in the GObject system (https://docs.gtk.org/gobject/concepts.html#signals) */ + $: GirInfoAttrs & { /** name of the signal */ name: string; - /** Binary attribute, true if the signal has a detailed parameter (https://developer.gnome.org/gobject/stable/signal.html#signal-detail//and https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ - detailed?: BinaryOption | BinaryOption; - /** When to run the signal during the 5 steps of signal emission (https://developer.gnome.org/gobject/stable/signal.html#signal-emission and https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ + /** Binary attribute, true if the signal has a detailed parameter (https://docs.gtk.org/gobject/concepts.html#the-detail-argument and https://docs.gtk.org/gobject/flags.SignalFlags.html) */ + detailed?: GirBoolean; + /** When to run the signal during the 5 steps of signal emission (https://docs.gtk.org/gobject/concepts.html#signal-emission and https://docs.gtk.org/gobject/flags.SignalFlags.html) */ when?: "first" | "last" | "cleanup"; - /** Binary attribute, true if the signal can be freely emitted on alive objects from user code (https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ - action?: BinaryOption | BinaryOption; - /** Binary attribute, true if no emission hooks are supported for this signal (https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ - "no-hooks"?: BinaryOption | BinaryOption; - /** Binary attribute, true if signals emitted for an object while currently being in emission for this very object will not be emitted recursively, but instead cause the first emission to be restarted (https://developer.gnome.org/gobject/unstable/gobject-Signals.html#GSignalFlags) */ - "no-recurse"?: BinaryOption | BinaryOption; + /** Binary attribute, true if the signal can be freely emitted on alive objects from user code (https://docs.gtk.org/gobject/flags.SignalFlags.html) */ + action?: GirBoolean; + /** Binary attribute, true if no emission hooks are supported for this signal (https://docs.gtk.org/gobject/flags.SignalFlags.html) */ + "no-hooks"?: GirBoolean; + /** Binary attribute, true if signals emitted for an object while currently being in emission for this very object will not be emitted recursively, but instead cause the first emission to be restarted (https://docs.gtk.org/gobject/flags.SignalFlags.html) */ + "no-recurse"?: GirBoolean; }; - /* Other elements a property can contain */ - parameters?: [CallableParams]; - "return-value"?: CallableReturn[]; + parameters?: [GirCallableParams]; + "return-value"?: GirCallableReturn[]; } -export interface FieldElement extends InfoElements, AnyType { +export interface GirFieldElement extends GirInfoElements, GirAnyType { /** A field of struct of union structure, that is a C bit field, that is a fixed length in bits variable */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the field */ name: string; /** Binary attribute, true if the field is writeable */ - writable?: BinaryOption | BinaryOption; + writable?: GirBoolean; /** Binary attribute, true if the field is readable */ - readable?: BinaryOption | BinaryOption; + readable?: GirBoolean; /** Binary attribute, true if the field is private to the structure or has public ("0") visibility */ - private?: BinaryOption | BinaryOption; + private?: GirBoolean; /** number of bits of the field */ - bits?: UnparsedNumber /** integer */; + bits?: GirUnparsedNumber /** integer */; }; /* Other elements a property can contain */ - callback?: CallbackElement[]; + callback?: GirCallbackElement[]; } -export interface CallbackElement extends InfoElements { +export interface GirCallbackElement extends GirInfoElements { /** A callback closure, that is a function called when a signal is emitted (as an answer to that signal) */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the callback */ name: string; /** the C type returned by the callback closure (i.e. function) */ "c:type"?: string; /** Binary attribute, true if the callback can throw an error */ - throws?: BinaryOption | BinaryOption; + throws?: GirBoolean; }; /* Other elements a property can contain */ - parameters?: [CallableParams]; - "return-value"?: CallableReturn[]; + parameters?: [GirCallableParams]; + "return-value"?: GirCallableReturn[]; } -export interface Implements { +export interface GirImplements { /** Give the name of the interface it implements. This element is generally used within a class element */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the interface implemented by a class */ name: string; }; } -export interface Prerequisite { - /** Interface which is pre-required to implement another interface. This node is generally using within an interface element */ - $: InfoAttrs & { - /** name of the required interface */ - name: string; +export interface GirPrerequisite { + $: { + name?: string; }; } //A generic grammar element to represent either a simple Type or an Array of the same Type -export interface AnyType { - type?: Type[]; - array?: ArrayType[]; +export interface GirAnyType { + type?: GirType[]; + array?: GirArrayType[]; } -export interface Type extends DocElement { +export interface GirType extends GirDocElement { /** A simple type of data (as opposed to an array) */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the type */ name?: string; /** the C representation of the type */ "c:type"?: string; /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: BinaryOption | BinaryOption; + introspectable?: GirBoolean; }; - array?: ArrayType[]; - type: Type[]; + array?: GirArrayType[]; + type: GirType[]; } -export interface ArrayType { +export interface GirArrayType { /** An array type of data where each element is of the same type */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the array type */ name?: string; /** Binary attribute, true if the last element of the array is zero. For example, in an array of pointers, the last pointer would be NULL */ - "zero-terminated"?: BinaryOption | BinaryOption; + "zero-terminated"?: GirBoolean; /** size of an array of predetermined fixed size. For example a C array declared as char arr[5]. */ - "fixed-size"?: UnparsedNumber /** integer */; - /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: BinaryOption | BinaryOption; + "fixed-size"?: GirUnparsedNumber /** integer */; + /** Binary attribute which is GirBoolean (false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: GirBoolean; /** 0-based index of parameter element that specifies the length of the array */ - length?: UnparsedNumber /** integer */; + length?: GirUnparsedNumber /** integer */; /** the C representation of the array type */ "c:type"?: string; }; - - array?: ArrayType[]; - type?: Type[]; + array?: GirArrayType[]; + type?: GirType[]; } -export enum TransferOwnershipType { +export enum GirTransferOwnershipType { Container = "container", Full = "full", None = "none", } -export interface TransferOwnership { - /** attributes used by many elements for the transfer of ownership, with for example, a returned value. "none" if the recipient does not own the value, "container" if the recipient owns the container but not the value (for arrays or lists for example) , "full" the recipient owns the entire value. For details, see https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Memory_and_lifecycle_management */ - "transfer-ownership": TransferOwnershipType; +export interface GirTransferOwnership { + /** attributes used by many elements for the transfer of ownership, with for example, a returned value. + * - "none" if the recipient does not own the value, + * - "container" if the recipient owns the container but not the value (for arrays or lists for example), + * - "full" the recipient owns the entire value. + * For details, see https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Memory_and_lifecycle_management */ + "transfer-ownership": GirTransferOwnershipType; } -export interface ConstructorElement { +export interface GirConstructorElement { /** A constructor of a class */ - $: InfoAttrs & CallableAttrs; + $: GirInfoAttrs & GirCallableAttrs; - parameters?: [CallableParams]; - "return-value"?: CallableReturn[]; + parameters?: [GirCallableParams]; + "return-value"?: GirCallableReturn[]; } /** Attributes of a Callable (functions, callbacks, closures, etc...) */ -export interface CallableAttrs { +export interface GirCallableAttrs { /** name of the Callable */ name: string; //C identifier in the source code of the Callable @@ -525,121 +536,137 @@ export interface CallableAttrs { /** Callable it shadows. For example, in C++, only one version of an overloaded callable will appear */ shadows?: string; /** Binary attribute, true if the callable can throw an error */ - throws?: BinaryOption | BinaryOption; + throws?: GirBoolean; /** if for backward compatibility reason the callable has a name in the source code but should be known by another one, this attribute contains the new name */ "moved-to"?: string[]; } -export interface VarArgs { +export interface GirVarArgs { /** an element, usually found in a parameter element for variadic parameter in a function or callable */ - $: InfoAttrs; + $: GirInfoAttrs; } -export interface CallableParamElement extends DocElement, AnyType { +export interface GirCallableParamElement extends GirDocElement, GirAnyType { /** parameter element of a list of parameters */ - $: InfoAttrs & - Partial & { - /** name of the parameter */ - name?: string; - /** Binary attribute, true if the parameter can have a null value */ - nullable?: BinaryOption | BinaryOption; - /** Deprecated. Replaced by nullable and optional */ - "allow-none"?: BinaryOption | BinaryOption; - /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: BinaryOption | BinaryOption; - /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ - closure?: UnparsedNumber /** integer */; - /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ - destroy?: UnparsedNumber /** integer */; - /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocationi (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ - scope?: "notified" | "async" | "call"; - /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ - direction?: Direction; - /** Binary attribute, true if the caller should allocate the parameter before calling the callable */ - "caller-allocates"?: BinaryOption | BinaryOption; - /** Binary attribute, true if the parameter is optional */ - optional?: BinaryOption | BinaryOption; - /** Binary attribute, true if the parameter can be omitted from the introspected output */ - skip?: BinaryOption | BinaryOption; - }; + $: GirInfoAttrs & + Partial & { + /** name of the parameter */ + name?: string; + /** Binary attribute, `true` if the parameter can have a null value */ + nullable?: GirBoolean; + /** @deprecated Replaced by {@link allow-none} */ + "null-ok"?: GirBoolean; + /** @deprecated Replaced by {@link nullable} and {@link optional} */ + "allow-none"?: GirBoolean; + /** Binary attribute which is GirBoolean(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ + introspectable?: GirBoolean; + /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ + closure?: GirUnparsedNumber /** integer */; + /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ + destroy?: GirUnparsedNumber /** integer */; + /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocation (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ + scope?: "notified" | "async" | "call"; + /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ + direction?: GirDirection; + /** Binary attribute, `true` if the caller should allocate the parameter before calling the callable */ + "caller-allocates"?: GirBoolean; + /** Binary attribute, `true` if the parameter is optional */ + optional?: GirBoolean; + /** Binary attribute, `true` if the parameter can be omitted from the introspected output */ + skip?: GirBoolean; + }; - varargs?: VarArgs[]; + varargs?: GirVarArgs[]; } // Refer to https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#Support_for_GObject_closures -export interface CallableParams { +export interface GirCallableParams { /** parameters element of a callable, that is in general parameters of a function or similar */ - parameter: CallableParamElement[]; + parameter: GirCallableParamElement[]; /** instance-parameter is a parameter of a C function which is an instance of an existing object. So the callable is surely a method of a class, and this parameter points to the instance of the object. In C++, this would be equivalent to the pointer this which is not passed to the method, in Python it's equivalent to self. */ - "instance-parameter"?: AnyType & - { - $: Partial<{ - /** name of the instance-parameter */ name: string; - /** Binary attribute, true if the parameter can have a null value */ - nullable?: BinaryOption | BinaryOption; - /** Deprecated. Replaced by nullable and optional */ - "allow-none"?: BinaryOption | BinaryOption; - /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ - direction?: Direction; - /** Binary attribute, true if the caller should allocate the parameter before calling the callable */ - "caller-allocates"?: BinaryOption | BinaryOption; - }> & - Partial; - }[]; + "instance-parameter"?: GirInstanceParameter[]; +} + +/** + * instance-parameter is a parameter of a C function which is an instance of an existing object. + * So the callable is surely a method of a class, and this parameter points to the instance of the object. + * In C++, this would be equivalent to the pointer this which is not passed to the method, in Python it's equivalent to self. + **/ +export interface GirInstanceParameter extends GirAnyType { + $: Partial<{ + /** name of the instance-parameter */ name: string; + /** Binary attribute, true if the parameter can have a null value */ + nullable?: GirBoolean; + /** @deprecated Replaced by nullable and optional */ + "allow-none"?: GirBoolean; + /** @deprecated Replaced by {@link allow-none} */ + "null-ok"?: GirBoolean; + /** direction of the parameter. "in" goes into the callable, "out" for output parameters from the callable (reference in C++, var in Pascal, etc...), "inout" for both (like a pre-allocated structure which will be filled-in by the callable) */ + direction?: GirDirection; + /** Binary attribute, true if the caller should allocate the parameter before calling the callable */ + "caller-allocates"?: GirBoolean; + }> & + Partial; + type?: GirType[]; } -export interface CallableReturn extends AnyType, DocElement { +export interface GirCallableReturn extends GirAnyType, GirDocElement { /** return value of a callable */ $: { + name?: string; /** Binary attribute which is BinaryOption(false) if the element is not introspectable. It doesn't exist in the bindings, due in general to missing information in the annotations in the original C code */ - introspectable?: BinaryOption | BinaryOption; + introspectable?: GirBoolean; /** Binary attribute, true if the parameter can have a null value */ - nullable?: BinaryOption | BinaryOption; + nullable?: GirBoolean; /** the parameter is a user_data for callbacks. The value points to a different parameter that is the actual callback */ - closure?: UnparsedNumber /** integer */; + closure?: GirUnparsedNumber /** integer */; /** the parameter is a callback, the value indicates the lifetime of the call. For language bindings which want to know when the resources required to do the call can be freed. "notified" valid until a GDestroyNotify argument is called, "async" only valid for the duration of the first callback invocationi (can only be called once), "call" only valid for the duration of the call, can be called multiple times during the call. */ scope?: "notified" | "async" | "call"; /** the parameter is a destroy_data for callbacks. The value points to a different parameter that is the actual callback */ - destroy?: UnparsedNumber /** integer */; + destroy?: GirUnparsedNumber /** integer */; /** Binary attribute, true if the parameter can be omitted from the introspected output */ - skip?: BinaryOption | BinaryOption; - /** Deprecated. Replaced by nullable and optional */ - "allow-none"?: BinaryOption | BinaryOption; - } & Partial; + skip?: GirBoolean; + /** @deprecated Replaced by nullable and optional */ + "allow-none"?: GirBoolean; + } & Partial; } -export interface FunctionElement extends DocElement { +export interface GirFunctionElement extends GirDocElement { /** element defining a standalone function (as usual in most programming languages) */ - $: InfoAttrs & CallableAttrs; + $: GirInfoAttrs & GirCallableAttrs; - parameters?: [CallableParams]; - "return-value"?: CallableReturn[]; + parameters?: [GirCallableParams]; + "return-value"?: GirCallableReturn[]; } -export interface MethodElement extends DocElement { +export interface GirMethodElement extends GirDocElement { /** element defining a method from a class */ - $: InfoAttrs & CallableAttrs; + $: GirInfoAttrs & + GirCallableAttrs & { + /** The GObject property that is set by this method */ + "glib:set-property": string; + /** The GObject property that is retrieved by this method */ + "glib:get-property": string; + }; - parameters?: [CallableParams]; - "return-value"?: CallableReturn[]; + parameters?: [GirCallableParams]; + "return-value"?: GirCallableReturn[]; } -export interface VirtualMethodElement extends DocElement { - /** element defining a virtual method from a class, concept similar to C++ */ - - $: InfoAttrs & - CallableAttrs & { - /** name of the callable called when invoking this virtual method */ - invoker?: string; - }; +export interface GirVirtualMethodElement extends GirDocElement { + $: GirInfoAttrs & + GirCallableAttrs & { + /** name of the callable called when invoking this virtual method */ + invoker?: string; + }; - parameters?: [CallableParams]; - "return-value"?: CallableReturn[]; + parameters?: [GirCallableParams]; + "return-value"?: GirCallableReturn[]; } -export interface UnionElement extends InfoElements { +export interface GirUnionElement extends GirInfoElements { /** element defining a type of data being a union of type, similar to union in C/C++ but extended with fields and methods */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the union */ name?: string; /** C type defining the union */ @@ -652,16 +679,16 @@ export interface UnionElement extends InfoElements { "glib:get-type"?: string; }; - field?: FieldElement[]; - "constructor"?: ConstructorElement[]; - method?: MethodElement[]; - function?: FunctionElement[]; - record?: RecordElement[]; + field?: GirFieldElement[]; + constructor?: GirConstructorElement[]; + method?: GirMethodElement[]; + function?: GirFunctionElement[]; + record?: GirRecordElement[]; } -export interface BitfieldElement extends InfoElements { +export interface GirBitfieldElement extends GirInfoElements { /** element defining a bit field (as in C) */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the bit field */ name: string; /** corresponding C type of the bit field type */ @@ -672,13 +699,13 @@ export interface BitfieldElement extends InfoElements { "glib:get-type"?: string; }; - member: MemberElement[]; - function: FunctionElement[]; + member: GirMemberElement[]; + function: GirFunctionElement[]; } -export interface EnumElement extends InfoElements { +export interface GirEnumElement extends GirInfoElements { /** element defining a enumeration type similar to enum in C/C++ */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the enumeration */ name: string; /** corresponding C type of the enumeration type */ @@ -690,21 +717,41 @@ export interface EnumElement extends InfoElements { /** Error domain of this enumeration in a stringified form */ "glib:error-domain"?: string; }; + member?: GirMemberElement[]; + function?: GirFunctionElement[]; +} - member?: MemberElement[]; - function?: FunctionElement[]; +export interface GirFieldElement extends GirInfoElements, GirAnyType { + /** A field of struct of union structure, that is a C bit field, that is a fixed length in bits variable */ + $: GirInfoAttrs & { + /** name of the field */ + name: string; + /** Binary attribute, true if the field is writeable */ + writable?: GirBoolean; + /** Binary attribute, true if the field is readable */ + readable?: GirBoolean; + /** Binary attribute, true if the field is private to the structure or has public ("0") visibility */ + private?: GirBoolean; + /** number of bits of the field */ + bits?: GirUnparsedNumber /** integer */; + }; + + /* Other elements a property can contain */ + callback?: GirCallbackElement[]; } -export interface MemberElement extends InfoElements { +export interface GirMemberElement extends GirInfoElements { /** element defining a member of a bit field or an enumeration */ - $: InfoAttrs & { + $: GirInfoAttrs & { /** name of the member */ name: string; /** value of the member */ value: string; /** corresponding C type of the member */ "c:identifier": string; - /** short nickname of the member */ + /** short nickname of the member (from GEnumValue/GFlagsValue) */ "glib:nick"?: string; + /** name of the member (from GEnumValue/GFlagsValue) */ + "glib:name"?: string; }; } diff --git a/packages/parser/tsconfig.json b/packages/parser/tsconfig.json index ccedbfe42..321dbe07a 100644 --- a/packages/parser/tsconfig.json +++ b/packages/parser/tsconfig.json @@ -3,7 +3,6 @@ "target": "ES2017", "module": "ES2020", "moduleResolution": "node", - "rootDir": "src", "outDir": "dist", "resolveJsonModule": true, "noImplicitThis": true, @@ -14,11 +13,12 @@ "declaration": true, "strictPropertyInitialization": true, "esModuleInterop": true, + "skipLibCheck": true, "lib": [ "ES2019" ] }, "include": [ - "src/**/*" + "./src/**/*.ts" ] } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index aae3f14bf..f0bf4854f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -706,12 +706,18 @@ __metadata: languageName: node linkType: hard -"@gi.ts/parser@workspace:packages/parser": +"@gi.ts/parser@workspace:^, @gi.ts/parser@workspace:packages/parser": version: 0.0.0-use.local resolution: "@gi.ts/parser@workspace:packages/parser" dependencies: "@types/xml2js": "npm:^0.4.4" + "@typescript-eslint/eslint-plugin": "npm:^6.9.1" + "@typescript-eslint/parser": "npm:^6.9.1" + eslint: "npm:^8.52.0" + eslint-config-prettier: "npm:^9.0.0" + eslint-plugin-prettier: "npm:^5.0.1" fast-xml-parser: "npm:^3.17.5" + prettier: "npm:^3.0.3" typescript: "npm:5.1.3" languageName: unknown linkType: soft @@ -1149,6 +1155,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ts-for-gir/cli@workspace:packages/cli" dependencies: + "@gi.ts/parser": "workspace:^" "@ts-for-gir/generator-base": "workspace:^" "@ts-for-gir/generator-html-doc": "workspace:^" "@ts-for-gir/generator-typescript": "workspace:^" From 82c18b5e5386c2f4f9b50f81faa87d7e7b385238 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 26 Feb 2024 17:03:33 -0800 Subject: [PATCH 04/53] vscode: Add a workspace definition file --- .gitignore | 2 + .vscode/extensions.json | 6 - .vscode/launch.json | 104 ------- .vscode/settings.json | 464 --------------------------- ts-for-gir.code-workspace | 641 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 643 insertions(+), 574 deletions(-) delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json create mode 100644 ts-for-gir.code-workspace diff --git a/.gitignore b/.gitignore index c2a5f20e1..5d241b70f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ examples/**/@types/ # !@types/Gtk-2.0.d.ts # !@types/* +.vscode + index.ts.bak examples/**/node_modules/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 8e8adf9ed..000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recommendations": [ - "arcanis.vscode-zipfs", - "dbaeumer.vscode-eslint" - ] -} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a6a26661e..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - // Use IntelliSense to learn about possible Node.js debug attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "build:types:vda1", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.vda1.rc.js", "--verbose", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true - }, - { - "name": "build:types:gtk2", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.gtk2.rc.js", "--verbose", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true - }, - { - "name": "build:types:gtk3", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.gtk3.rc.js", "--verbose", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true - }, - { - "name": "build:types:gtk4", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.gtk4.rc.js", "--verbose", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true, - }, - { - "name": "build:types:gio", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.gio.rc.js", "--verbose", "--promisify", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true, - }, - { - "name": "build:types", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.all.rc.js", "--verbose", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true, - }, - { - "name": "build:types:gjs", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.all.rc.js", "--verbose", "--environments=gjs", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true, - }, - { - "name": "build:types:node", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", "generate", "--configName=.ts-for-gir.all.rc.js", "--verbose", "--environments=node", "--outdir", "../../../tmp" - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true, - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b3ab86357..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,464 +0,0 @@ -{ - "deno.enable": false, - "editor.tabSize": 4, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" - }, - "eslint.validate": [ - "typescript" - ], - "cSpell.words": [ - "ABGR", - "acceleratable", - "ACCELS", - "ACCES", - "accountsservice", - "accounttype", - "accu", - "ADHOC", - "Adwaita", - "AFIRST", - "AGPL", - "AHOM", - "alphav", - "Amtk", - "animatev", - "Anjuta", - "Anthy", - "ARBFP", - "ARGB", - "AUTOSIZE", - "BAMUM", - "BATAK", - "BGRA", - "Bidir", - "bindtextdomain", - "bitfield", - "BOPOMOFO", - "BOTTOMLEFT", - "BOTTOMRIGHT", - "BTLR", - "BTRL", - "BUGINESE", - "BUHID", - "Buildable", - "Cally", - "camelcase", - "CANTOPEN", - "CARIAN", - "cclosure", - "CDROM", - "cgjs", - "CHAKMA", - "CHECKME", - "CHIKI", - "childname", - "childs", - "CITI", - "clampf", - "cmyk", - "Codepoint", - "Cogl", - "colorette", - "Colorhug", - "Colormap", - "columnify", - "COMBOBOX", - "CONNECTIONSETTINGNOTFOUND", - "CONNECTIONTYPEINVALID", - "Connman", - "cosmiconfig", - "CROSSFADE", - "cset", - "ctix", - "CTYPE", - "CURISVE", - "Datapath", - "DATETIME", - "dbus", - "Dbusmenu", - "dcgettext", - "Descs", - "DESERET", - "detokenize", - "devel", - "dgettext", - "dngettext", - "domainname", - "dups", - "Eastasian", - "ELBASAN", - "ellipsize", - "EMBOX", - "emitable", - "emitv", - "enumtype", - "errorno", - "espree", - "Farstream", - "FBIG", - "FCOE", - "finfo", - "FINISHINGS", - "FLEURONS", - "focusable", - "fontconfig", - "fontmap", - "fontname", - "FONTSET", - "Forall", - "FREEBUSY", - "freetype", - "fullname", - "GACTION", - "Garber", - "gboolean", - "gbytes", - "gcalc", - "gchar", - "gconstpointer", - "Gdaui", - "gdkpixbuf", - "gdouble", - "Gegl", - "getenv", - "gettext", - "getv", - "Gfile", - "gfloat", - "GICON", - "gint", - "girrc", - "girs", - "Gitg", - "gjsify", - "globby", - "glong", - "gmenu", - "gmodule", - "gnomeshell", - "gobject", - "gpointer", - "Graphene", - "gshort", - "gsize", - "GSSDP", - "gssize", - "gstring", - "gtksourceview", - "gtype", - "guchar", - "guint", - "guintptr", - "gulong", - "gunichar", - "GURMUKHI", - "gushort", - "Gvalue", - "hadjustment", - "halign", - "HANJA", - "HANUNOO", - "HARDDISK", - "Harf", - "harfbuzz", - "HATRAN", - "hbox", - "Hexpand", - "HOJO", - "HORIZ", - "ICONTHEME", - "iface", - "iface's", - "ihint", - "IMMESSAGE", - "implmts", - "Initable", - "inout", - "instantiatable", - "instream", - "interp", - "INTERROBANG", - "intptr", - "introspectable", - "INVAL", - "INVALIDSETTING", - "ISDIR", - "itype", - "JAMO", - "jsgtk", - "jsobject", - "KAITHI", - "KAYAH", - "keyfile", - "keynav", - "keyval", - "KHAROSHTHI", - "KHUDAWADI", - "KIKAKUI", - "Launchable", - "lcopy", - "LEPCHA", - "LGPL", - "Libadwaita", - "libappindicator", - "LIBBAD", - "libcairo", - "libgda", - "libgirepository", - "libgtk", - "libgtksourceview", - "libnotify", - "libsoup", - "libwebkit", - "libxml", - "LIMBU", - "LISU", - "LRBT", - "LRTB", - "Mainloop", - "MALLOC", - "MANDAIC", - "MARCHEN", - "MAYEK", - "MEDIABASEURL", - "MEETEI", - "MENDE", - "MEROITIC", - "METAINFO", - "MFILE", - "MIAO", - "MODALIAS", - "modemmanager", - "monospace", - "MONOSPACED", - "msgid", - "multidevice", - "MULTIHEAD", - "NAGRI", - "NAMETOOLONG", - "newv", - "newval", - "NFILE", - "ngettext", - "NLCCHARACTERS", - "nlinks", - "NOCOPY", - "NODEV", - "NOENT", - "NOEXEC", - "NOSPC", - "NOSYS", - "NOTCALLED", - "NOTDIR", - "NPOT", - "NXIO", - "oclass", - "oclif", - "oldval", - "Orientable", - "OSMANYA", - "outdir", - "outstream", - "Overloadable", - "PAINTABLE", - "PALMYRENE", - "Pango", - "pangocairo", - "PARANTHESIS", - "Pbutils", - "PERMIC", - "pgettext", - "PHAGS", - "Pixbuf", - "Pixmap", - "PKGNAME", - "pkgnames", - "PLUGSOCKET", - "prealloced", - "preallocs", - "Preedit", - "PRELIGHT", - "PRELIT", - "PREMULT", - "printerr", - "printf", - "PRIO", - "PROGRESSBAR", - "promisified", - "pspec", - "Pspecs", - "psuwit", - "Qdata", - "qname", - "realh", - "REJANG", - "relationset", - "reparent", - "REPETION", - "REQUESTABLE", - "rgbxyz", - "RLBT", - "RLTB", - "ROFS", - "romgrk", - "rowstride", - "Rtsp", - "RUBBERBAND", - "RULESET", - "Rygel", - "rygelcore", - "SAURASHTRA", - "Savepoint", - "schar", - "screencast", - "Scrollable", - "Serializable", - "setlocale", - "SETTINGNOTFOUND", - "SHARADA", - "signall", - "SIGNWRITING", - "SINHALA", - "sizei", - "sizeiptr", - "somestring", - "Sparql", - "spdx", - "SPINBUTTON", - "SQRTI", - "strdup", - "streamtransmitter", - "STRIKETHROUGH", - "STRINGOBJECTPOINTER", - "struct", - "Strv", - "submodule", - "submodules", - "SUBPATTERN", - "SUBPATTERNS", - "substitutor", - "SYLOTI", - "symtable", - "TAGBANWA", - "TAKRI", - "TANGUT", - "Tasklist", - "TBLR", - "TBRL", - "textdomain", - "THAANA", - "THAM", - "TIFINAGH", - "timelinev", - "timezonemap", - "TIRHUTA", - "TITLEBAR", - "toolchain", - "TOOLITEM", - "TOPLEFT", - "Toplevel", - "TOPRIGHT", - "TRANSCODING", - "TSDATA", - "TXTBSY", - "TXTBUSY", - "Typecheck", - "typeof", - "Uchar", - "ufuncs", - "Ulong", - "uncache", - "UNDELETE", - "UNDERBAR", - "undraggable", - "UNEXP", - "unfallback", - "Unhighlight", - "Unichar", - "UNKNOWNERROR", - "UNMANAGED", - "Unmap", - "unrealize", - "unuse", - "unvalidated", - "UPSIDEDOWN", - "vadjustment", - "vala", - "valign", - "Vals", - "VAPIs", - "varargs", - "VCARD", - "Vercmp", - "vevents", - "vexpand", - "vfunc", - "Vgda", - "VIET", - "Volkoff", - "vprintf", - "Vulkan", - "WARANG", - "wmclass", - "XALIGN", - "xlib", - "xpad", - "xrandr", - "XTHICKNESS", - "yalign", - "ypad", - "YTHICKNESS", - "zorder" - ], - "search.exclude": { - "**/.yarn": true, - "**/.pnp.*": true - }, - "typescript.enablePromptUseWorkspaceTsdk": true, - "presentation-mode.active": { - "commands": [ - "workbench.action.closeSidebar" - ], - "editor.fontSize": 16, - "editor.matchBrackets": "never", - "editor.minimap.enabled": false, - "editor.scrollbar.verticalScrollbarSize": 0, - "workbench.activityBar.visible": false, - "workbench.statusBar.visible": false, - "workbench.colorTheme": "GitHub Dark Default", - "workbench.colorCustomizations": { - "[GitHub Dark Default]": { - "activityBar.background": "#000", - "editor.background": "#000", - "editor.lineHighlightBackground": "#0000", - "editor.lineHighlightBorder": "#0000", - "panel.background": "#000", - "sideBar.background": "#000", - "terminal.background": "#000" - }, - "[GitHub Light Default]": { - "activityBar.background": "#fff", - "editor.background": "#fff", - "editor.lineHighlightBackground": "#fff0", - "editor.lineHighlightBorder": "#fff0", - "panel.background": "#fff", - "sideBar.background": "#fff", - "terminal.background": "#fff" - } - }, - "window.zoomLevel": 2 - }, - "presentation-mode.configBackup": { - "editor.fontSize": "undefined", - "editor.matchBrackets": "undefined", - "editor.minimap.enabled": "undefined", - "editor.scrollbar.verticalScrollbarSize": "undefined", - "workbench.activityBar.visible": "undefined", - "workbench.statusBar.visible": "undefined", - "workbench.colorTheme": "undefined", - "workbench.colorCustomizations": "undefined", - "window.zoomLevel": "undefined" - }, - "typescript.tsdk": "node_modules/typescript/lib" -} diff --git a/ts-for-gir.code-workspace b/ts-for-gir.code-workspace new file mode 100644 index 000000000..13d49ac8f --- /dev/null +++ b/ts-for-gir.code-workspace @@ -0,0 +1,641 @@ +{ + "extensions": { + "recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint"], + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "build:types:vda1", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.vda1.rc.js", + "--verbose", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types:gtk2", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.gtk2.rc.js", + "--verbose", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types:gtk3", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.gtk3.rc.js", + "--verbose", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types:gtk4", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.gtk4.rc.js", + "--verbose", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types:gio", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.gio.rc.js", + "--verbose", + "--promisify", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.all.rc.js", + "--verbose", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types:gjs", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.all.rc.js", + "--verbose", + "--environments=gjs", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + { + "name": "build:types:node", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}/packages/cli", + "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", + "args": [ + "${workspaceRoot}/packages/cli/src/start.ts", + "generate", + "--configName=.ts-for-gir.all.rc.js", + "--verbose", + "--environments=node", + "--outdir", + "../../../tmp", + ], + "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], + "sourceMaps": true, + }, + ], + }, + "folders": [ + { + "path": ".", + }, + { + "path": "packages/parser", + }, + { + "path": "packages/lib", + }, + { + "path": "packages/cli", + }, + { + "path": "packages/generator-base", + }, + { + "path": "packages/generator-typescript", + }, + { + "path": "packages/generator-html-doc", + }, + ], + "settings": { + "search.exclude": { + "**/.yarn": true, + "**/.pnp.*": true, + }, + "editor.tabSize": 4, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + }, + "eslint.validate": ["typescript"], + "cSpell.words": [ + "ABGR", + "acceleratable", + "ACCELS", + "ACCES", + "accountsservice", + "accounttype", + "accu", + "ADHOC", + "Adwaita", + "AFIRST", + "AGPL", + "AHOM", + "alphav", + "Amtk", + "animatev", + "Anjuta", + "Anthy", + "ARBFP", + "ARGB", + "AUTOSIZE", + "BAMUM", + "BATAK", + "BGRA", + "Bidir", + "bindtextdomain", + "bitfield", + "BOPOMOFO", + "BOTTOMLEFT", + "BOTTOMRIGHT", + "BTLR", + "BTRL", + "BUGINESE", + "BUHID", + "Buildable", + "Cally", + "camelcase", + "CANTOPEN", + "CARIAN", + "cclosure", + "CDROM", + "cgjs", + "CHAKMA", + "CHECKME", + "CHIKI", + "childname", + "childs", + "CITI", + "clampf", + "cmyk", + "Codepoint", + "Cogl", + "colorette", + "Colorhug", + "Colormap", + "columnify", + "COMBOBOX", + "CONNECTIONSETTINGNOTFOUND", + "CONNECTIONTYPEINVALID", + "Connman", + "cosmiconfig", + "CROSSFADE", + "cset", + "ctix", + "CTYPE", + "CURISVE", + "Datapath", + "DATETIME", + "dbus", + "Dbusmenu", + "dcgettext", + "Descs", + "DESERET", + "detokenize", + "devel", + "dgettext", + "dngettext", + "domainname", + "dups", + "Eastasian", + "ELBASAN", + "ellipsize", + "EMBOX", + "emitable", + "emitv", + "enumtype", + "errorno", + "espree", + "Farstream", + "FBIG", + "FCOE", + "finfo", + "FINISHINGS", + "FLEURONS", + "focusable", + "fontconfig", + "fontmap", + "fontname", + "FONTSET", + "Forall", + "FREEBUSY", + "freetype", + "fullname", + "GACTION", + "Garber", + "gboolean", + "gbytes", + "gcalc", + "gchar", + "gconstpointer", + "Gdaui", + "gdkpixbuf", + "gdouble", + "Gegl", + "getenv", + "gettext", + "getv", + "Gfile", + "gfloat", + "GICON", + "gint", + "girrc", + "girs", + "Gitg", + "gjsify", + "globby", + "glong", + "gmenu", + "gmodule", + "gnomeshell", + "gobject", + "gpointer", + "Graphene", + "gshort", + "gsize", + "GSSDP", + "gssize", + "gstring", + "gtksourceview", + "gtype", + "guchar", + "guint", + "guintptr", + "gulong", + "gunichar", + "GURMUKHI", + "gushort", + "Gvalue", + "hadjustment", + "halign", + "HANJA", + "HANUNOO", + "HARDDISK", + "Harf", + "harfbuzz", + "HATRAN", + "hbox", + "Hexpand", + "HOJO", + "HORIZ", + "ICONTHEME", + "iface", + "iface's", + "ihint", + "IMMESSAGE", + "implmts", + "Initable", + "inout", + "instantiatable", + "instream", + "interp", + "INTERROBANG", + "intptr", + "introspectable", + "INVAL", + "INVALIDSETTING", + "ISDIR", + "itype", + "JAMO", + "jsgtk", + "jsobject", + "KAITHI", + "KAYAH", + "keyfile", + "keynav", + "keyval", + "KHAROSHTHI", + "KHUDAWADI", + "KIKAKUI", + "Launchable", + "lcopy", + "LEPCHA", + "LGPL", + "Libadwaita", + "libappindicator", + "LIBBAD", + "libcairo", + "libgda", + "libgirepository", + "libgtk", + "libgtksourceview", + "libnotify", + "libsoup", + "libwebkit", + "libxml", + "LIMBU", + "LISU", + "LRBT", + "LRTB", + "Mainloop", + "MALLOC", + "MANDAIC", + "MARCHEN", + "MAYEK", + "MEDIABASEURL", + "MEETEI", + "MENDE", + "MEROITIC", + "METAINFO", + "MFILE", + "MIAO", + "MODALIAS", + "modemmanager", + "monospace", + "MONOSPACED", + "msgid", + "multidevice", + "MULTIHEAD", + "NAGRI", + "NAMETOOLONG", + "newv", + "newval", + "NFILE", + "ngettext", + "NLCCHARACTERS", + "nlinks", + "NOCOPY", + "NODEV", + "NOENT", + "NOEXEC", + "NOSPC", + "NOSYS", + "NOTCALLED", + "NOTDIR", + "NPOT", + "NXIO", + "oclass", + "oclif", + "oldval", + "Orientable", + "OSMANYA", + "outdir", + "outstream", + "Overloadable", + "PAINTABLE", + "PALMYRENE", + "Pango", + "pangocairo", + "PARANTHESIS", + "Pbutils", + "PERMIC", + "pgettext", + "PHAGS", + "Pixbuf", + "Pixmap", + "PKGNAME", + "pkgnames", + "PLUGSOCKET", + "prealloced", + "preallocs", + "Preedit", + "PRELIGHT", + "PRELIT", + "PREMULT", + "printerr", + "printf", + "PRIO", + "PROGRESSBAR", + "promisified", + "pspec", + "Pspecs", + "psuwit", + "Qdata", + "qname", + "realh", + "REJANG", + "relationset", + "reparent", + "REPETION", + "REQUESTABLE", + "rgbxyz", + "RLBT", + "RLTB", + "ROFS", + "romgrk", + "rowstride", + "Rtsp", + "RUBBERBAND", + "RULESET", + "Rygel", + "rygelcore", + "SAURASHTRA", + "Savepoint", + "schar", + "screencast", + "Scrollable", + "Serializable", + "setlocale", + "SETTINGNOTFOUND", + "SHARADA", + "signall", + "SIGNWRITING", + "SINHALA", + "sizei", + "sizeiptr", + "somestring", + "Sparql", + "spdx", + "SPINBUTTON", + "SQRTI", + "strdup", + "streamtransmitter", + "STRIKETHROUGH", + "STRINGOBJECTPOINTER", + "struct", + "Strv", + "submodule", + "submodules", + "SUBPATTERN", + "SUBPATTERNS", + "substitutor", + "SYLOTI", + "symtable", + "TAGBANWA", + "TAKRI", + "TANGUT", + "Tasklist", + "TBLR", + "TBRL", + "textdomain", + "THAANA", + "THAM", + "TIFINAGH", + "timelinev", + "timezonemap", + "TIRHUTA", + "TITLEBAR", + "toolchain", + "TOOLITEM", + "TOPLEFT", + "Toplevel", + "TOPRIGHT", + "TRANSCODING", + "TSDATA", + "TXTBSY", + "TXTBUSY", + "Typecheck", + "typeof", + "Uchar", + "ufuncs", + "Ulong", + "uncache", + "UNDELETE", + "UNDERBAR", + "undraggable", + "UNEXP", + "unfallback", + "Unhighlight", + "Unichar", + "UNKNOWNERROR", + "UNMANAGED", + "Unmap", + "unrealize", + "unuse", + "unvalidated", + "UPSIDEDOWN", + "vadjustment", + "vala", + "valign", + "Vals", + "VAPIs", + "varargs", + "VCARD", + "Vercmp", + "vevents", + "vexpand", + "vfunc", + "Vgda", + "VIET", + "Volkoff", + "vprintf", + "Vulkan", + "WARANG", + "wmclass", + "XALIGN", + "xlib", + "xpad", + "xrandr", + "XTHICKNESS", + "yalign", + "ypad", + "YTHICKNESS", + "zorder", + ], + + "typescript.enablePromptUseWorkspaceTsdk": true, + "presentation-mode.active": { + "commands": ["workbench.action.closeSidebar"], + "editor.fontSize": 16, + "editor.matchBrackets": "never", + "editor.minimap.enabled": false, + "editor.scrollbar.verticalScrollbarSize": 0, + "workbench.activityBar.visible": false, + "workbench.statusBar.visible": false, + "workbench.colorTheme": "GitHub Dark Default", + "workbench.colorCustomizations": { + "[GitHub Dark Default]": { + "activityBar.background": "#000", + "editor.background": "#000", + "editor.lineHighlightBackground": "#0000", + "editor.lineHighlightBorder": "#0000", + "panel.background": "#000", + "sideBar.background": "#000", + "terminal.background": "#000", + }, + "[GitHub Light Default]": { + "activityBar.background": "#fff", + "editor.background": "#fff", + "editor.lineHighlightBackground": "#fff0", + "editor.lineHighlightBorder": "#fff0", + "panel.background": "#fff", + "sideBar.background": "#fff", + "terminal.background": "#fff", + }, + }, + "window.zoomLevel": 2, + }, + "presentation-mode.configBackup": { + "editor.fontSize": "undefined", + "editor.matchBrackets": "undefined", + "editor.minimap.enabled": "undefined", + "editor.scrollbar.verticalScrollbarSize": "undefined", + "workbench.activityBar.visible": "undefined", + "workbench.statusBar.visible": "undefined", + "workbench.colorTheme": "undefined", + "workbench.colorCustomizations": "undefined", + "window.zoomLevel": "undefined", + }, + "typescript.tsdk": ".yarn/sdks/typescript/lib", + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "packages/**": true, + }, + }, +} From d69e5df52a117c970d20de9ffb9402456edd5b00 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 11:15:50 -0700 Subject: [PATCH 05/53] Fix for non-string doc comment --- packages/lib/src/gir-module.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index a91892fbd..bce66d404 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -231,7 +231,8 @@ export class GirModule { tags: [], } if (girDoc.doc?.[0]?._) { - let text = girDoc.doc?.[0]?._ || '' + // TODO: Somehow _ is not a string + let text = `${girDoc.doc?.[0]?._ || ''}` text = this.transformation.transformGirDocText(text) tsDoc.text = text } From 1015e45ca68c1c65fefa2b8aae9ecd458e14d350 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 11:32:02 -0700 Subject: [PATCH 06/53] Drop node-gtk support to simplify merging @gi.ts code --- .github/workflows/ci.yml | 29 ---- .ts-for-gir.all.rc.js | 2 +- .ts-for-gir.gcalc.rc.js | 2 +- .ts-for-gir.gio.rc.js | 2 +- .ts-for-gir.gtk2.rc.js | 2 +- .ts-for-gir.gtk3+gtk4.rc.js | 2 +- .ts-for-gir.gtk3.rc.js | 2 +- .ts-for-gir.gtk4.rc.js | 4 +- .ts-for-gir.modemmanager1.rc.js | 2 +- .ts-for-gir.packages-all.rc.js | 2 +- .ts-for-gir.rygelcore2.rc.js | 2 +- .ts-for-gir.timezonemap1.rc.js | 2 +- .ts-for-gir.vda1.rc.js | 2 +- .ts-for-gir.vte4.rc.js | 2 +- examples/README.md | 43 ++---- examples/gjs/gio-2-cat-alias/esbuild.js | 2 +- examples/gjs/gio-2-cat-packages/esbuild.js | 2 +- examples/gjs/gio-2-cat-promisify/esbuild.js | 2 +- examples/gjs/gio-2-cat-types-only/esbuild.js | 2 +- examples/gjs/gio-2-cat/esbuild.js | 2 +- examples/gjs/gio-2-dbus/esbuild.js | 2 +- examples/gjs/gtk-3-calc/esbuild.js | 2 +- examples/gjs/gtk-3-gettext/esbuild.js | 2 +- examples/gjs/gtk-3-hello-2/esbuild.js | 2 +- examples/gjs/gtk-3-template/esbuild.js | 2 +- examples/gjs/gtk-3-webkit/esbuild.js | 2 +- examples/gjs/gtk-4-application/esbuild.js | 2 +- examples/gjs/gtk-4-custom-widget/esbuild.js | 2 +- examples/gjs/gtk-4-template/esbuild.js | 2 +- examples/gjs/soup-3-http/esbuild.js | 2 +- examples/gjs/soup-3-websocket/esbuild.js | 2 +- examples/gjs/timers/esbuild.js | 2 +- .../node-gtk/gio-2-cat-packages/.gitignore | 18 --- .../node-gtk/gio-2-cat-packages/esbuild.mjs | 15 -- examples/node-gtk/gio-2-cat-packages/main.ts | 37 ----- .../node-gtk/gio-2-cat-packages/package.json | 28 ---- .../node-gtk/gio-2-cat-packages/tsconfig.json | 14 -- .../gio-2-cat-packages/tsconfig.types.json | 6 - .../node-gtk/glib-2-spawn-command/main.ts | 17 --- .../glib-2-spawn-command/package.json | 41 ------ .../glib-2-spawn-command/tsconfig.json | 20 --- .../glib-2-spawn-command/tsconfig.types.json | 6 - .../glib-2-spawn-command/webpack.config.js | 40 ------ examples/node-gtk/gtk-3-browser/main.ts | 88 ------------ examples/node-gtk/gtk-3-browser/package.json | 41 ------ examples/node-gtk/gtk-3-browser/tsconfig.json | 23 --- .../gtk-3-browser/tsconfig.types.json | 6 - .../node-gtk/gtk-3-browser/webpack.config.cjs | 39 ----- .../builder-auto-connect-signals.glade | 59 -------- .../global.ts | 4 - .../main.ts | 32 ----- .../package.json | 41 ------ .../tsconfig.json | 20 --- .../tsconfig.types.json | 6 - .../webpack.config.js | 40 ------ .../gtk-3-builder/builderExample.glade | 55 ------- examples/node-gtk/gtk-3-builder/global.ts | 4 - examples/node-gtk/gtk-3-builder/main.ts | 71 ---------- examples/node-gtk/gtk-3-builder/package.json | 42 ------ examples/node-gtk/gtk-3-builder/tsconfig.json | 20 --- .../gtk-3-builder/tsconfig.types.json | 6 - .../node-gtk/gtk-3-builder/webpack.config.js | 45 ------ examples/node-gtk/gtk-3-editor/main.ts | 40 ------ examples/node-gtk/gtk-3-editor/package.json | 40 ------ examples/node-gtk/gtk-3-editor/tsconfig.json | 20 --- .../node-gtk/gtk-3-editor/tsconfig.types.json | 6 - .../node-gtk/gtk-3-editor/webpack.config.js | 36 ----- examples/node-gtk/gtk-3-hello/main.ts | 25 ---- examples/node-gtk/gtk-3-hello/package.json | 41 ------ examples/node-gtk/gtk-3-hello/tsconfig.json | 20 --- .../node-gtk/gtk-3-hello/tsconfig.types.json | 6 - .../node-gtk/gtk-3-hello/webpack.config.js | 40 ------ .../node-gtk/gtk-4-custom-widget/esbuild.js | 12 -- .../node-gtk/gtk-4-custom-widget/index.ts | 126 ---------------- .../node-gtk/gtk-4-custom-widget/package.json | 31 ---- .../gtk-4-custom-widget/tsconfig.json | 19 --- .../gtk-4-custom-widget/tsconfig.types.json | 6 - examples/node-gtk/soup-3-http/esbuild.js | 12 -- examples/node-gtk/soup-3-http/http-client.ts | 67 --------- examples/node-gtk/soup-3-http/http-server.ts | 73 ---------- examples/node-gtk/soup-3-http/package.json | 32 ----- examples/node-gtk/soup-3-http/tsconfig.json | 20 --- .../node-gtk/soup-3-http/tsconfig.types.json | 6 - package.json | 36 +---- packages/cli/package.json | 1 - packages/cli/src/commands/generate.ts | 4 +- packages/cli/src/config.ts | 2 +- .../src/template-processor.ts | 4 +- .../src/type-definition-generator.ts | 74 +--------- .../templates/node-gtk/README-NODE-GTK.md | 74 ---------- .../templates/node-gtk/ambient.d.ts | 19 --- .../templates/node-gtk/gobject-2.0.d.ts | 57 -------- .../templates/node-gtk/module-import.d.ts | 29 ---- .../templates/node-gtk/module.append.d.ts | 1 - .../templates/node-gtk/module.d.ts | 10 -- .../templates/node-gtk/module.js | 18 --- .../templates/node-gtk/node-gtk.d.ts | 25 ---- .../templates/node-gtk/node-gtk.js | 7 - .../templates/package.json | 29 +--- .../templates/tsconfig.json | 3 - .../templates/typedoc.json | 5 - packages/lib/package.json | 5 +- packages/lib/src/constants.ts | 10 +- packages/lib/src/dependency-manager.ts | 8 -- packages/lib/src/gir-factory.ts | 44 ------ packages/lib/src/gir-module.ts | 14 -- packages/lib/src/injection/callbacks/index.ts | 1 - .../src/injection/callbacks/node-gtk/index.ts | 3 - packages/lib/src/injection/classes/index.ts | 1 - .../src/injection/classes/node-gtk/gdk-4.0.ts | 33 ----- .../src/injection/classes/node-gtk/gio-2.0.ts | 15 -- .../injection/classes/node-gtk/glib-2.0.ts | 20 --- .../injection/classes/node-gtk/gobject-2.0.ts | 67 --------- .../classes/node-gtk/graphene-1.0.ts | 134 ------------------ .../src/injection/classes/node-gtk/gtk-3.0.ts | 32 ----- .../src/injection/classes/node-gtk/gtk-4.0.ts | 53 ------- .../src/injection/classes/node-gtk/index.ts | 21 --- .../injection/classes/node-gtk/pango-1.0.ts | 32 ----- packages/lib/src/injection/injector.ts | 10 +- packages/lib/src/transformation.ts | 44 +----- packages/lib/src/types/environment.ts | 2 +- packages/lib/src/types/transformations.ts | 3 - 122 files changed, 66 insertions(+), 2580 deletions(-) delete mode 100644 examples/node-gtk/gio-2-cat-packages/.gitignore delete mode 100644 examples/node-gtk/gio-2-cat-packages/esbuild.mjs delete mode 100644 examples/node-gtk/gio-2-cat-packages/main.ts delete mode 100644 examples/node-gtk/gio-2-cat-packages/package.json delete mode 100644 examples/node-gtk/gio-2-cat-packages/tsconfig.json delete mode 100644 examples/node-gtk/gio-2-cat-packages/tsconfig.types.json delete mode 100644 examples/node-gtk/glib-2-spawn-command/main.ts delete mode 100644 examples/node-gtk/glib-2-spawn-command/package.json delete mode 100644 examples/node-gtk/glib-2-spawn-command/tsconfig.json delete mode 100644 examples/node-gtk/glib-2-spawn-command/tsconfig.types.json delete mode 100644 examples/node-gtk/glib-2-spawn-command/webpack.config.js delete mode 100644 examples/node-gtk/gtk-3-browser/main.ts delete mode 100644 examples/node-gtk/gtk-3-browser/package.json delete mode 100644 examples/node-gtk/gtk-3-browser/tsconfig.json delete mode 100644 examples/node-gtk/gtk-3-browser/tsconfig.types.json delete mode 100644 examples/node-gtk/gtk-3-browser/webpack.config.cjs delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/builder-auto-connect-signals.glade delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/global.ts delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/main.ts delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/package.json delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.json delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.types.json delete mode 100644 examples/node-gtk/gtk-3-builder-auto-connect-signals/webpack.config.js delete mode 100644 examples/node-gtk/gtk-3-builder/builderExample.glade delete mode 100644 examples/node-gtk/gtk-3-builder/global.ts delete mode 100644 examples/node-gtk/gtk-3-builder/main.ts delete mode 100644 examples/node-gtk/gtk-3-builder/package.json delete mode 100644 examples/node-gtk/gtk-3-builder/tsconfig.json delete mode 100644 examples/node-gtk/gtk-3-builder/tsconfig.types.json delete mode 100644 examples/node-gtk/gtk-3-builder/webpack.config.js delete mode 100644 examples/node-gtk/gtk-3-editor/main.ts delete mode 100644 examples/node-gtk/gtk-3-editor/package.json delete mode 100644 examples/node-gtk/gtk-3-editor/tsconfig.json delete mode 100644 examples/node-gtk/gtk-3-editor/tsconfig.types.json delete mode 100644 examples/node-gtk/gtk-3-editor/webpack.config.js delete mode 100644 examples/node-gtk/gtk-3-hello/main.ts delete mode 100644 examples/node-gtk/gtk-3-hello/package.json delete mode 100644 examples/node-gtk/gtk-3-hello/tsconfig.json delete mode 100644 examples/node-gtk/gtk-3-hello/tsconfig.types.json delete mode 100644 examples/node-gtk/gtk-3-hello/webpack.config.js delete mode 100644 examples/node-gtk/gtk-4-custom-widget/esbuild.js delete mode 100644 examples/node-gtk/gtk-4-custom-widget/index.ts delete mode 100644 examples/node-gtk/gtk-4-custom-widget/package.json delete mode 100644 examples/node-gtk/gtk-4-custom-widget/tsconfig.json delete mode 100644 examples/node-gtk/gtk-4-custom-widget/tsconfig.types.json delete mode 100644 examples/node-gtk/soup-3-http/esbuild.js delete mode 100644 examples/node-gtk/soup-3-http/http-client.ts delete mode 100644 examples/node-gtk/soup-3-http/http-server.ts delete mode 100644 examples/node-gtk/soup-3-http/package.json delete mode 100644 examples/node-gtk/soup-3-http/tsconfig.json delete mode 100644 examples/node-gtk/soup-3-http/tsconfig.types.json delete mode 100644 packages/generator-typescript/templates/node-gtk/README-NODE-GTK.md delete mode 100644 packages/generator-typescript/templates/node-gtk/ambient.d.ts delete mode 100644 packages/generator-typescript/templates/node-gtk/gobject-2.0.d.ts delete mode 100644 packages/generator-typescript/templates/node-gtk/module-import.d.ts delete mode 100644 packages/generator-typescript/templates/node-gtk/module.append.d.ts delete mode 100644 packages/generator-typescript/templates/node-gtk/module.d.ts delete mode 100644 packages/generator-typescript/templates/node-gtk/module.js delete mode 100644 packages/generator-typescript/templates/node-gtk/node-gtk.d.ts delete mode 100644 packages/generator-typescript/templates/node-gtk/node-gtk.js delete mode 100644 packages/lib/src/injection/callbacks/node-gtk/index.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/gdk-4.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/gio-2.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/glib-2.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/gobject-2.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/graphene-1.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/gtk-3.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/gtk-4.0.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/index.ts delete mode 100644 packages/lib/src/injection/classes/node-gtk/pango-1.0.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 214ef7d53..ee1ab727f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,32 +68,3 @@ jobs: - run: yarn run build - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:gjs - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:gjs - - node-gtk-types-all: - - runs-on: ubuntu-22.04 - - strategy: - matrix: - node-version: [18.x] - architecture: - - x64 - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - submodules: true - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - # - name: Workaround for bad mirror - # run: sudo gem install apt-spy2; sudo apt-spy2 check; sudo apt-spy2 fix --commit; - - name: Update package repository - run: sudo apt-get update; # sudo apt-get upgrade - - name: Install dependencies - run: sudo apt-get --yes install gjs libappindicator3-dev libgda-5.0-dev libgirepository1.0-dev libgtk-3-dev libgtk-4-dev libgtksourceview-3.0-dev libnotify-dev libsoup2.4-dev libsoup-3.0-dev libwebkit2gtk-4.0-dev libadwaita-1-dev gnome-shell-common libmutter-10-dev libgcr-3-dev libgnome-desktop-3-dev - - run: yarn install - - run: yarn run build - - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:node - - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:node \ No newline at end of file diff --git a/.ts-for-gir.all.rc.js b/.ts-for-gir.all.rc.js index ac4e45b8b..01a7b11b9 100644 --- a/.ts-for-gir.all.rc.js +++ b/.ts-for-gir.all.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['*'], girDirectories: ['./vala-girs/gir-1.0', './girs'], ignoreVersionConflicts: true, diff --git a/.ts-for-gir.gcalc.rc.js b/.ts-for-gir.gcalc.rc.js index 3bf2f19c9..c82439501 100644 --- a/.ts-for-gir.gcalc.rc.js +++ b/.ts-for-gir.gcalc.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: [/*'GCalc-1',*/ 'GCalc-2'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gio.rc.js b/.ts-for-gir.gio.rc.js index d1af95051..c0141e040 100644 --- a/.ts-for-gir.gio.rc.js +++ b/.ts-for-gir.gio.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['Gio-2.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk2.rc.js b/.ts-for-gir.gtk2.rc.js index 4f7194a19..ae8dac27c 100644 --- a/.ts-for-gir.gtk2.rc.js +++ b/.ts-for-gir.gtk2.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['Gtk-2.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk3+gtk4.rc.js b/.ts-for-gir.gtk3+gtk4.rc.js index c12e6e51c..f69d98e81 100644 --- a/.ts-for-gir.gtk3+gtk4.rc.js +++ b/.ts-for-gir.gtk3+gtk4.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['Gtk-3.0', 'Gtk-4.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk3.rc.js b/.ts-for-gir.gtk3.rc.js index 92c486b83..921eac660 100644 --- a/.ts-for-gir.gtk3.rc.js +++ b/.ts-for-gir.gtk3.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['Gtk-3.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk4.rc.js b/.ts-for-gir.gtk4.rc.js index 1ad29469c..19755daec 100644 --- a/.ts-for-gir.gtk4.rc.js +++ b/.ts-for-gir.gtk4.rc.js @@ -1,6 +1,6 @@ export default { - environments: ['gjs', 'node'], - modules: ['Gtk-4.0', 'Adw-1.0'], + environments: ['gjs'], + modules: ['Gtk-4.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], ignoreVersionConflicts: true, diff --git a/.ts-for-gir.modemmanager1.rc.js b/.ts-for-gir.modemmanager1.rc.js index 095633643..a1bd542fd 100644 --- a/.ts-for-gir.modemmanager1.rc.js +++ b/.ts-for-gir.modemmanager1.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['ModemManager-1.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.packages-all.rc.js b/.ts-for-gir.packages-all.rc.js index f0b7c77bb..cab70b116 100644 --- a/.ts-for-gir.packages-all.rc.js +++ b/.ts-for-gir.packages-all.rc.js @@ -1,6 +1,6 @@ export default { outdir: './types', - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['*'], girDirectories: [ // General gir files in this repository diff --git a/.ts-for-gir.rygelcore2.rc.js b/.ts-for-gir.rygelcore2.rc.js index 6ae8121f2..c88406977 100644 --- a/.ts-for-gir.rygelcore2.rc.js +++ b/.ts-for-gir.rygelcore2.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['RygelCore-2.6', 'RygelRenderer-2.6'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.timezonemap1.rc.js b/.ts-for-gir.timezonemap1.rc.js index 3f71a6ac1..82c1dbfca 100644 --- a/.ts-for-gir.timezonemap1.rc.js +++ b/.ts-for-gir.timezonemap1.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['TimezoneMap-1.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.vda1.rc.js b/.ts-for-gir.vda1.rc.js index b246049fb..8f5c06210 100644 --- a/.ts-for-gir.vda1.rc.js +++ b/.ts-for-gir.vda1.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['Vda-1'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.vte4.rc.js b/.ts-for-gir.vte4.rc.js index 8fb4fb2b9..012fd22f6 100644 --- a/.ts-for-gir.vte4.rc.js +++ b/.ts-for-gir.vte4.rc.js @@ -1,5 +1,5 @@ export default { - environments: ['gjs', 'node'], + environments: ['gjs'], modules: ['Vte-4*'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/examples/README.md b/examples/README.md index 019da75c4..2ec2ebaba 100644 --- a/examples/README.md +++ b/examples/README.md @@ -13,9 +13,8 @@ code examples/gjs/browser ![gtk-3-browser](gtk-3-browser.png) This example uses ESM when building the types and executing GJS. -On Node.js ESM is converted back to CommonJS (as long as node-gtk doesn't support ESM), but this way the types can still be used in ESM format. -Source: [GJS](gjs/gtk-3-browser), [node-gtk](node-gtk/gtk-3-browser) +Source: [GJS](gjs/gtk-3-browser) Bundler: Webpack Module: ESM @@ -23,16 +22,12 @@ Build and run: ```bash cd /examples/gjs/gtk-3-browser yarn run start - -# or for node-gtk -cd /examples/node-gtk/gtk-3-browser -yarn run start ``` ## Gtk-3.0 Builder ![gtk-3-builder](gtk-3-builder.png) -Source: [GJS](gjs/gtk-3-builder), [node-gtk](node-gtk/gtk-3-builder) +Source: [GJS](gjs/gtk-3-builder) Bundler: Webpack Module: CommonJS @@ -40,16 +35,12 @@ Build and run: ```bash cd /examples/gjs/gtk-3-builder yarn run start - -# or for node-gtk -cd /examples/node-gtk/gtk-3-builder -yarn run start ``` ## Gtk-3.0 Editor ![gtk-3-editor](gtk-3-editor.png) -Source: [GJS](gjs/gtk-3-editor), [node-gtk](node-gtk/gtk-3-editor) +Source: [GJS](gjs/gtk-3-editor) Bundler: Webpack Module: CommonJS @@ -57,16 +48,12 @@ Build and run: ```bash cd /examples/gjs/gtk-3-editor yarn run start - -# or for node-gtk -cd /examples/node-gtk/gtk-3-editor -yarn run start ``` ## Gtk-3.0 Hello Gtk ![gtk-3-hello](gtk-3-hello.png) -Source: [GJS](gjs/gtk-3-hello), [node-gtk](node-gtk/gtk-3-hello) +Source: [GJS](gjs/gtk-3-hello) Bundler: Webpack Module: CommonJS @@ -74,10 +61,6 @@ Build and run: ```bash cd /examples/gjs/gtk-3-hello yarn run start - -# or for node-gtk -cd /examples/node-gtk/gtk-3-hello -yarn run start ``` ## Gtk-4.0 ListStore @@ -120,9 +103,9 @@ Gjs-Message: 21:13:22.008: JS LOG: body: GJS example showing how to build a http server/client using Soap 3. -This example contains a client and a server example, for the client example the server must be running. You can also start the server from the node-gtk example and then request that with the gjs example and vice versa ;) +This example contains a client and a server example, for the client example the server must be running. -Source: [GJS](gjs/soup-3-http), [node-gtk](node-gtk/soup-3-http) +Source: [GJS](gjs/soup-3-http) Bundler: ESBuild Module: ESM @@ -132,20 +115,14 @@ cd /examples/gjs/soup-3-http yarn run build yarn run start:server yarn run start:client - -# or for node-gtk -cd /examples/node-gtk/soup-3-http -yarn run build -yarn run start:server -yarn run start:client ``` ## Gtk4 Custom Widget ![gtk-4-custom-widget](gtk-4-custom-widget.png) -This example shows the usage of custom widgets and virtual functions in GJS and node-gtk. +This example shows the usage of custom widgets and virtual functions in GJS. -Source: [GJS](gjs/gtk-4-custom-widget), [node-gtk](node-gtk/gtk-4-custom-widget) +Source: [GJS](gjs/gtk-4-custom-widget) Bundler: ESBuild Module: ESM @@ -153,8 +130,4 @@ Build and run: ```bash cd /examples/gjs/gtk-4-custom-widget yarn run start - -# or for node-gtk -cd /examples/node-gtk/gtk-4-custom-widget -yarn run start ``` \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-alias/esbuild.js b/examples/gjs/gio-2-cat-alias/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gio-2-cat-alias/esbuild.js +++ b/examples/gjs/gio-2-cat-alias/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-packages/esbuild.js b/examples/gjs/gio-2-cat-packages/esbuild.js index 327f0e881..ed1de7599 100644 --- a/examples/gjs/gio-2-cat-packages/esbuild.js +++ b/examples/gjs/gio-2-cat-packages/esbuild.js @@ -11,5 +11,5 @@ await build({ // target: firefox102 // Since GJS 1.73.2 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-promisify/esbuild.js b/examples/gjs/gio-2-cat-promisify/esbuild.js index 327f0e881..1828892ba 100644 --- a/examples/gjs/gio-2-cat-promisify/esbuild.js +++ b/examples/gjs/gio-2-cat-promisify/esbuild.js @@ -11,5 +11,5 @@ await build({ // target: firefox102 // Since GJS 1.73.2 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-types-only/esbuild.js b/examples/gjs/gio-2-cat-types-only/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gio-2-cat-types-only/esbuild.js +++ b/examples/gjs/gio-2-cat-types-only/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat/esbuild.js b/examples/gjs/gio-2-cat/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gio-2-cat/esbuild.js +++ b/examples/gjs/gio-2-cat/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-dbus/esbuild.js b/examples/gjs/gio-2-dbus/esbuild.js index b81654f2c..4e147bd88 100644 --- a/examples/gjs/gio-2-dbus/esbuild.js +++ b/examples/gjs/gio-2-dbus/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-calc/esbuild.js b/examples/gjs/gtk-3-calc/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-3-calc/esbuild.js +++ b/examples/gjs/gtk-3-calc/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-gettext/esbuild.js b/examples/gjs/gtk-3-gettext/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-3-gettext/esbuild.js +++ b/examples/gjs/gtk-3-gettext/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-hello-2/esbuild.js b/examples/gjs/gtk-3-hello-2/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-3-hello-2/esbuild.js +++ b/examples/gjs/gtk-3-hello-2/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-template/esbuild.js b/examples/gjs/gtk-3-template/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-3-template/esbuild.js +++ b/examples/gjs/gtk-3-template/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-webkit/esbuild.js b/examples/gjs/gtk-3-webkit/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-3-webkit/esbuild.js +++ b/examples/gjs/gtk-3-webkit/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-4-application/esbuild.js b/examples/gjs/gtk-4-application/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-4-application/esbuild.js +++ b/examples/gjs/gtk-4-application/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-4-custom-widget/esbuild.js b/examples/gjs/gtk-4-custom-widget/esbuild.js index fccbfb243..1ee1551f2 100644 --- a/examples/gjs/gtk-4-custom-widget/esbuild.js +++ b/examples/gjs/gtk-4-custom-widget/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-4-template/esbuild.js b/examples/gjs/gtk-4-template/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/gtk-4-template/esbuild.js +++ b/examples/gjs/gtk-4-template/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/soup-3-http/esbuild.js b/examples/gjs/soup-3-http/esbuild.js index 3966f3bda..e669e8fba 100644 --- a/examples/gjs/soup-3-http/esbuild.js +++ b/examples/gjs/soup-3-http/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/soup-3-websocket/esbuild.js b/examples/gjs/soup-3-websocket/esbuild.js index 5790cc7a4..5a7081cb4 100644 --- a/examples/gjs/soup-3-websocket/esbuild.js +++ b/examples/gjs/soup-3-websocket/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/gjs/timers/esbuild.js b/examples/gjs/timers/esbuild.js index 0f01e258b..c013b7046 100644 --- a/examples/gjs/timers/esbuild.js +++ b/examples/gjs/timers/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], + external: ['gi://*'], }) \ No newline at end of file diff --git a/examples/node-gtk/gio-2-cat-packages/.gitignore b/examples/node-gtk/gio-2-cat-packages/.gitignore deleted file mode 100644 index dad405d9f..000000000 --- a/examples/node-gtk/gio-2-cat-packages/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Yarn https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions - -!@types/ -@types/node-gio-2.0/* -!@types/node-gio-2.0/package.json -@types/node-glib-2.0/* -!@types/node-glib-2.0/package.json -@types/node-gobject-2.0/* -!@types/node-gobject-2.0/package.json -@types/node-gtk/* -!@types/node-gtk/package.json \ No newline at end of file diff --git a/examples/node-gtk/gio-2-cat-packages/esbuild.mjs b/examples/node-gtk/gio-2-cat-packages/esbuild.mjs deleted file mode 100644 index 8da2de1d1..000000000 --- a/examples/node-gtk/gio-2-cat-packages/esbuild.mjs +++ /dev/null @@ -1,15 +0,0 @@ -import { build } from "esbuild"; - -await build({ - entryPoints: ['main.ts'], - outdir: 'dist', - bundle: true, - // target: "firefox60", // Since GJS 1.53.90 - // target: "firefox68", // Since GJS 1.63.90 - // target: "firefox78", // Since GJS 1.65.90 - target: "firefox91", // Since GJS 1.71.1 - // target: firefox102 // Since GJS 1.73.2 - format: 'cjs', - platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], -}) \ No newline at end of file diff --git a/examples/node-gtk/gio-2-cat-packages/main.ts b/examples/node-gtk/gio-2-cat-packages/main.ts deleted file mode 100644 index 62bf4da73..000000000 --- a/examples/node-gtk/gio-2-cat-packages/main.ts +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later -// SPDX-FileCopyrightText: 2009 Red Hat, Inc. -// Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gio-cat.js - -/* - * Make sure you have a non english locale installed, for example fr_FR and run - * LANGUAGE=fr_FR gjs gettext.js - * the label should show a translation of 'Print help' - */ -import "@girs/node-gtk/ambient" -import "@girs/node-gio-2.0" - -import gi = require("node-gtk"); -const Gio = gi.require("Gio", "2.0"); - -function cat(filename: string) { - const file = Gio.fileNewForPath(filename); - - // @ts-ignore - file.__proto__= Gio.File.prototype - - const [success, contents] = file.loadContents(null); - if (!success) { - console.error("Failed to read file", filename); - process.exit(1); - } - - console.log(Buffer.from(contents).toString()); - process.exit(0); -} - -if (process.argv.length !== 3) - console.error('Usage: node gio-cat.js filename', process.argv); -else { - gi.startLoop() - cat(process.argv[2]); -} diff --git a/examples/node-gtk/gio-2-cat-packages/package.json b/examples/node-gtk/gio-2-cat-packages/package.json deleted file mode 100644 index 2f195536a..000000000 --- a/examples/node-gtk/gio-2-cat-packages/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-gio-2-cat-promisify-packages", - "version": "3.2.8", - "description": "Simple Node Gtk 3 example app that shows how you can translate strings with gettext", - "main": "index.js", - "type": "commonjs", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build:app": "yarn node esbuild.mjs", - "build": "yarn build:app", - "start:app": "node dist/main.js main.ts", - "debug:app": "GTK_DEBUG=interactive yarn start:app", - "start": "yarn clear && yarn build && yarn start:app", - "validate": "yarn validate:app", - "validate:app": "tsc --noEmit", - "clear": "rm -rf dist @types" - }, - "author": "Pascal Garber ", - "license": "MIT", - "devDependencies": { - "esbuild": "^0.20.0", - "typescript": "5.2.2" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/gio-2-cat-packages/tsconfig.json b/examples/node-gtk/gio-2-cat-packages/tsconfig.json deleted file mode 100644 index 0cbc88687..000000000 --- a/examples/node-gtk/gio-2-cat-packages/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "lib": ["ESNext"], - "types": ["node"], - "target": "ESNext", - "module": "CommonJS", - "moduleResolution": "node" - }, - "include": ["@girs/node-gtk/ambient"], - "files": [ - "main.ts", - ] -} diff --git a/examples/node-gtk/gio-2-cat-packages/tsconfig.types.json b/examples/node-gtk/gio-2-cat-packages/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gio-2-cat-packages/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/glib-2-spawn-command/main.ts b/examples/node-gtk/glib-2-spawn-command/main.ts deleted file mode 100644 index 7050d0396..000000000 --- a/examples/node-gtk/glib-2-spawn-command/main.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Example based on https://gist.github.com/buzztaiki/1487781/74ea93d3a30f20c7f094327db9cb263a6286f6d6 -import * as GLib from './@types/node-glib-2.0' - -let [res, out, err, status] = GLib.spawnCommandLineSync('ls -la'); -console.log(Buffer.from(out).toString()); - -[res, out] = GLib.spawnCommandLineSync('ls -la'); -console.log(Buffer.from(out).toString()); - -[res, out] = GLib.spawnSync(null, ['/bin/ls', '-la'], null, 0, null); -console.log(Buffer.from(out).toString()); - -[res, out] = GLib.spawnSync(GLib.getenv('HOME'), ['/bin/ls', '-la'], null, 0, null); -console.log(Buffer.from(out).toString()); - -[res, out] = GLib.spawnSync(null, ['ls', '-la'], null, GLib.SpawnFlags.SEARCH_PATH, null); -console.log(Buffer.from(out).toString()); \ No newline at end of file diff --git a/examples/node-gtk/glib-2-spawn-command/package.json b/examples/node-gtk/glib-2-spawn-command/package.json deleted file mode 100644 index 48a0c2a32..000000000 --- a/examples/node-gtk/glib-2-spawn-command/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "ts-for-gir-node-glib-2-spawn-command-example", - "version": "3.2.8", - "description": "", - "main": "main.ts", - "private": true, - "scripts": { - "build": "yarn build:types && yarn build:app", - "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate GLib-2.0 -e node --noNamespace -t cjs", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start": "yarn clear && yarn build && yarn start:app", - "start:app": "yarn node dist/main.js", - "watch": "yarn build:app --watch", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "Apache-2.0", - "engines": { - "node": ">=16" - }, - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "@types/node": "^20.11.18", - "fork-ts-checker-webpack-plugin": "^9.0.2", - "raw-loader": "^4.0.2", - "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", - "webpack-cli": "^5.1.4", - "webpack-node-externals": "^3.0.0" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/glib-2-spawn-command/tsconfig.json b/examples/node-gtk/glib-2-spawn-command/tsconfig.json deleted file mode 100644 index b0e17efc6..000000000 --- a/examples/node-gtk/glib-2-spawn-command/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "types": ["node"], - "declaration": true, - "noImplicitAny": false, - "removeComments": true, - "noLib": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES6", - "sourceMap": true, - "outDir": "./dist" - }, - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/glib-2-spawn-command/tsconfig.types.json b/examples/node-gtk/glib-2-spawn-command/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/glib-2-spawn-command/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/glib-2-spawn-command/webpack.config.js b/examples/node-gtk/glib-2-spawn-command/webpack.config.js deleted file mode 100644 index 1ccb62059..000000000 --- a/examples/node-gtk/glib-2-spawn-command/webpack.config.js +++ /dev/null @@ -1,40 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -const path = require('path'); - -module.exports = { - entry: ['./main.ts'], - target: 'node', - externals: [ - nodeExternals(), - nodeExternals({ - // necessary so that it also works with npm workspaces - modulesDir: path.resolve(__dirname, '../../../node_modules') - }), - ], - output: { - filename: 'main.js', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: [/node_modules/], - options: { - // disable type checker - we will use it in fork plugin - transpileOnly: true - } - }, - { - test: /\.(txt|glade)$/i, - use: 'raw-loader', - }, - ], - }, - mode: "development", - resolve: { - extensions: ['.tsx', '.ts', '.js'], - }, - plugins: [new ForkTsCheckerWebpackPlugin()] -}; diff --git a/examples/node-gtk/gtk-3-browser/main.ts b/examples/node-gtk/gtk-3-browser/main.ts deleted file mode 100644 index 1f56caac6..000000000 --- a/examples/node-gtk/gtk-3-browser/main.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { inspect } from 'util' - -import { Gtk } from './@types/node-gtk-3.0' -import { Pango } from './@types/node-pango-1.0' -import { WebKit2 } from './@types/node-webkit2-4.0' - -// import gi from 'node-gtk'; -// const Gtk = gi.require('Gtk', '3.0') -// const Pango = gi.require('Pango', '1.0') -// const WebKit2 = gi.require('WebKit2', '4.0') - -function makeButton(label: string, callback: () => void) { - const but = new Gtk.Button({ label: label }) - but.getChild()?.modifyFont(Pango.FontDescription.fromString('sans bold 16')) - but.on('clicked', () => { - callback() - }) - return but -} - -Gtk.init(null) - -const wnd = new Gtk.Window() -// TODO const wnd = new Gtk.Window({ title: 'Browser Test', defaultWidth: 800, defaultHeight: 600 }) -wnd.setDefaultSize(800, 600) -wnd.setTitle('Browser Test') -const webview = new WebKit2.WebView({}) -const scrolledWindow = new Gtk.ScrolledWindow({}) -const box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) -const entry = new Gtk.Entry({ text: 'about:none', halign: Gtk.Align.FILL }) -const spinner = new Gtk.Spinner({}); - -const hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) -hbox.packStart( - makeButton('⇦', () => { - webview.goBack() - }), - false, - false, - 5, -) -hbox.packStart( - makeButton('⇨', () => { - webview.goForward() - }), - false, - false, - 5, -) -hbox.packStart( - makeButton('↻', () => { - webview.reload() - }), - false, - false, - 5, -) -hbox.packStart(entry, true, true, 5) -hbox.packStart(spinner, false, false, 5) - -wnd.on('delete-event', () => { - Gtk.mainQuit() - return false -}) -entry.on('activate', () => { - let uri = entry.text - if (!(uri.startsWith('http://') || uri.startsWith('https://') || uri.startsWith('ftp://'))) uri = 'http://' + uri - webview.loadUri(uri) -}) -webview.on('notify::uri', () => { - entry.text = webview.uri -}) -webview.on('notify::is-loading', () => { - spinner.active = (webview as any).isLoading() // TODO -}) - -// TODO what is the name if the `is-loading` property? -console.log('webview', inspect(webview.isLoading)) - -scrolledWindow.add(webview as Gtk.Widget) -box.packStart(hbox, false, true, 0) -box.packStart(scrolledWindow, true, true, 0) -wnd.add(box) -wnd.showAll() - -webview.loadUri('https://duckduckgo.com/') - -Gtk.main() diff --git a/examples/node-gtk/gtk-3-browser/package.json b/examples/node-gtk/gtk-3-browser/package.json deleted file mode 100644 index d070cb3ed..000000000 --- a/examples/node-gtk/gtk-3-browser/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-3-browser-example", - "version": "3.2.8", - "description": "", - "main": "dist/main.js", - "private": true, - "scripts": { - "build": "yarn build:types && yarn build:app", - "build:app": "yarn clear:ts && webpack --config webpack.config.cjs --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0 -e node -t esm", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start": "yarn clear && yarn build && yarn start:app", - "start:app": "yarn node dist/main.js", - "watch": "yarn build:app --watch", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "Apache-2.0", - "engines": { - "node": ">=16" - }, - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "@types/node": "^20.11.18", - "fork-ts-checker-webpack-plugin": "^9.0.2", - "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", - "webpack-cli": "^5.1.4", - "webpack-node-externals": "^3.0.0" - }, - "dependencies": { - "node-gtk": "^0.12.0", - "util": "^0.12.5" - } -} diff --git a/examples/node-gtk/gtk-3-browser/tsconfig.json b/examples/node-gtk/gtk-3-browser/tsconfig.json deleted file mode 100644 index 315778cd5..000000000 --- a/examples/node-gtk/gtk-3-browser/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "types": ["node"], - "target": "ESNext", - "module": "NodeNext", - "moduleResolution":"NodeNext", - "declaration": true, - "noImplicitAny": false, - "removeComments": true, - "noLib": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "outDir": "./dist" - }, - "include": ["@types/node-gtk.d.ts", "@types/node-gtk-3.0.d.ts", "@types/node-pango-1.0.d.ts", "@types/node-webkit2-4.0.d.ts"], - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/gtk-3-browser/tsconfig.types.json b/examples/node-gtk/gtk-3-browser/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-3-browser/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/gtk-3-browser/webpack.config.cjs b/examples/node-gtk/gtk-3-browser/webpack.config.cjs deleted file mode 100644 index b62749e14..000000000 --- a/examples/node-gtk/gtk-3-browser/webpack.config.cjs +++ /dev/null @@ -1,39 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); // TypeScript type checker -const path = require('path'); - -exports.default = { - mode: 'development', - entry: ['./main.ts'], - externalsPresets: { node: true }, - externals: [ - nodeExternals(), - nodeExternals({ - // necessary so that it also works with npm workspaces - modulesDir: path.resolve(__dirname, '../../../node_modules') - }), - ], - output: { - filename: 'main.js', - }, - target: 'node', - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: [/node_modules/], - options: { - // disable type checker - we will use it in fork plugin - transpileOnly: true - } - }, - ], - }, - resolve: { - extensions: ['.tsx', '.jsx', '.ts', '.js'], - }, - plugins: [ - new ForkTsCheckerWebpackPlugin() - ] -}; diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/builder-auto-connect-signals.glade b/examples/node-gtk/gtk-3-builder-auto-connect-signals/builder-auto-connect-signals.glade deleted file mode 100644 index 46a3f4908..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/builder-auto-connect-signals.glade +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - False - - - - - - - - True - False - vertical - - - True - False - - - True - True - 0 - - - - - Action - True - True - True - - - - False - True - 1 - - - - - Close - True - True - True - - - - False - True - 2 - - - - - - diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/global.ts b/examples/node-gtk/gtk-3-builder-auto-connect-signals/global.ts deleted file mode 100644 index c17db0083..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/global.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.glade' { - const glade: string - export default glade -} diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/main.ts b/examples/node-gtk/gtk-3-builder-auto-connect-signals/main.ts deleted file mode 100644 index 33c371d68..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/main.ts +++ /dev/null @@ -1,32 +0,0 @@ -import './global' -import gi from './@types/node-gtk.js' -import gladeFile from './builder-auto-connect-signals.glade' -import * as Gtk from './@types/node-gtk-3.0.js' - -gi.startLoop() -Gtk.init(process.argv) - -const builder = Gtk.Builder.newFromString(gladeFile, gladeFile.length) -const win = builder.getObject('mainWindow') as Gtk.Window - -win.setDefaultSize(600, 400) - -const handlers = { - onWindowShow: Gtk.main, - onWindowDestroy: Gtk.mainQuit, - onCloseBtnClicked: function () { - win.close() - console.log('window closed') - }, - onActionBtnClicked: function () { - console.log('button clicked') - }, -} - -// Connect to signals that specified on glade file -builder.connectSignals(handlers) - -const label = builder.getObject('helloLabel') as Gtk.Label -label.setText('Hello World!') - -win.showAll() diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/package.json b/examples/node-gtk/gtk-3-builder-auto-connect-signals/package.json deleted file mode 100644 index 66f995ed8..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-3-builder-auto-connect-signals-example", - "version": "3.2.8", - "description": "", - "main": "main.ts", - "private": true, - "scripts": { - "build": "yarn build:types && yarn build:wp", - "build:wp": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 -e node --noNamespace -t cjs", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start": "yarn build && yarn start:app", - "start:app": "yarn node dist/main.js", - "watch": "yarn build:wp --watch", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "Apache-2.0", - "engines": { - "node": ">=16" - }, - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "@types/node": "^20.11.18", - "fork-ts-checker-webpack-plugin": "^9.0.2", - "raw-loader": "^4.0.2", - "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", - "webpack-cli": "^5.1.4", - "webpack-node-externals": "^3.0.0" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.json b/examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.json deleted file mode 100644 index b0e17efc6..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "types": ["node"], - "declaration": true, - "noImplicitAny": false, - "removeComments": true, - "noLib": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES6", - "sourceMap": true, - "outDir": "./dist" - }, - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.types.json b/examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/gtk-3-builder-auto-connect-signals/webpack.config.js b/examples/node-gtk/gtk-3-builder-auto-connect-signals/webpack.config.js deleted file mode 100644 index 1ccb62059..000000000 --- a/examples/node-gtk/gtk-3-builder-auto-connect-signals/webpack.config.js +++ /dev/null @@ -1,40 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -const path = require('path'); - -module.exports = { - entry: ['./main.ts'], - target: 'node', - externals: [ - nodeExternals(), - nodeExternals({ - // necessary so that it also works with npm workspaces - modulesDir: path.resolve(__dirname, '../../../node_modules') - }), - ], - output: { - filename: 'main.js', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: [/node_modules/], - options: { - // disable type checker - we will use it in fork plugin - transpileOnly: true - } - }, - { - test: /\.(txt|glade)$/i, - use: 'raw-loader', - }, - ], - }, - mode: "development", - resolve: { - extensions: ['.tsx', '.ts', '.js'], - }, - plugins: [new ForkTsCheckerWebpackPlugin()] -}; diff --git a/examples/node-gtk/gtk-3-builder/builderExample.glade b/examples/node-gtk/gtk-3-builder/builderExample.glade deleted file mode 100644 index 275ba7276..000000000 --- a/examples/node-gtk/gtk-3-builder/builderExample.glade +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - False - - - - - - True - False - vertical - - - True - False - - - True - True - 0 - - - - - Action - True - True - True - - - False - True - 1 - - - - - Close - True - True - True - - - False - True - 2 - - - - - - diff --git a/examples/node-gtk/gtk-3-builder/global.ts b/examples/node-gtk/gtk-3-builder/global.ts deleted file mode 100644 index c17db0083..000000000 --- a/examples/node-gtk/gtk-3-builder/global.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.glade' { - const glade: string - export default glade -} diff --git a/examples/node-gtk/gtk-3-builder/main.ts b/examples/node-gtk/gtk-3-builder/main.ts deleted file mode 100644 index 0cb9cabf0..000000000 --- a/examples/node-gtk/gtk-3-builder/main.ts +++ /dev/null @@ -1,71 +0,0 @@ -import './global' -import gi from './@types/node-gtk.js' -import { performance } from 'perf_hooks' -import gladeFile from './builderExample.glade' - -import Gtk from './@types/node-gtk-3.0.js' -// const Gtk = gi.require('Gtk', '3.0') - -gi.startLoop() -Gtk.init(process.argv) - -const builder = Gtk.Builder.newFromString(gladeFile, gladeFile.length) -const win = builder.getObject('mainWindow') as Gtk.Window | null - -win.setDefaultSize(600, 400) -win.on('show', Gtk.main) -win.on('destroy', Gtk.mainQuit) - -const closeButton = builder.getObject('closeButton') as Gtk.Button | null -if (!closeButton) { - throw new Error('Builder object closeButton not found!') -} - -const actionButton = builder.getObject('actionButton') as Gtk.Button | null -if (!actionButton) { - throw new Error('Builder object actionButton not found!') -} - -const label = builder.getObject('helloLabel') as Gtk.Label | null -if (!label) { - throw new Error('Builder object helloLabel not found!') -} - -closeButton.on('clicked', () => { - win.close() - console.log('window closed') -}) - -actionButton.on('clicked', () => { - const start = performance.now() - - Promise.resolve().then(() => { - console.log('event promise.then() called, ' + (performance.now() - start)) - }) - - process.nextTick(() => { - console.log('event nextTick() called, ' + (performance.now() - start)) - }) -}) - -label.setText('Hello World!') - -const action = function () { - return new Promise((resolve) => { - resolve('CHANGED') - console.log('new Promise(...) called') - }) -} - -const start = performance.now() -action().then((res: string) => { - console.log('promise.then() called, ' + (performance.now() - start)) - label.setText(res) -}) - -process.nextTick(() => { - console.log('nextTick() called') - Promise.resolve().then(() => console.log('inner promise.then() called')) -}) - -win.showAll() diff --git a/examples/node-gtk/gtk-3-builder/package.json b/examples/node-gtk/gtk-3-builder/package.json deleted file mode 100644 index f98aa2449..000000000 --- a/examples/node-gtk/gtk-3-builder/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-3-builder-example", - "version": "3.2.8", - "description": "", - "main": "main.ts", - "private": true, - "scripts": { - "build": "yarn build:types && yarn build:app", - "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 -e node --noNamespace -t cjs", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start": "yarn build && yarn start:app", - "start:app": "yarn node dist/main.js", - "watch": "yarn build:app --watch", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "Apache-2.0", - "engines": { - "node": ">=16" - }, - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "@types/node": "^20.11.18", - "fork-ts-checker-webpack-plugin": "^9.0.2", - "raw-loader": "^4.0.2", - "terser-webpack-plugin": "^5.3.10", - "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", - "webpack-cli": "^5.1.4", - "webpack-node-externals": "^3.0.0" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/gtk-3-builder/tsconfig.json b/examples/node-gtk/gtk-3-builder/tsconfig.json deleted file mode 100644 index b0e17efc6..000000000 --- a/examples/node-gtk/gtk-3-builder/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "types": ["node"], - "declaration": true, - "noImplicitAny": false, - "removeComments": true, - "noLib": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES6", - "sourceMap": true, - "outDir": "./dist" - }, - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/gtk-3-builder/tsconfig.types.json b/examples/node-gtk/gtk-3-builder/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-3-builder/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/gtk-3-builder/webpack.config.js b/examples/node-gtk/gtk-3-builder/webpack.config.js deleted file mode 100644 index 80630f433..000000000 --- a/examples/node-gtk/gtk-3-builder/webpack.config.js +++ /dev/null @@ -1,45 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -const TerserPlugin = require("terser-webpack-plugin"); -const path = require('path'); - -module.exports = { - entry: ['./main.ts'], - target: 'node', - externals: [ - nodeExternals(), - nodeExternals({ - // necessary so that it also works with npm workspaces - modulesDir: path.resolve(__dirname, '../../../node_modules') - }), - ], - output: { - filename: 'main.js', - }, - optimization: { - minimize: true, - minimizer: [new TerserPlugin()], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: [/node_modules/], - options: { - // disable type checker - we will use it in fork plugin - transpileOnly: true - } - }, - { - test: /\.(txt|glade)$/i, - use: 'raw-loader', - }, - ], - }, - mode: "production", - resolve: { - extensions: ['.tsx', '.ts', '.js'], - }, - plugins: [new ForkTsCheckerWebpackPlugin()] -}; diff --git a/examples/node-gtk/gtk-3-editor/main.ts b/examples/node-gtk/gtk-3-editor/main.ts deleted file mode 100644 index 8a6ad5475..000000000 --- a/examples/node-gtk/gtk-3-editor/main.ts +++ /dev/null @@ -1,40 +0,0 @@ - -import gi from './@types/node-gtk' -import * as Gtk from './@types/node-gtk-3.0' -import * as GtkSource from './@types/node-gtksource-3.0' - -// const Gtk = gi.require('Gtk', '3.0') -// const GtkSource = gi.require('GtkSource') - -gi.startLoop() -Gtk.init(null) - -const wnd = new Gtk.Window({ title: 'Editor Test' }) -wnd.defaultHeight = 400 -wnd.defaultWidth = 600 -const box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }) -const notebook = new Gtk.Notebook() -const srcView = new GtkSource.View() - -srcView.autoIndent = true -srcView.showLineNumbers = true -srcView.monospace = true - -const buf = srcView.getBuffer() as GtkSource.Buffer -const lang = GtkSource.LanguageManager.getDefault().getLanguage('js') -buf.setLanguage(lang) - -notebook.add(srcView) - -box.packStart(notebook, true, true, 0) -wnd.add(box) -wnd.showAll() - -wnd.connect('delete-event', () => { - Gtk.mainQuit() - return true -}) - -console.log('hello world') - -Gtk.main() diff --git a/examples/node-gtk/gtk-3-editor/package.json b/examples/node-gtk/gtk-3-editor/package.json deleted file mode 100644 index 1ea912249..000000000 --- a/examples/node-gtk/gtk-3-editor/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-3-editor-example", - "version": "3.2.8", - "description": "", - "main": "main.ts", - "private": true, - "scripts": { - "build": "yarn build:types && yarn build:app", - "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 -e node --noNamespace -t cjs", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start": "yarn build && yarn start:app", - "start:app": "yarn node dist/main.js", - "watch": "yarn build:app --watch", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "Apache-2.0", - "engines": { - "node": ">=16" - }, - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "@types/node": "^20.11.18", - "fork-ts-checker-webpack-plugin": "^9.0.2", - "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", - "webpack-cli": "^5.1.4", - "webpack-node-externals": "^3.0.0" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/gtk-3-editor/tsconfig.json b/examples/node-gtk/gtk-3-editor/tsconfig.json deleted file mode 100644 index b0e17efc6..000000000 --- a/examples/node-gtk/gtk-3-editor/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "types": ["node"], - "declaration": true, - "noImplicitAny": false, - "removeComments": true, - "noLib": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES6", - "sourceMap": true, - "outDir": "./dist" - }, - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/gtk-3-editor/tsconfig.types.json b/examples/node-gtk/gtk-3-editor/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-3-editor/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/gtk-3-editor/webpack.config.js b/examples/node-gtk/gtk-3-editor/webpack.config.js deleted file mode 100644 index 136c1d84b..000000000 --- a/examples/node-gtk/gtk-3-editor/webpack.config.js +++ /dev/null @@ -1,36 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -const path = require('path'); - -module.exports = { - entry: ['./main.ts'], - target: 'node', - externals: [ - nodeExternals(), - nodeExternals({ - // necessary so that it also works with npm workspaces - modulesDir: path.resolve(__dirname, '../../../node_modules') - }), - ], - output: { - filename: 'main.js', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: [/node_modules/], - options: { - // disable type checker - we will use it in fork plugin - transpileOnly: true - } - }, - ], - }, - mode: "development", - resolve: { - extensions: ['.tsx', '.ts', '.js'], - }, - plugins: [new ForkTsCheckerWebpackPlugin()] -}; diff --git a/examples/node-gtk/gtk-3-hello/main.ts b/examples/node-gtk/gtk-3-hello/main.ts deleted file mode 100644 index aea5f0c5c..000000000 --- a/examples/node-gtk/gtk-3-hello/main.ts +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env node -// Based on https://github.com/romgrk/node-gtk/blob/master/examples/hello-gtk.js - -import gi from './@types/node-gtk.js' -import * as Gtk from './@types/node-gtk-3.0.js' - -gi.startLoop() -Gtk.init(process.argv) - -const settings = Gtk.Settings.getDefault() -settings.gtkApplicationPreferDarkTheme = true -settings.gtkThemeName = 'Adwaita' - -console.log(settings.gtkEnableAccels) - -const win = new Gtk.Window() -win.setTitle('node-gtk') -win.setPosition(Gtk.WindowPosition.CENTER) -win.setDefaultSize(200, 80) - -win.on('show', Gtk.main) -win.on('destroy', Gtk.mainQuit) - -win.add(new Gtk.Label({ label: 'Hello Gtk+' })) -win.showAll() diff --git a/examples/node-gtk/gtk-3-hello/package.json b/examples/node-gtk/gtk-3-hello/package.json deleted file mode 100644 index f8074423e..000000000 --- a/examples/node-gtk/gtk-3-hello/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-3-hello-example", - "version": "3.2.8", - "description": "", - "main": "dist/main.js", - "private": true, - "scripts": { - "build": "yarn build:types && yarn build:app", - "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 -e node --noNamespace -t cjs", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start": "yarn clear && yarn build && yarn start:app", - "start:app": "yarn node dist/main.js", - "watch": "yarn build:app --watch", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "Apache-2.0", - "engines": { - "node": ">=16" - }, - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "@types/node": "^20.11.18", - "fork-ts-checker-webpack-plugin": "^9.0.2", - "raw-loader": "^4.0.2", - "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", - "webpack-cli": "^5.1.4", - "webpack-node-externals": "^3.0.0" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/gtk-3-hello/tsconfig.json b/examples/node-gtk/gtk-3-hello/tsconfig.json deleted file mode 100644 index b0e17efc6..000000000 --- a/examples/node-gtk/gtk-3-hello/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "types": ["node"], - "declaration": true, - "noImplicitAny": false, - "removeComments": true, - "noLib": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES6", - "sourceMap": true, - "outDir": "./dist" - }, - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/gtk-3-hello/tsconfig.types.json b/examples/node-gtk/gtk-3-hello/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-3-hello/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/gtk-3-hello/webpack.config.js b/examples/node-gtk/gtk-3-hello/webpack.config.js deleted file mode 100644 index 1ccb62059..000000000 --- a/examples/node-gtk/gtk-3-hello/webpack.config.js +++ /dev/null @@ -1,40 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -const path = require('path'); - -module.exports = { - entry: ['./main.ts'], - target: 'node', - externals: [ - nodeExternals(), - nodeExternals({ - // necessary so that it also works with npm workspaces - modulesDir: path.resolve(__dirname, '../../../node_modules') - }), - ], - output: { - filename: 'main.js', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: [/node_modules/], - options: { - // disable type checker - we will use it in fork plugin - transpileOnly: true - } - }, - { - test: /\.(txt|glade)$/i, - use: 'raw-loader', - }, - ], - }, - mode: "development", - resolve: { - extensions: ['.tsx', '.ts', '.js'], - }, - plugins: [new ForkTsCheckerWebpackPlugin()] -}; diff --git a/examples/node-gtk/gtk-4-custom-widget/esbuild.js b/examples/node-gtk/gtk-4-custom-widget/esbuild.js deleted file mode 100644 index 94a38d53e..000000000 --- a/examples/node-gtk/gtk-4-custom-widget/esbuild.js +++ /dev/null @@ -1,12 +0,0 @@ -require('esbuild').build({ - entryPoints: ['index.ts'], - outdir: 'dist', - bundle: true, - // target: "firefox60", // Since GJS 1.53.90 - // target: "firefox68", // Since GJS 1.63.90 - target: "firefox78", // Since GJS 1.65.90 - // target: "firefox91", // Since GJS 1.71.1 - format: 'cjs', - platform: 'node', - external: ['node-gtk'], -}) \ No newline at end of file diff --git a/examples/node-gtk/gtk-4-custom-widget/index.ts b/examples/node-gtk/gtk-4-custom-widget/index.ts deleted file mode 100644 index 452b260b6..000000000 --- a/examples/node-gtk/gtk-4-custom-widget/index.ts +++ /dev/null @@ -1,126 +0,0 @@ -// This example is based on https://github.com/romgrk/node-gtk/blob/master/examples/gtk-4-custom-widget.js -// TODO? https://github.com/romgrk/node-gtk/issues/341 - -import gi from './@types/node-gtk.js'; -import GLib from './@types/node-glib-2.0.js'; -import Gtk from './@types/node-gtk-4.0.js'; -import Gdk from './@types/node-gdk-4.0.js'; -import Graphene from './@types/node-graphene-1.0.js'; - -Gtk.init() -console.log('Init Gtk DONE') - -/* Define our custom widget */ - -class CustomWidget extends Gtk.Widget { - customMethod() { - console.log("Hello from CustomWidget.customMethod") - } - - measure(orientation: Gtk.Orientation, forSize: number) { - const [minWidth, natWidth] = [100, 200] - const [minHeight, natHeight] = [20, 40] - const isHorizontal = orientation === Gtk.Orientation.HORIZONTAL - - const minimum = isHorizontal ? minWidth : minHeight - const natural = isHorizontal ? natWidth : natHeight - const minimumBaseline = !isHorizontal ? minWidth : minHeight - const naturalBaseline = !isHorizontal ? natWidth : natHeight - - return [minimum, natural, minimumBaseline, naturalBaseline] as [number, number, number, number] - } - - snapshot(snapshot: Gtk.Snapshot) { - const width = this.getAllocatedWidth() - const color = Gdk.RGBA.create('red') - const rect = Graphene.Rect.create(10, 10, width / 2, 10) - snapshot.appendColor(color, rect) - } -} - -gi.registerClass(CustomWidget) -console.log('registerClass DONE') - -/* Setup & start the application */ - -const loop = new GLib.MainLoop(null, false) -const app = new Gtk.Application('com.github.romgrk.node-gtk.demo', 0) -app.on('activate', onActivate) -const status = app.run([]) - -console.log('Finished with status:', status) - -/* Event handlers */ - -function onActivate() { - console.log('onActivate...') - const window = new Gtk.ApplicationWindow(app) - window.setTitle('Window') - window.setDefaultSize(200, 200) - window.on('close-request', onQuit) - - const ui = getUI() - const builder = Gtk.Builder.newFromString(ui, ui.length) - const root = builder.getObject('root') as Gtk.Box - console.log('getObject root:', root) - const custom = new CustomWidget() - root.append(custom) - - const actionButton = builder.getObject('actionButton') as Gtk.Button - actionButton?.on('clicked', () => { - console.log('actionButton clicked...') - custom.customMethod() - }) - - const closeButton = builder.getObject('closeButton') as Gtk.Button - closeButton?.on('clicked', () => { - console.log('closeButton clicked...') - window.close() - }) - - window.setChild(root) - window.present() - - console.log('startLoop...') - gi.startLoop() - loop.run() - console.log('startLoop DONE') -} - -function onQuit() { - console.log('onQuit...') - loop.quit() - app.quit() - console.log('onQuit DONE') - return false -} - -function getUI() { - return ` - - - - - vertical - - - 1 - Hello World! - - - - - Action - 1 - - - - - Close - 1 - - - - - ` -} diff --git a/examples/node-gtk/gtk-4-custom-widget/package.json b/examples/node-gtk/gtk-4-custom-widget/package.json deleted file mode 100644 index f22a7d224..000000000 --- a/examples/node-gtk/gtk-4-custom-widget/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-gtk-4-custom-widget-example", - "version": "3.2.8", - "description": "This example shows the usage of custom widgets and virtual functions in node-gtk", - "main": "dist/index.js", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 Gdk-4.0 Graphene-1.0 -e node", - "build:app": "yarn node esbuild.js", - "build": "yarn build:types && yarn build:app", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start:app": "yarn node dist/index.js", - "start": "yarn clear && yarn build && yarn start:app", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit" - }, - "author": "Pascal Garber ", - "license": "MIT", - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/gtk-4-custom-widget/tsconfig.json b/examples/node-gtk/gtk-4-custom-widget/tsconfig.json deleted file mode 100644 index 3621881bd..000000000 --- a/examples/node-gtk/gtk-4-custom-widget/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "types": ["node"], - "target": "ESNext", - "module": "Node16", - "strict": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "noImplicitAny": true, - "strictNullChecks": true, - "noImplicitThis": true, - "alwaysStrict": true, - "moduleResolution":"Node16" - }, - "files": [ - "index.ts" - ] -} diff --git a/examples/node-gtk/gtk-4-custom-widget/tsconfig.types.json b/examples/node-gtk/gtk-4-custom-widget/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-4-custom-widget/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/node-gtk/soup-3-http/esbuild.js b/examples/node-gtk/soup-3-http/esbuild.js deleted file mode 100644 index 615ef4316..000000000 --- a/examples/node-gtk/soup-3-http/esbuild.js +++ /dev/null @@ -1,12 +0,0 @@ -require('esbuild').build({ - entryPoints: ['http-client.ts', 'http-server.ts'], - outdir: 'dist', - bundle: true, - // target: "firefox60", // Since GJS 1.53.90 - // target: "firefox68", // Since GJS 1.63.90 - target: "firefox78", // Since GJS 1.65.90 - // target: "firefox91", // Since GJS 1.71.1 - format: 'cjs', - platform: 'node', - external: ['node-gtk'], -}) \ No newline at end of file diff --git a/examples/node-gtk/soup-3-http/http-client.ts b/examples/node-gtk/soup-3-http/http-client.ts deleted file mode 100644 index 6da715ec3..000000000 --- a/examples/node-gtk/soup-3-http/http-client.ts +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later -// SPDX-FileCopyrightText: 2019 Sonny Piers -// Copyright 2022 Pascal Garber - -// This is a simple example of a HTTP client in Gjs using libsoup 3 -// https://developer.gnome.org/libsoup/stable/libsoup-client-howto.html -// https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/http-client.js - -// TODO callbacks not working in node-gtk? - -import gi from './@types/node-gtk.js'; -import GLib from './@types/node-glib-2.0.js'; -import Soup from './@types/node-soup-3.0.js'; -import Gio from './@types/node-gio-2.0.js'; - -const loop = GLib.MainLoop.new(null, false); - -gi.startLoop(); - -const gBytesToString = (data: GLib.Bytes) => { - return Buffer.from(data.getData() || []).toString() -} - -const session = new Soup.Session(); -const message = new Soup.Message({ - method: 'GET', - uri: GLib.Uri.parse('http://localhost:1080/hello?myname=node-gtk', GLib.UriFlags.NONE), -}); - -const readBytesAsyncCallback: Gio.AsyncReadyCallback = (inputStream, res) => { - let data; - - try { - data = (inputStream as Gio.InputStream).readBytesFinish(res); - } catch (e) { - console.error(e); - loop.quit(); - return; - } - - console.log(`body:\n${gBytesToString(data)}`); - - loop.quit(); -} - -const send_async_callback: Gio.AsyncReadyCallback = (self, res) => { - let inputStream; - - try { - inputStream = session.sendFinish(res); - } catch (e) { - console.error(e); - loop.quit(); - return; - } - - console.log(`status: ${message.statusCode} - ${message.reasonPhrase}`); - message.responseHeaders.foreach((name, value) => { - console.log(`${name}: ${value}`); - }); - - inputStream.readBytesAsync(message.responseHeaders.getContentLength(), 0, null, readBytesAsyncCallback); -} - -session.sendAsync(message, 0, null, send_async_callback); - -loop.run() diff --git a/examples/node-gtk/soup-3-http/http-server.ts b/examples/node-gtk/soup-3-http/http-server.ts deleted file mode 100644 index 4010143c7..000000000 --- a/examples/node-gtk/soup-3-http/http-server.ts +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later -// SPDX-FileCopyrightText: 2010 litl, LLC -// Copyright 2022 Pascal Garber - -// This is a simple example of a HTTP server in Gjs using libsoup 3 -// https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/http-server.js - -// TODO callbacks not working in node-gtk? - -import gi from './@types/node-gtk.js'; -import GLib from './@types/node-glib-2.0.js'; -import Soup from './@types/node-soup-3.0.js'; - -// GJS version of GLib.HashTable -// TODO fix in ts-for-gir -interface GjsHashTable { - [key: symbol | string | number]: string | number | boolean; -} - -gi.startLoop(); - -const loop = GLib.MainLoop.new(null, false); - -const handler: Soup.ServerCallback = (server, msg, path, query) => { - msg.setStatus(200, null); - - const body = Buffer.from(` - - - Greetings, visitor from ${msg.getRemoteHost()}
- What is your name? -
- -
- - - `); - - msg.setResponse('text/html; charset=utf-8', Soup.MemoryUse.COPY, [...body]) -} - -const helloHandler: Soup.ServerCallback = (server, msg, path, query) => { - if (!query) { - msg.setRedirect(302, '/'); - return; - } - - msg.setStatus(200, null); - - console.log("query", JSON.stringify(query)) - - const body = Buffer.from(` - - - Hello, ${(query as GjsHashTable).myname}! ☺
- Go back - - - `); - - msg.setResponse('text/html; charset=utf-8', Soup.MemoryUse.COPY, [...body]) -} - -function main() { - let server = new Soup.Server({}); - server.addHandler('/', handler); - server.addHandler('/hello', helloHandler); - server.listenLocal(1080, Soup.ServerListenOptions.IPV4_ONLY); - console.log("Visit http://localhost:1080") - loop.run(); -} - -main(); \ No newline at end of file diff --git a/examples/node-gtk/soup-3-http/package.json b/examples/node-gtk/soup-3-http/package.json deleted file mode 100644 index 26aa5e5fc..000000000 --- a/examples/node-gtk/soup-3-http/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "ts-for-gir-node-soup-3-http-example", - "version": "3.2.8", - "description": "Node-gtk example showing how to build a http server/client using Soap 3", - "main": "dist/http-server.js", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Soup-3.0 -e node", - "build:app": "yarn node esbuild.js", - "build": "yarn build:types && yarn build:app", - "clear:types": "rm -rf ./@types", - "clear:ts": "rm -rf ./dist", - "clear": "yarn clear:ts && yarn clear:types", - "start:server": "yarn node dist/http-server.js", - "start:client": "yarn node dist/http-client.js", - "start": "yarn build && yarn start:server", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit" - }, - "author": "Pascal Garber ", - "license": "MIT", - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" - }, - "dependencies": { - "node-gtk": "^0.12.0" - } -} diff --git a/examples/node-gtk/soup-3-http/tsconfig.json b/examples/node-gtk/soup-3-http/tsconfig.json deleted file mode 100644 index c3d8f28b3..000000000 --- a/examples/node-gtk/soup-3-http/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "types": ["node"], - "target": "ESNext", - "module": "Node16", - "strict": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "noImplicitAny": true, - "strictNullChecks": true, - "noImplicitThis": true, - "alwaysStrict": true, - "moduleResolution": "Node16" - }, - "files": [ - "http-client.ts", - "http-server.ts" - ] -} diff --git a/examples/node-gtk/soup-3-http/tsconfig.types.json b/examples/node-gtk/soup-3-http/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/soup-3-http/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/package.json b/package.json index 6fb099124..62b0de347 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ts-for-gir", - "version": "3.2.8", - "description": "Typescript .d.ts generator from GIR for gjs and node-gtk", + "version": "3.2.3", + "description": "Typescript .d.ts generator from GIR for gjs", "type": "module", "private": true, "engines": { @@ -21,29 +21,17 @@ "test": "yarn build:all && yarn test:girs:all && yarn validate:examples && yarn start:cli-examples:all", "test:girs:all": "yarn clear:types && yarn build:types:all && yarn validate:types:all", "test:girs:gjs": "yarn clear:types && yarn build:types:gjs && yarn validate:types:gjs", - "test:girs:node": "yarn clear:types && yarn build:types:node && yarn validate:types:node", "test:girs:gjs:vda1": "yarn clear:types && yarn build:types:gjs:vda1 && yarn validate:types:gjs", - "test:girs:node:vda1": "yarn clear:types && yarn build:types:node:vda1 && yarn validate:types:node", "test:girs:gjs:gtk2": "yarn clear:types && yarn build:types:gjs:gtk2 && yarn validate:types:gjs", - "test:girs:node:gtk2": "yarn clear:types && yarn build:types:node:gtk2 && yarn validate:types:node", "test:girs:gjs:gtk3": "yarn clear:types && yarn build:types:gjs:gtk3 && yarn validate:types:gjs", - "test:girs:node:gtk3": "yarn clear:types && yarn build:types:node:gtk3 && yarn validate:types:node", "test:girs:gjs:gtk4": "yarn clear:types && yarn build:types:gjs:gtk4 && yarn validate:types:gjs", - "test:girs:node:gtk4": "yarn clear:types && yarn build:types:node:gtk4 && yarn validate:types:node", "test:girs:gjs:gtk3+gtk4": "yarn clear:types && yarn build:types:gjs:gtk3+gtk4 && yarn validate:types:gjs", - "test:girs:node:gtk3+gtk4": "yarn clear:types && yarn build:types:node:gtk3+gtk4 && yarn validate:types:node", "test:girs:gjs:gio": "yarn clear:types && yarn build:types:gjs:gio && yarn validate:types:gjs", - "test:girs:node:gio": "yarn clear:types && yarn build:types:node:gio && yarn validate:types:node", "test:girs:gjs:vte4": "yarn clear:types && yarn build:types:gjs:vte4 && yarn validate:types:gjs", - "test:girs:node:vte4": "yarn clear:types && yarn build:types:node:vte4 && yarn validate:types:node", "test:girs:gjs:modemmanager1": "yarn clear:types && yarn build:types:gjs:modemmanager1 && yarn validate:types:gjs", - "test:girs:node:modemmanager1": "yarn clear:types && yarn build:types:node:modemmanager1 && yarn validate:types:node", "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:gjs:timezonemap1 && yarn validate:types:gjs", - "test:girs:node:timezonemap1": "yarn clear:types && yarn build:types:node:timezonemap1 && yarn validate:types:node", "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:gjs:rygelcore2 && yarn validate:types:gjs", - "test:girs:node:rygelcore2": "yarn clear:types && yarn build:types:node:rygelcore2 && yarn validate:types:node", "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gjs:gcalc && yarn validate:types:gjs", - "test:girs:node:gcalc": "yarn clear:types && yarn build:types:node:gcalc && yarn validate:types:node", "build": "yarn build:lib && yarn build:generators && yarn build:cli", "build:cli": "yarn workspace @ts-for-gir/cli run build", "build:lib": "yarn workspace @ts-for-gir/lib run build", @@ -53,9 +41,8 @@ "build:generator-html-doc": "yarn workspace @ts-for-gir/generator-html-doc run build", "build:examples": "yarn workspaces foreach -v --all --exclude '@ts-for-gir/*' --parallel run build", "build:all": "yarn build && yarn build:examples", - "start:cli-examples:all": "yarn start:cli-examples:gjs && yarn start:cli-examples:node", + "start:cli-examples:all": "yarn start:cli-examples:gjs", "start:cli-examples:gjs": "yarn workspace ts-for-gir-glib-2-spawn-command-example run start && yarn workspace ts-for-gir-gio-2-cat-promisify-packages run start", - "start:cli-examples:node": "yarn workspace ts-for-gir-node-glib-2-spawn-command-example run start && yarn workspace ts-for-gir-node-gtk-gio-2-cat-promisify-packages run start", "build:types:packages:all": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-all.rc.js' && yarn install", "build:types:packages:gtk4": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-gtk4.rc.js' && yarn install", "build:types:all": "yarn ts-for-gir generate --configName='.ts-for-gir.all.rc.js'", @@ -82,29 +69,15 @@ "build:types:gjs:timezonemap1": "yarn build:types:timezonemap1 --environments=gjs", "build:types:gjs:rygelcore2": "yarn build:types:rygelcore2 --environments=gjs", "build:types:gjs:gcalc": "yarn build:types:gcalc --environments=gjs", - "build:types:node": "yarn clear:types:node && yarn build:types:all --environments=node --noNamespace --moduleType=cjs", - "build:types:node:vda1": "yarn build:types:vda1 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:gtk2": "yarn build:types:gtk2 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:gtk3": "yarn build:types:gtk3 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:gtk4": "yarn build:types:gtk4 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:gtk3+gtk4": "yarn build:types:gtk3+gtk4 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:gio": "yarn build:types:gio --environments=node --noNamespace --moduleType=cjs", - "build:types:node:vte4": "yarn build:types:vte4 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:modemmanager1": "yarn build:types:modemmanager1 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:timezonemap1": "yarn build:types:timezonemap1 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:rygelcore2": "yarn build:types:rygelcore2 --environments=node --noNamespace --moduleType=cjs", - "build:types:node:gcalc": "yarn build:types:gcalc --environments=node --noNamespace --moduleType=cjs", "validate": "yarn workspaces foreach -v --all --parallel run validate", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app", - "validate:types:all": "yarn validate:types:gjs && yarn validate:types:node", + "validate:types:all": "yarn validate:types:gjs", "validate:types:gjs": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", - "validate:types:node": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.node.json", "clear": "yarn clear:build && yarn clear:types", "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", "clear:types:gjs": "rimraf ./@types", - "clear:types:node": "rimraf ./@types", "clear:examples": "yarn workspaces foreach -v --all --exclude @ts-for-gir/cli,@ts-for-gir/lib,@ts-for-gir/generator-base,@ts-for-gir/generator-typescript,@ts-for-gir/generator-html-doc --parallel run clear", "clear:all": "yarn build && yarn clear:examples", "watch": "concurrently 'yarn:watch:*'", @@ -128,7 +101,6 @@ "gjs", "typescript", "generate", - "node-gtk", "gir", "gobject-introspection", "gnome", diff --git a/packages/cli/package.json b/packages/cli/package.json index 8c60ecd2f..5ee13a3e2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -42,7 +42,6 @@ "gjs", "typescript", "generate", - "node-gtk", "gir", "gobject-introspection", "gnome", diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index bed56614b..db10c4f77 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -13,7 +13,7 @@ import type { ConfigFlags } from '@ts-for-gir/lib' const command = 'generate [modules..]' -const description = 'Generates .d.ts files from GIR for GJS or node-gtk' +const description = 'Generates .d.ts files from GIR for GJS' // eslint-disable-next-line @typescript-eslint/no-explicit-any const builder: BuilderCallback = (yargs: Argv) => { @@ -51,7 +51,7 @@ const handler = async (args: ConfigFlags) => { const examples: ReadonlyArray<[string, string?]> = [ [ `${Config.appName} generate`, - `Run '${Config.appName} generate' in your gjs or node-gtk project to generate typings for your project, pass the gir modules you need for your project`, + `Run '${Config.appName} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`, ], [`${Config.appName} generate Gtk*`, 'You can also use wild cards'], [`${Config.appName} generate '*'`, 'If you want to parse all of your locally installed gir modules run'], diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts index a1a8363a9..393213cf8 100644 --- a/packages/cli/src/config.ts +++ b/packages/cli/src/config.ts @@ -89,7 +89,7 @@ export class Config { alias: 'e', description: 'Javascript environment', array: true, - choices: ['gjs', 'node'], + choices: ['gjs'], default: Config.defaults.environments, normalize: true, }, diff --git a/packages/generator-typescript/src/template-processor.ts b/packages/generator-typescript/src/template-processor.ts index 9a5dad08a..c22adc08e 100644 --- a/packages/generator-typescript/src/template-processor.ts +++ b/packages/generator-typescript/src/template-processor.ts @@ -72,9 +72,7 @@ export class TemplateProcessor { if (environment === 'gjs' && !baseDir.endsWith('/gjs')) { return join(baseDir, 'gjs') } - if (environment === 'node' && !baseDir.endsWith('/node-gtk')) { - return join(baseDir, 'node-gtk') - } + return baseDir } diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index e80d0fdd9..9eabc6d6f 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -1358,7 +1358,7 @@ export class TypeDefinitionGenerator implements Generator { protected async exportModuleTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise { const template = 'module.d.ts' - let explicitTemplate = `${girModule.importName}.d.ts` + const explicitTemplate = `${girModule.importName}.d.ts` let target = `${girModule.importName}.d.ts` @@ -1370,10 +1370,6 @@ export class TypeDefinitionGenerator implements Generator { } } - // Remove `node-` prefix for node environment - if (this.config.environment === 'node' && explicitTemplate.startsWith('node-')) { - explicitTemplate = explicitTemplate.substring(5) - } const out: string[] = [] out.push(...this.addTSDocCommentLines([girModule.packageName])) @@ -1863,69 +1859,6 @@ export class TypeDefinitionGenerator implements Generator { } } - protected async exportNodeGtk( - dependencies: Dependency[], - girModules: GirModule[], - girModulesGrouped: GirModulesGrouped[], - ) { - if (!this.config.outdir) return - const packageName = 'node-gtk' - - const templateProcessor = new TemplateProcessor( - { girModules, girModulesGrouped }, - packageName, - dependencies, - this.config, - ) - - // TS - await templateProcessor.create('node-gtk.d.ts', this.config.outdir, 'node-gtk.d.ts') - - // JS - if (this.config.buildType === 'lib') { - await templateProcessor.create('node-gtk.js', this.config.outdir, 'node-gtk.js') - } - - // If you build an NPM package, we also build the node-gtk module for the other module type - if (this.config.package) { - this.setOverrideConfigForOtherModuleType() - // TS - await templateProcessor.create( - 'node-gtk.d.ts', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'node-gtk.d.cts' : 'node-gtk.d.mts', - undefined, - undefined, - undefined, - this.overrideConfig, - ) - // JS - if (this.config.buildType === 'lib') { - await templateProcessor.create( - 'node-gtk.js', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'node-gtk.cjs' : 'node-gtk.mjs', - undefined, - undefined, - undefined, - this.overrideConfig, - ) - } - this.resetOverrideConfig() - } - - // Import ambient types - await templateProcessor.create('ambient.d.ts', this.config.outdir, 'node-ambient.d.ts') - if (this.config.buildType === 'lib') { - await templateProcessor.create('ambient.js', this.config.outdir, 'node-ambient.js') - } - - // Package - if (this.config.package) { - await this.exportNPMPackage(templateProcessor, 'node-gtk') - } - } - public async start(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[] = []) { this.dependencyManager.addAll(girModules) @@ -1937,11 +1870,6 @@ export class TypeDefinitionGenerator implements Generator { await this.exportModule(girModule, girModules, girModulesGrouped) } - if (this.config.environment === 'node') { - // node-gtk internal stuff - await this.exportNodeGtk(this.dependencyManager.core(), girModules, girModulesGrouped) - } - if (this.config.environment === 'gjs') { // GJS internal stuff await this.exportGjs(this.dependencyManager.core(), girModules, girModulesGrouped) diff --git a/packages/generator-typescript/templates/node-gtk/README-NODE-GTK.md b/packages/generator-typescript/templates/node-gtk/README-NODE-GTK.md deleted file mode 100644 index 31b7d37e9..000000000 --- a/packages/generator-typescript/templates/node-gtk/README-NODE-GTK.md +++ /dev/null @@ -1,74 +0,0 @@ -<%# This template is used if the Option `package` is enabled %> -# <%- packageName %> - -![version](https://img.shields.io/npm/v/<%- npmScope %>/<%- importName %>) -![downloads/week](https://img.shields.io/npm/dw/<%- npmScope %>/<%- importName %>) - -<%- PACKAGE_DESC %> using [<%- APP_NAME %>](<%- APP_SOURCE %>) v<%- APP_VERSION %>. - -<%_ if (typeof pkgData !== 'undefined' && pkgData.description) { _%> -<%- pkgData.description %> -<%_ } else { _%> -[node-gtk](https://github.com/romgrk/node-gtk) is a [GObject Introspection](https://gi.readthedocs.io/en/latest/) import library for Node.js. Using node-gtk with the type definitions in this NPM package, you can build GTK applications in JavaScript or TypeScript with type checking, better autocompletion and inline documentations. -<%_ } _%> - -## Install - -To use this type definitions, install them with NPM: -```bash -npm install <%- npmScope %>/<%- importName %> -``` - -<%_ const pkg = dep.get(packageName) _%> -<%_ if(!pkg){ _%> - <%_ return `Package with package name "${packageName}" not found!` _%> -<%_ } _%> - -## Usage - -You can import this package into your project like this: -```ts -import <%- pkg.namespace %> from '<%- pkg.importPath %>'; -``` - -Or if you prefer CommonJS, you can also use this: -```ts -const <%- pkg.namespace %> = require('<%- pkg.importPath %>'); -``` - -### Ambient Modules - -You can import core [ambient module](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) types. -For this you need to include the `<%- npmScope %>/<%- importName %>` or `<%- npmScope %>/<%- importName %>/ambient` in your `tsconfig` or entry point Typescript file: - -`index.ts`: -```ts -import '<%- npmScope %>/<%- importName %>' -``` - -`tsconfig.json`: -```json -{ - "compilerOptions": { - ... - }, - "include": ["<%- npmScope %>/<%- importName %>"], - ... -} -``` - -Now you can import `node-gtk` with Typescript support: -```ts -const gi = require('node-gtk'); -gi.startLoop(); -``` - -If you want to have types for [GObject Introspection](https://gi.readthedocs.io/en/latest/) modules, you have to add them to your dependencies and import them as well, see the description of these modules, e.g. [node-gtk-4.0](https://www.npmjs.com/package/@girs/node-gtk-4.0), [node-gio-2.0](https://www.npmjs.com/package/@girs/node-gio-2.0), [node-adw-1](https://www.npmjs.com/package/@girs/node-adw-1) and [much more](https://github.com/gjsify/types). - -### Bundle - -Depending on your project configuration, it is recommended to use a bundler like [esbuild](https://esbuild.github.io/). You can find examples using different bundlers [here](https://github.com/gjsify/ts-for-gir/tree/main/examples). - -## Other packages - -All existing pre-generated packages can be found on [gjsify/types](https://github.com/gjsify/types). \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/ambient.d.ts b/packages/generator-typescript/templates/node-gtk/ambient.d.ts deleted file mode 100644 index 47ab433b1..000000000 --- a/packages/generator-typescript/templates/node-gtk/ambient.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules -// https://stackoverflow.com/questions/45099605/ambient-declaration-with-an-imported-type-in-typescript -declare module 'node-gtk' { - <%_ const pkg = dep.getNodeGtk() _%> - <%_ if(package){ _%> - <% if(moduleType === 'esm'){ %> - import gi from '<%= pkg.importPath %>'; - <% } else { %> - import * as gi from '<%= pkg.importPath %>'; - <% } %> - <%_ } else { _%> - <% if(moduleType === 'esm'){ %> - const gi: typeof import('<%= pkg.importPath %>').default; - <% } else { %> - const gi: typeof import('<%= pkg.importPath %>'); - <% } %> - <%_ } _%> - export = gi; -} diff --git a/packages/generator-typescript/templates/node-gtk/gobject-2.0.d.ts b/packages/generator-typescript/templates/node-gtk/gobject-2.0.d.ts deleted file mode 100644 index dcd25e8f8..000000000 --- a/packages/generator-typescript/templates/node-gtk/gobject-2.0.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -// See https://github.com/romgrk/node-gtk/blob/master/lib/overrides/GObject.js - -export type GType = { - __type__(arg: never): T - name: string -}; - -// TODO: What about the generated class Closure -export type TClosure = (...args: P[]) => R; - -export let TYPE_INVALID : 0n -export let TYPE_NONE : GType; -export let TYPE_INTERFACE : GType; -export let TYPE_CHAR : GType; -export let TYPE_UCHAR : GType; -export let TYPE_BOOLEAN : GType; -export let TYPE_INT : GType; -export let TYPE_UINT : GType; -export let TYPE_LONG : GType; -export let TYPE_ULONG : GType; -export let TYPE_INT64 : GType; -export let TYPE_UINT64 : GType; -export let TYPE_ENUM : GType; -export let TYPE_FLAGS : GType; -export let TYPE_FLOAT : GType; -export let TYPE_DOUBLE : GType; -export let TYPE_STRING : GType; -export let TYPE_POINTER : GType; -export let TYPE_BOXED : GType; -export let TYPE_PARAM : GType; -export let TYPE_OBJECT : GType; -export let TYPE_GTYPE : GType; -export let TYPE_VARIANT : GType; -export let TYPE_UNICHAR : GType; - -export function typeFromName(name: 'void'): typeof TYPE_INVALID -export function typeFromName(name: 'GInterface'): typeof TYPE_INTERFACE -export function typeFromName(name: 'gchar'): typeof TYPE_CHAR -export function typeFromName(name: 'guchar'): typeof TYPE_UCHAR -export function typeFromName(name: 'gboolean'): typeof TYPE_BOOLEAN -export function typeFromName(name: 'gint'): typeof TYPE_INT -export function typeFromName(name: 'guint'): typeof TYPE_UINT -export function typeFromName(name: 'glong'): typeof TYPE_LONG -export function typeFromName(name: 'gulong'): typeof TYPE_ULONG -export function typeFromName(name: 'gint64'): typeof TYPE_INT64 -export function typeFromName(name: 'guint64'): typeof TYPE_UINT64 -export function typeFromName(name: 'GEnum'): typeof TYPE_ENUM -export function typeFromName(name: 'GFlags'): typeof TYPE_FLAGS -export function typeFromName(name: 'gfloat'): typeof TYPE_FLOAT -export function typeFromName(name: 'gdouble'): typeof TYPE_DOUBLE -export function typeFromName(name: 'gchararray'): typeof TYPE_STRING -export function typeFromName(name: 'gpointer'): typeof TYPE_POINTER -export function typeFromName(name: 'GBoxed'): typeof TYPE_BOXED -export function typeFromName(name: 'GParam'): typeof TYPE_PARAM -export function typeFromName(name: 'GObject'): typeof TYPE_OBJECT -export function typeFromName(name: 'GType'): typeof TYPE_GTYPE -export function typeFromName(name: 'GVariant'): typeof TYPE_VARIANT diff --git a/packages/generator-typescript/templates/node-gtk/module-import.d.ts b/packages/generator-typescript/templates/node-gtk/module-import.d.ts deleted file mode 100644 index 994ca7c59..000000000 --- a/packages/generator-typescript/templates/node-gtk/module-import.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -<%# - This EJS template is used to extend the global NodeGtkGi interface with the GIR module, for `gi.require(namespace) node-gtk GIR types` -%> -<%_ const pkg = dep.get(girModule.namespace, girModule.version) _%> -<%_ if(package){ _%> - <%_ if(noNamespace){ _%> -import * as <%= girModule.importNamespace %> from '<%= pkg.importPath %>'; - <%_ } else { _%> -import <%= girModule.importNamespace %> from '<%= pkg.importPath %>'; - <%_ } _%> -<%_ } else { _%> - <%_ if(noNamespace){ _%> -type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>'); - <%_ } else { _%> -type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>').default; - <%_ } _%> -<%_ } _%> - -declare global { - interface NodeGtkGi { - <%_ if(package){ _%> - require(ns: '<%= girModule.namespace %>', ver?: '<%= girModule.version %>'): typeof <%= girModule.importNamespace %>; - <%_ } else { _%> - require(ns: '<%= girModule.namespace %>', ver?: '<%= girModule.version %>'): <%= girModule.importNamespace %>; - <%_ } _%> - } -} - -export default NodeGtkGi; \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/module.append.d.ts b/packages/generator-typescript/templates/node-gtk/module.append.d.ts deleted file mode 100644 index fb1bc88f3..000000000 --- a/packages/generator-typescript/templates/node-gtk/module.append.d.ts +++ /dev/null @@ -1 +0,0 @@ -// END \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/module.d.ts b/packages/generator-typescript/templates/node-gtk/module.d.ts deleted file mode 100644 index 032684623..000000000 --- a/packages/generator-typescript/templates/node-gtk/module.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -<%# This template is used for the generated .d.ts file of each GIR module like Gtk-4.0, GObject-2.0, ... %> -/* - * Type Definitions for node-gtk (https://github.com/romgrk/node-gtk) - * - * These type definitions are automatically generated, do not edit them by hand. - * If you found a bug fix it in <%= APP_NAME %> itself or create a bug report on <%= APP_SOURCE %> - */ - -import './<%= importName %>-import.d.ts'; - \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/module.js b/packages/generator-typescript/templates/node-gtk/module.js deleted file mode 100644 index 049ce9463..000000000 --- a/packages/generator-typescript/templates/node-gtk/module.js +++ /dev/null @@ -1,18 +0,0 @@ -<% if(moduleType === 'esm'){ %> - import gi from 'node-gtk'; - const { require: giRequire } = gi; - const <%= name %> = giRequire('<%= name %>', '<%= version %>'); - export { <%= name %> }; - export default <%= name %>; -<% } else { %> - const { require: giRequire } = require('node-gtk'); - const <%= name %> = giRequire('<%= name %>', '<%= version %>'); - <% if(!noNamespace){ %> - module.exports = { <%= name %> }; - exports.default = <%= name %>; - <% } else { %> - module.exports = <%= name %>; - <% } %> -<% } %> - - diff --git a/packages/generator-typescript/templates/node-gtk/node-gtk.d.ts b/packages/generator-typescript/templates/node-gtk/node-gtk.d.ts deleted file mode 100644 index 0b5e5d7d2..000000000 --- a/packages/generator-typescript/templates/node-gtk/node-gtk.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* eslint-disable @typescript-eslint/triple-slash-reference */ - -/* - * Type Definitions for node-gtk (https://github.com/romgrk/node-gtk) - * - * These type definitions are automatically generated, do not edit them by hand. - * If you found a bug fix it in <%= APP_NAME %> itself or create a bug report on <%= APP_SOURCE %> - */ -import './node-ambient.d.ts'; - -declare global { - interface NodeGtkGi { - startLoop(): void; - registerClass(object: any): void - require(ns: string, ver?: string): any; - } -} - -declare const gi: NodeGtkGi; - -<% if(moduleType === 'esm'){ %> - export default gi; -<% } else { %> - export = gi; -<% } %> \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/node-gtk.js b/packages/generator-typescript/templates/node-gtk/node-gtk.js deleted file mode 100644 index 7645f7bc2..000000000 --- a/packages/generator-typescript/templates/node-gtk/node-gtk.js +++ /dev/null @@ -1,7 +0,0 @@ -<% if(moduleType === 'esm'){ %> - import * as gi from 'node-gtk'; - export default gi; -<% } else { %> - const gi = require('node-gtk'); - module.exports = gi; -<% } %> \ No newline at end of file diff --git a/packages/generator-typescript/templates/package.json b/packages/generator-typescript/templates/package.json index 35ae6a95b..9155cfa07 100644 --- a/packages/generator-typescript/templates/package.json +++ b/packages/generator-typescript/templates/package.json @@ -4,9 +4,6 @@ let entryPointName = importName if (packageName === 'Gjs') { entryPointName = 'gjs' } -if (packageName === 'node-gtk') { - entryPointName = 'node-gtk' -} let depVersion = packageYarn ? 'workspace:^' : APP_VERSION _%> { @@ -99,19 +96,8 @@ _%> }, <%_ } _%> <%_ if (entryPointName === 'gjs') { _%> - "./ambient": { - "types": "./ambient.d.ts", - "default": "./ambient.js" - }, - "./dom": { - "types": "./dom.d.ts", - "default": "./dom.js" - }, - <%_ } else if (entryPointName === 'node-gtk') { _%> - "./ambient": { - "types": "./node-ambient.d.ts", - "default": "./node-ambient.js" - }, + "./ambient": "./ambient.d.ts", + "./dom": "./dom.d.ts", <%_ } else {_%> "./ambient": { "types": "./<%- entryPointName %>-ambient.d.ts", @@ -155,10 +141,8 @@ _%> <%_ } _%> }, "dependencies": { - <%_ if (packageName !== 'Gjs' && packageName !== 'node-gtk') { _%> - <%_ if (environment === 'node') { _%> - "<%- npmScope %>/node-gtk": "<%- depVersion %>"<%_ if(deps.length > 0 ) { _%>,<%_ } _%> - <%_ } else { _%> + <%_ if (packageName !== 'Gjs') { _%> + <%_ if (environment === 'gjs') { _%> "<%- npmScope %>/gjs": "<%- depVersion %>"<%_ if(deps.length > 0 ) { _%>,<%_ } _%> <%_ } _%> <%_ } _%> @@ -171,11 +155,6 @@ _%> "<%- deps[i].importPath %>": "<%- depVersion %>"<%_ if(i < deps.length - 1) { _%>,<%_ } _%> <% } %> }, - <%_ if (environment === 'node') { _%> - "peerDependencies": { - "node-gtk": "*" - }, - <%_ } _%> "devDependencies": { "typescript": "*" }, diff --git a/packages/generator-typescript/templates/tsconfig.json b/packages/generator-typescript/templates/tsconfig.json index e5abfbf1a..9ca93fc4a 100644 --- a/packages/generator-typescript/templates/tsconfig.json +++ b/packages/generator-typescript/templates/tsconfig.json @@ -5,9 +5,6 @@ if (packageName === 'Gjs') { entryPointName = 'gjs' includes.push(`./dom.d.ts`) } -if (packageName === 'node-gtk') { - entryPointName = 'node-gtk' -} includes.push(`./${entryPointName}.d.ts`) _%> { diff --git a/packages/generator-typescript/templates/typedoc.json b/packages/generator-typescript/templates/typedoc.json index 9d2ba2305..dc446d83d 100644 --- a/packages/generator-typescript/templates/typedoc.json +++ b/packages/generator-typescript/templates/typedoc.json @@ -3,9 +3,6 @@ let entryPointName = importName if (packageName === 'Gjs') { entryPointName = 'gjs' } -if (packageName === 'node-gtk') { - entryPointName = 'node-gtk' -} let entryPoints = [`./${entryPointName}.d.ts`] @@ -15,8 +12,6 @@ if (packageName === 'Gjs') { // entryPoints.push(`./gettext.d.ts`) // entryPoints.push(`./system.d.ts`) // entryPoints.push('./dom.d.ts') -} else if (packageName === 'node-gtk') { - // entryPoints.push('./node-ambient.d.ts') } else { // entryPoints.push(`./${entryPointName}-ambient.d.ts`) // entryPoints.push(`./${entryPointName}-import.d.ts`) diff --git a/packages/lib/package.json b/packages/lib/package.json index 803a67470..4d4cfb144 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,7 +1,7 @@ { "name": "@ts-for-gir/lib", - "version": "3.2.8", - "description": "Typescript .d.ts generator from GIR for gjs and node-gtk", + "version": "3.2.3", + "description": "Typescript .d.ts generator from GIR for gjs", "module": "lib/index.js", "main": "lib/index.js", "type": "module", @@ -34,7 +34,6 @@ "gjs", "typescript", "generate", - "node-gtk", "gir", "gobject-introspection", "gnome", diff --git a/packages/lib/src/constants.ts b/packages/lib/src/constants.ts index 02490b81b..78e9160c3 100644 --- a/packages/lib/src/constants.ts +++ b/packages/lib/src/constants.ts @@ -31,14 +31,14 @@ export const APP_SOURCE = 'https://github.com/gjsify/ts-for-gir' export const APP_VERSION = PACKAGE.version export const PACKAGE_DESC = (packageName: string, environment: Environment, libraryVersion?: LibraryVersion) => { - const envStr = environment === 'node' ? 'Node.js' : 'GJS' + const envStr = environment === 'gjs' ? 'GJS' : 'unknown environment' if (libraryVersion) { return `${envStr} TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}` } return `${envStr} TypeScript type definitions for ${packageName}` } export const PACKAGE_KEYWORDS = (packageName: string, environment: Environment) => { - const envKeywords = environment === 'node' ? '"node", "node-gtk"' : '"GJS"' + const envKeywords = environment === 'gjs' ? '"GJS"' : '' return `"Gir", "TypeScript", "types", "GObject-Introspection", ${envKeywords}, "${packageName}"` } @@ -46,10 +46,6 @@ export const GENERIC_NAMES: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', export const SIGNAL_METHOD_NAMES_GENERAL: string[] = ['connect', 'emit', 'disconnect'] export const SIGNAL_METHOD_NAMES_GJS: string[] = ['connect_after', 'emit'] -export const SIGNAL_METHOD_NAMES_NODE: string[] = ['after', 'on', 'once', 'off'] export const SIGNAL_METHOD_NAMES = (env: Environment) => { - if (env === 'node') { - return [...SIGNAL_METHOD_NAMES_GENERAL, SIGNAL_METHOD_NAMES_NODE] - } - return [...SIGNAL_METHOD_NAMES_GENERAL, SIGNAL_METHOD_NAMES_GJS] + return [...SIGNAL_METHOD_NAMES_GENERAL, ...(env === 'gjs' ? SIGNAL_METHOD_NAMES_GJS : [])] } diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index 12f21927f..94b382f5e 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -98,8 +98,6 @@ export class DependencyManager { // Special case for Gjs if (namespaceOrPackageName === 'Gjs') { return this.getGjs() - } else if (namespaceOrPackageName === 'node-gtk') { - return this.getNodeGtk() } const args = this.parseArgs(namespaceOrPackageName, version) @@ -207,8 +205,6 @@ export class DependencyManager { // Special case for Gjs if (namespace === 'Gjs') { return this.getGjs() - } else if (namespace === 'node-gtk') { - return this.getNodeGtk() } const packageNames = this.getAllPackageNames() @@ -252,8 +248,4 @@ export class DependencyManager { getGjs(): Dependency { return this.getPseudoPackage('Gjs') } - - getNodeGtk(): Dependency { - return this.getPseudoPackage('node-gtk') - } } diff --git a/packages/lib/src/gir-factory.ts b/packages/lib/src/gir-factory.ts index 88025b0aa..7cc546863 100644 --- a/packages/lib/src/gir-factory.ts +++ b/packages/lib/src/gir-factory.ts @@ -407,50 +407,6 @@ export class GirFactory { parentClass, ) tsMethods.push(connectAfterTsFn) - } else if (environment === 'node') { - const afterInParam: InjectionParameter = { - name: 'after', - type: [ - this.newTsType({ - type: 'boolean', - optional: true, - }), - ], - doc: this.newTsDoc(), - } - - const nodeEventEmitterReturnType = this.newTsType({ - type: 'NodeJS.EventEmitter', - }) - - const onTsFn = this.newTsFunction( - { - name: 'on', - inParams: [sigNameInParam, callbackInParam, afterInParam], - returnTypes: [nodeEventEmitterReturnType], - girTypeName, - }, - parentClass, - ) - const onceTsFn = this.newTsFunction( - { - name: 'once', - inParams: [sigNameInParam, callbackInParam, afterInParam], - returnTypes: [nodeEventEmitterReturnType], - girTypeName, - }, - parentClass, - ) - const offTsFn = this.newTsFunction( - { - name: 'off', - inParams: [sigNameInParam, callbackInParam], - returnTypes: [nodeEventEmitterReturnType], - girTypeName, - }, - parentClass, - ) - tsMethods.push(onTsFn, onceTsFn, offTsFn) } const emitTsFn = this.newTsFunction( diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index bce66d404..13d05688d 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -1504,10 +1504,6 @@ export class GirModule { const { returnTypes, outArrayLengthIndex, retTypeIsVoid } = this.getReturnType(girSignalFunc, girClass._tsData) - if (this.config.environment === 'node') { - returnTypes[0].type === 'void' - } - const tsCallback: TsCallback = { name, // TODO: 'callback'? returnTypes, @@ -1614,8 +1610,6 @@ export class GirModule { const objParam = `$obj: ${girClass._tsData.name}` // TODO: create arrowType object instead of a pure string type, see Pango-1.0.Pango.FontMapClass.load_font for an example callbackType = `((${objParam}, pspec: ${namespacePrefix}ParamSpec) => void)` - } else if (this.config.environment === 'node') { - callbackType = `(...args: any[]) => void` } tsMethods.push( ...this.girFactory.newTsSignalMethods( @@ -2010,14 +2004,6 @@ export class GirModule { girTypeName: 'property', }) girProperties.push(staticGTypeProp) - } else if (this.config.environment === 'node') { - const staticGTypeProp = this.girFactory.newGirProperty({ - isStatic: false, - name: '__gtype__', - type: [{ type: 'number' }], - girTypeName: 'property', - }) - girProperties.push(staticGTypeProp) } } diff --git a/packages/lib/src/injection/callbacks/index.ts b/packages/lib/src/injection/callbacks/index.ts index e7921ea6b..fd22c6a75 100644 --- a/packages/lib/src/injection/callbacks/index.ts +++ b/packages/lib/src/injection/callbacks/index.ts @@ -1,6 +1,5 @@ import type { InjectionCallback } from '../../types/index.js' export { callbacksGjs } from './gjs/index.js' -export { callbacksNode } from './node-gtk/index.js' export const callbacksAll: InjectionCallback[] = [] diff --git a/packages/lib/src/injection/callbacks/node-gtk/index.ts b/packages/lib/src/injection/callbacks/node-gtk/index.ts deleted file mode 100644 index 30c3e6c64..000000000 --- a/packages/lib/src/injection/callbacks/node-gtk/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { InjectionCallback } from '../../../types/index.js' - -export const callbacksNode: InjectionCallback[] = [] diff --git a/packages/lib/src/injection/classes/index.ts b/packages/lib/src/injection/classes/index.ts index e44a94ef9..4a8836354 100644 --- a/packages/lib/src/injection/classes/index.ts +++ b/packages/lib/src/injection/classes/index.ts @@ -3,5 +3,4 @@ import type { InjectionClass } from '../../types/index.js' import { classesGLib20All } from './glib-2.0.js' export { classesGjs } from './gjs/index.js' -export { classesNode } from './node-gtk/index.js' export const classesAll: InjectionClass[] = [...classesGLib20All] diff --git a/packages/lib/src/injection/classes/node-gtk/gdk-4.0.ts b/packages/lib/src/injection/classes/node-gtk/gdk-4.0.ts deleted file mode 100644 index becedb80d..000000000 --- a/packages/lib/src/injection/classes/node-gtk/gdk-4.0.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGdk40Node: InjectionClass[] = [ - // See https://github.com/romgrk/node-gtk/blob/master/lib/overrides/Gdk-4.0.js - { - versions: ['4.0'], - qualifiedName: 'Gdk.RGBA', - constructors: [ - { - girTypeName: 'constructor', - isStatic: true, - name: 'create', - returnTypes: [{ type: 'Gdk.RGBA' }], - inParams: [ - { - name: 'value', - type: [{ type: 'string' }], - }, - ], - doc: { - text: 'Creates a new color from the given string. Passes value to `GdkRGBA.parse()`', - tags: [ - { - paramName: '', - tagName: 'param', - text: 'value', - }, - ], - }, - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/gio-2.0.ts b/packages/lib/src/injection/classes/node-gtk/gio-2.0.ts deleted file mode 100644 index cd0c07c01..000000000 --- a/packages/lib/src/injection/classes/node-gtk/gio-2.0.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGio20Node: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'Gio.ListStore', - generics: [ - { - name: 'A', - extends: 'GObject.Object', - value: 'GObject.Object', - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/glib-2.0.ts b/packages/lib/src/injection/classes/node-gtk/glib-2.0.ts deleted file mode 100644 index eaa84e712..000000000 --- a/packages/lib/src/injection/classes/node-gtk/glib-2.0.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGLib20Node: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'GLib.MainLoop', - methods: [ - { - girTypeName: 'method', - name: 'run', - returnTypes: [{ type: 'void' }], - }, - { - girTypeName: 'method', - name: 'quit', - returnTypes: [{ type: 'void' }], - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/gobject-2.0.ts b/packages/lib/src/injection/classes/node-gtk/gobject-2.0.ts deleted file mode 100644 index 1b262d705..000000000 --- a/packages/lib/src/injection/classes/node-gtk/gobject-2.0.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGObject20Node: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'GObject.Object', - methods: [ - { - girTypeName: 'method', - name: 'setProperty', - isVirtual: true, - generics: [ - { - name: 'T', - value: 'any', - }, - ], - returnTypes: [{ type: 'void' }], - inParams: [ - { - name: 'propertyName', - type: [{ type: 'string' }], - }, - { - name: 'value', - type: [{ type: 'T' }], - }, - ], - }, - { - girTypeName: 'method', - name: 'getProperty', - isVirtual: true, - generics: [ - { - name: 'T', - value: 'unknown', - }, - ], - returnTypes: [{ type: 'T' }], - inParams: [ - { - name: 'propertyName', - type: [{ type: 'string' }], - }, - ], - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'GObject.Value', - methods: [ - { - girTypeName: 'method', - name: 'getBoxed', - generics: [ - { - name: 'T', - value: 'unknown', - }, - ], - returnTypes: [{ type: 'T' }], - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/graphene-1.0.ts b/packages/lib/src/injection/classes/node-gtk/graphene-1.0.ts deleted file mode 100644 index 34b245971..000000000 --- a/packages/lib/src/injection/classes/node-gtk/graphene-1.0.ts +++ /dev/null @@ -1,134 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGraphene10Node: InjectionClass[] = [ - // See https://github.com/romgrk/node-gtk/blob/master/lib/overrides/Graphene-1.0.js - { - versions: ['1.0'], - qualifiedName: 'Graphene.Rect', - constructors: [ - { - girTypeName: 'constructor', - isStatic: true, - name: 'create', - returnTypes: [{ type: 'Graphene.Rect' }], - inParams: [ - { - name: 'x', - type: [{ type: 'number' }], - }, - { - name: 'y', - type: [{ type: 'number' }], - }, - { - name: 'width', - type: [{ type: 'number' }], - }, - { - name: 'height', - type: [{ type: 'number' }], - }, - ], - doc: { - text: 'Creates a new Rect with the given values', - tags: [ - { - paramName: '', - tagName: 'param', - text: 'x', - }, - { - paramName: '', - tagName: 'param', - text: 'y', - }, - { - paramName: '', - tagName: 'param', - text: 'width', - }, - { - paramName: '', - tagName: 'param', - text: 'height', - }, - ], - }, - }, - ], - }, - { - versions: ['1.0'], - qualifiedName: 'Graphene.Point', - constructors: [ - { - girTypeName: 'constructor', - isStatic: true, - name: 'create', - returnTypes: [{ type: 'Graphene.Point' }], - inParams: [ - { - name: 'x', - type: [{ type: 'number' }], - }, - { - name: 'y', - type: [{ type: 'number' }], - }, - ], - doc: { - text: 'Creates a new Point with the given values', - tags: [ - { - paramName: '', - tagName: 'param', - text: 'x', - }, - { - paramName: '', - tagName: 'param', - text: 'y', - }, - ], - }, - }, - ], - }, - { - versions: ['1.0'], - qualifiedName: 'Graphene.Size', - constructors: [ - { - girTypeName: 'constructor', - isStatic: true, - name: 'create', - returnTypes: [{ type: 'Graphene.Size' }], - inParams: [ - { - name: 'width', - type: [{ type: 'number' }], - }, - { - name: 'height', - type: [{ type: 'number' }], - }, - ], - doc: { - text: 'Creates a new Size with the given values', - tags: [ - { - paramName: '', - tagName: 'param', - text: 'width', - }, - { - paramName: '', - tagName: 'param', - text: 'height', - }, - ], - }, - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/gtk-3.0.ts b/packages/lib/src/injection/classes/node-gtk/gtk-3.0.ts deleted file mode 100644 index 7042e424d..000000000 --- a/packages/lib/src/injection/classes/node-gtk/gtk-3.0.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGtk30Node: InjectionClass[] = [ - { - versions: ['3.0'], - qualifiedName: 'Gtk.Widget', - methods: [ - { - girTypeName: 'method', - name: 'getSizeRequest', - returnTypes: [{ type: '{ width: number; height: number; }' }], - }, - ], - }, - { - versions: ['3.0'], - qualifiedName: 'Gtk.Builder', - methods: [ - { - girTypeName: 'method', - name: 'connectSignals', - returnTypes: [{ type: 'void' }], - inParams: [ - { - name: 'handlers', - type: [{ type: '{ [handler: string]: (...args: any[]) => void; }' }], - }, - ], - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/gtk-4.0.ts b/packages/lib/src/injection/classes/node-gtk/gtk-4.0.ts deleted file mode 100644 index 77e6f6f06..000000000 --- a/packages/lib/src/injection/classes/node-gtk/gtk-4.0.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGtk40Node: InjectionClass[] = [ - { - versions: ['4.0'], - qualifiedName: 'Gtk.Widget', - methods: [ - { - girTypeName: 'method', - name: 'addCssClass', - inParams: [ - { - name: 'classNames', - type: [{ type: 'string', isArray: true }], - }, - ], - returnTypes: [{ type: 'void' }], - }, - { - girTypeName: 'method', - name: 'removeCssClass', - inParams: [ - { - name: 'classNames', - type: [{ type: 'string', isArray: true }], - }, - ], - returnTypes: [{ type: 'void' }], - }, - ], - }, - { - versions: ['4.0'], - qualifiedName: 'Gtk.ScrolledWindow', - methods: [ - { - girTypeName: 'method', - name: 'scrollTo', - returnTypes: [{ type: 'number' }], - inParams: [ - { - name: 'value', - type: [{ type: 'number' }], - }, - { - name: 'vertical', - type: [{ type: 'boolean', optional: true }], - }, - ], - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/node-gtk/index.ts b/packages/lib/src/injection/classes/node-gtk/index.ts deleted file mode 100644 index 3cc35bba0..000000000 --- a/packages/lib/src/injection/classes/node-gtk/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -import { classesGdk40Node } from './gdk-4.0.js' -import { classesGio20Node } from './gio-2.0.js' -import { classesGLib20Node } from './glib-2.0.js' -import { classesGObject20Node } from './gobject-2.0.js' -import { classesGraphene10Node } from './graphene-1.0.js' -import { classesGtk30Node } from './gtk-3.0.js' -import { classesGtk40Node } from './gtk-4.0.js' -import { classesPango10Node } from './pango-1.0.js' - -export const classesNode: InjectionClass[] = [ - ...classesGdk40Node, - ...classesGio20Node, - ...classesGLib20Node, - ...classesGObject20Node, - ...classesGraphene10Node, - ...classesGtk30Node, - ...classesGtk40Node, - ...classesPango10Node, -] diff --git a/packages/lib/src/injection/classes/node-gtk/pango-1.0.ts b/packages/lib/src/injection/classes/node-gtk/pango-1.0.ts deleted file mode 100644 index 28ff2bc89..000000000 --- a/packages/lib/src/injection/classes/node-gtk/pango-1.0.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesPango10Node: InjectionClass[] = [ - { - versions: ['1.0'], - qualifiedName: 'Pango.Layout', - methods: [ - { - girTypeName: 'method', - name: 'setMarkup', - inParams: [ - { - name: 'markup', - type: [{ type: 'string' }], - }, - ], - returnTypes: [{ type: 'void' }], - }, - { - girTypeName: 'method', - name: 'setText', - inParams: [ - { - name: 'text', - type: [{ type: 'string' }], - }, - ], - returnTypes: [{ type: 'void' }], - }, - ], - }, -] diff --git a/packages/lib/src/injection/injector.ts b/packages/lib/src/injection/injector.ts index fceffc64d..2c44b840a 100644 --- a/packages/lib/src/injection/injector.ts +++ b/packages/lib/src/injection/injector.ts @@ -9,7 +9,7 @@ import type { } from '../types/index.js' import { Logger } from '../logger.js' -import { classesAll, classesGjs, classesNode, callbacksGjs, callbacksNode, callbacksAll } from './index.js' +import { classesAll, classesGjs, callbacksGjs, callbacksAll } from './index.js' import { GirFactory } from '../gir-factory.js' /** @@ -29,7 +29,7 @@ export class Injector { return } - const classes = this.environment === 'gjs' ? [...classesAll, ...classesGjs] : [...classesAll, ...classesNode] + const classes = this.environment === 'gjs' ? [...classesAll, ...classesGjs] : [...classesAll] const toClass = classes.find((cls) => { return ( @@ -84,8 +84,7 @@ export class Injector { /** Inject additional generics to existing callback interfaces */ toCallback(girCallback: GirCallbackElement) { - const callbacks = - this.environment === 'gjs' ? [...callbacksAll, ...callbacksGjs] : [...callbacksAll, ...callbacksNode] + const callbacks = this.environment === 'gjs' ? [...callbacksAll, ...callbacksGjs] : [...callbacksAll] if (!girCallback._module || !girCallback._tsData) { return girCallback @@ -131,8 +130,7 @@ export class Injector { toParameterType(girParam: GirCallableParamElement) { const tsTypes = girParam._tsData?.type - const callbacks = - this.environment === 'gjs' ? [...callbacksAll, ...callbacksGjs] : [...callbacksAll, ...callbacksNode] + const callbacks = this.environment === 'gjs' ? [...callbacksAll, ...callbacksGjs] : [...callbacksAll] if (!girParam._module || !girParam._tsData) { return girParam diff --git a/packages/lib/src/transformation.ts b/packages/lib/src/transformation.ts index b7e5706a7..e3d39d2cc 100644 --- a/packages/lib/src/transformation.ts +++ b/packages/lib/src/transformation.ts @@ -1,6 +1,6 @@ /** - * This is where transformations take place for gjs and node-gtk. - * For example a function names should be transformed to lowerCamelCase for node-gtk but should keep their original name for gjs + * This is where transformations take place for gjs. + * For example function names should keep their original name for gjs */ import { @@ -255,46 +255,30 @@ export const RESERVED_NAMESPACE_NAMES = {} export class Transformation { /** * Rules for the name conventions - * For node-gtk naming conventions see https://github.com/romgrk/node-gtk#naming-conventions * For gjs see https://gjs-docs.gnome.org/ and https://wiki.gnome.org/Attic/Gjs */ private transformations: Transformations = { functionName: { - node: { - transformation: 'lowerCamelCase', - }, gjs: { transformation: 'original', }, }, enumName: { - node: { - transformation: 'original', - }, gjs: { transformation: 'original', }, }, enumMember: { - node: { - transformation: 'upperCase', - }, gjs: { transformation: 'upperCase', }, }, signalName: { - node: { - transformation: 'original', - }, gjs: { transformation: 'original', }, }, propertyName: { - node: { - transformation: 'lowerCamelCase', - }, gjs: { transformation: 'lowerCamelCase', }, @@ -308,49 +292,31 @@ export class Transformation { }, }, parameterName: { - node: { - transformation: 'lowerCamelCase', - }, gjs: { transformation: 'underscores', }, }, fieldName: { - node: { - transformation: 'lowerCamelCase', - }, gjs: { transformation: 'underscores', }, }, constantName: { - node: { - transformation: 'original', - }, gjs: { transformation: 'original', }, }, importNamespaceName: { - node: { - transformation: 'upperCamelCase', - }, gjs: { transformation: 'upperCamelCase', }, }, signalInterfaceName: { - node: { - transformation: 'upperCamelCase', - }, gjs: { transformation: 'upperCamelCase', }, }, importName: { - node: { - transformation: 'lowerCase', - }, gjs: { transformation: 'lowerCase', }, @@ -635,10 +601,8 @@ export class Transformation { } public transformImportName(packageName: string): string { - let importName = this.transform('importName', packageName) - if (this.config.environment === 'node' && !importName.startsWith('node-')) { - importName = 'node-' + importName - } + const importName = this.transform('importName', packageName) + return importName } } diff --git a/packages/lib/src/types/environment.ts b/packages/lib/src/types/environment.ts index f0780de45..034823203 100644 --- a/packages/lib/src/types/environment.ts +++ b/packages/lib/src/types/environment.ts @@ -1 +1 @@ -export type Environment = 'gjs' | 'node' +export type Environment = 'gjs' diff --git a/packages/lib/src/types/transformations.ts b/packages/lib/src/types/transformations.ts index a830ddc65..36bb8dd00 100644 --- a/packages/lib/src/types/transformations.ts +++ b/packages/lib/src/types/transformations.ts @@ -2,9 +2,6 @@ import type { TransformationCase } from './transformation-case.js' export interface Transformations { [type: string]: { - node: { - transformation: TransformationCase - } gjs: { transformation: TransformationCase } From 99e0b3a6553aef048e56c4741c81da6ff6b4bbe9 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 11:37:31 -0700 Subject: [PATCH 07/53] Add @gi.ts/lib sources as 'newlib' --- packages/lib/src/newlib/formatters/default.ts | 7 + .../lib/src/newlib/formatters/formatter.ts | 3 + packages/lib/src/newlib/formatters/json.ts | 7 + .../lib/src/newlib/generators/dts-inline.ts | 87 + .../lib/src/newlib/generators/dts-modules.ts | 139 ++ packages/lib/src/newlib/generators/dts.ts | 875 +++++++++ packages/lib/src/newlib/generators/dts/gio.ts | 9 + .../lib/src/newlib/generators/dts/glib.ts | 516 ++++++ .../lib/src/newlib/generators/dts/gobject.ts | 202 ++ .../lib/src/newlib/generators/generator.ts | 52 + packages/lib/src/newlib/generators/index.ts | 6 + packages/lib/src/newlib/generators/json.ts | 1294 +++++++++++++ packages/lib/src/newlib/generics/clutter.ts | 53 + packages/lib/src/newlib/generics/generify.ts | 47 + packages/lib/src/newlib/generics/gio.ts | 66 + packages/lib/src/newlib/generics/glib.ts | 22 + packages/lib/src/newlib/generics/meta.ts | 27 + packages/lib/src/newlib/generics/st.ts | 112 ++ packages/lib/src/newlib/generics/visitor.ts | 368 ++++ packages/lib/src/newlib/gir.ts | 758 ++++++++ packages/lib/src/newlib/gir/alias.ts | 74 + packages/lib/src/newlib/gir/base.ts | 102 ++ packages/lib/src/newlib/gir/class.ts | 1618 +++++++++++++++++ packages/lib/src/newlib/gir/const.ts | 78 + packages/lib/src/newlib/gir/enum.ts | 258 +++ packages/lib/src/newlib/gir/function.ts | 874 +++++++++ packages/lib/src/newlib/gir/generics.ts | 68 + packages/lib/src/newlib/gir/namespace.ts | 571 ++++++ packages/lib/src/newlib/gir/nodes.ts | 19 + packages/lib/src/newlib/gir/property.ts | 204 +++ packages/lib/src/newlib/gir/registry.ts | 282 +++ packages/lib/src/newlib/gir/signal.ts | 237 +++ packages/lib/src/newlib/gir/util.ts | 657 +++++++ packages/lib/src/newlib/injections/gio.ts | 438 +++++ packages/lib/src/newlib/injections/glib.ts | 238 +++ packages/lib/src/newlib/injections/gobject.ts | 568 ++++++ packages/lib/src/newlib/injections/inject.ts | 24 + packages/lib/src/newlib/lib.ts | 83 + packages/lib/src/newlib/types.ts | 47 + packages/lib/src/newlib/util.ts | 84 + packages/lib/src/newlib/validators/class.ts | 258 +++ .../lib/src/newlib/validators/interface.ts | 20 + packages/lib/src/newlib/visitor.ts | 47 + 43 files changed, 11499 insertions(+) create mode 100644 packages/lib/src/newlib/formatters/default.ts create mode 100644 packages/lib/src/newlib/formatters/formatter.ts create mode 100644 packages/lib/src/newlib/formatters/json.ts create mode 100644 packages/lib/src/newlib/generators/dts-inline.ts create mode 100644 packages/lib/src/newlib/generators/dts-modules.ts create mode 100644 packages/lib/src/newlib/generators/dts.ts create mode 100644 packages/lib/src/newlib/generators/dts/gio.ts create mode 100644 packages/lib/src/newlib/generators/dts/glib.ts create mode 100644 packages/lib/src/newlib/generators/dts/gobject.ts create mode 100644 packages/lib/src/newlib/generators/generator.ts create mode 100644 packages/lib/src/newlib/generators/index.ts create mode 100644 packages/lib/src/newlib/generators/json.ts create mode 100644 packages/lib/src/newlib/generics/clutter.ts create mode 100644 packages/lib/src/newlib/generics/generify.ts create mode 100644 packages/lib/src/newlib/generics/gio.ts create mode 100644 packages/lib/src/newlib/generics/glib.ts create mode 100644 packages/lib/src/newlib/generics/meta.ts create mode 100644 packages/lib/src/newlib/generics/st.ts create mode 100644 packages/lib/src/newlib/generics/visitor.ts create mode 100644 packages/lib/src/newlib/gir.ts create mode 100644 packages/lib/src/newlib/gir/alias.ts create mode 100644 packages/lib/src/newlib/gir/base.ts create mode 100644 packages/lib/src/newlib/gir/class.ts create mode 100644 packages/lib/src/newlib/gir/const.ts create mode 100644 packages/lib/src/newlib/gir/enum.ts create mode 100644 packages/lib/src/newlib/gir/function.ts create mode 100644 packages/lib/src/newlib/gir/generics.ts create mode 100644 packages/lib/src/newlib/gir/namespace.ts create mode 100644 packages/lib/src/newlib/gir/nodes.ts create mode 100644 packages/lib/src/newlib/gir/property.ts create mode 100644 packages/lib/src/newlib/gir/registry.ts create mode 100644 packages/lib/src/newlib/gir/signal.ts create mode 100644 packages/lib/src/newlib/gir/util.ts create mode 100644 packages/lib/src/newlib/injections/gio.ts create mode 100644 packages/lib/src/newlib/injections/glib.ts create mode 100644 packages/lib/src/newlib/injections/gobject.ts create mode 100644 packages/lib/src/newlib/injections/inject.ts create mode 100644 packages/lib/src/newlib/lib.ts create mode 100644 packages/lib/src/newlib/types.ts create mode 100644 packages/lib/src/newlib/util.ts create mode 100644 packages/lib/src/newlib/validators/class.ts create mode 100644 packages/lib/src/newlib/validators/interface.ts create mode 100644 packages/lib/src/newlib/visitor.ts diff --git a/packages/lib/src/newlib/formatters/default.ts b/packages/lib/src/newlib/formatters/default.ts new file mode 100644 index 000000000..d0f6a4d1b --- /dev/null +++ b/packages/lib/src/newlib/formatters/default.ts @@ -0,0 +1,7 @@ +import { Formatter } from "./formatter.js"; + +export class DefaultFormatter extends Formatter { + format(source: string): string { + return source; + } +} diff --git a/packages/lib/src/newlib/formatters/formatter.ts b/packages/lib/src/newlib/formatters/formatter.ts new file mode 100644 index 000000000..dc9cb743f --- /dev/null +++ b/packages/lib/src/newlib/formatters/formatter.ts @@ -0,0 +1,3 @@ +export abstract class Formatter { + abstract format(source: string): string; +} diff --git a/packages/lib/src/newlib/formatters/json.ts b/packages/lib/src/newlib/formatters/json.ts new file mode 100644 index 000000000..af58ec037 --- /dev/null +++ b/packages/lib/src/newlib/formatters/json.ts @@ -0,0 +1,7 @@ +import { Formatter } from "./formatter.js"; + +export class JSONFormatter extends Formatter { + format(source: string): string { + return JSON.stringify(JSON.parse(source), null, 4); + } +} diff --git a/packages/lib/src/newlib/generators/dts-inline.ts b/packages/lib/src/newlib/generators/dts-inline.ts new file mode 100644 index 000000000..273125192 --- /dev/null +++ b/packages/lib/src/newlib/generators/dts-inline.ts @@ -0,0 +1,87 @@ +import { GirNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; + +import { GirBase } from "../gir.js"; +import { GenerationOptions } from "../types.js"; + +import { override as overrideGLib } from "./dts/glib.js"; +import { override as overrideGObject } from "./dts/gobject.js"; +import { override as overrideGio } from "./dts/gio.js"; +import { DtsGenerator } from "./dts.js"; + +export class DtsInlineGenerator extends DtsGenerator { + constructor(namespace: GirNamespace, options: GenerationOptions) { + super(namespace, options); + } + + async generateNamespace(node: GirNamespace): Promise { + const { namespace, options } = this; + + if (options.verbose) { + console.debug(`Resolving the types of ${namespace.name}...`); + } + + let suffix = ""; + + if (!options.noAdvancedVariants && node.name === "GLib") { + suffix = `\n${overrideGLib(node)}\n`; + } else if (node.name === "GObject") { + suffix = `\n${overrideGObject(node)}\n`; + } else if (node.name === "Gio") { + suffix = `\n${overrideGio(node)}\n`; + } + + try { + const { name } = node; + + const header = ` +/** + * ${name} ${node.version} + * + * Generated from ${node.package_version.join(".")} + */ +`; + const base = ` + +`; + + if (options.promisify) { + promisifyNamespaceFunctions(node); + } + + const content = Array.from(node.members.values()) + .map(m => { + return `${(Array.isArray(m) ? m : [m]) + .map(m => (m.emit ? (m as GirBase).asString(this) : "")) + .join(`\n`)}`; + }) + .join(`\n`); + + // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. + const imports = Array.from(node.getImports()) + .map( + ([i, version]) => + `import * as ${i} from "${options.importPrefix}${i.toLowerCase()}${ + options.versionedImports ? version.toLowerCase().split(".")[0] : "" + }";` + ) + .join(`${`\n`}`); + + const output = [header, imports, base, content, suffix].join(`\n\n`); + + if (options.verbose) { + console.debug(`Printing ${namespace.name}...`); + } + + return output; + } catch (err) { + console.error(`Failed to generate namespace: ${node.name}`); + console.error(err); + + return null; + } + } + + async stringifyNamespace(node: GirNamespace): Promise { + return this.generateNamespace(node); + } +} diff --git a/packages/lib/src/newlib/generators/dts-modules.ts b/packages/lib/src/newlib/generators/dts-modules.ts new file mode 100644 index 000000000..7557034a4 --- /dev/null +++ b/packages/lib/src/newlib/generators/dts-modules.ts @@ -0,0 +1,139 @@ +import { GirNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; + +import { + GirBase } from "../gir.js"; +import { GenerationOptions } from "../types.js"; + +import { override as overrideGLib } from "./dts/glib.js"; +import { override as overrideGObject } from "./dts/gobject.js"; +import { override as overrideGio } from "./dts/gio.js"; +import { DtsGenerator, versionImportFormat } from "./dts.js"; + +export class DtsModuleGenerator extends DtsGenerator { + constructor(namespace: GirNamespace, options: GenerationOptions) { + super(namespace, options); + } + + + async generateNamespace(node: GirNamespace): Promise { + const { namespace, options } = this; + + if (options.verbose) { + console.debug(`Resolving the types of ${namespace.name}...`); + } + + let suffix = ""; + + if (!options.noAdvancedVariants && node.name === "GLib") { + suffix = `\n${overrideGLib(node)}\n`; + } else if (node.name === "GObject") { + suffix = `\n${overrideGObject(node)}\n`; + } else if (node.name === "Gio") { + suffix = `\n${overrideGio(node)}\n`; + } + + try { + const { name } = node; + + const header = ` +/** + * ${name} ${node.version} + * + * Generated from ${node.package_version.join(".")} + */ +`; + const base = ` + +`; + + if (options.promisify) { + promisifyNamespaceFunctions(node); + } + + const content = Array.from(node.members.values()) + .map(m => { + return `${(Array.isArray(m) ? m : [m]) + .map(m => (m.emit ? (m as GirBase).asString(this) : "")) + .join(`\n`)}`; + }) + .join(`\n`); + + const pathSuffix = options.outputFormat === "folder" ? "/index.d.ts" : ".d.ts"; + const referenceType = options.importPrefix.startsWith(".") ? "path" : "types"; + const references = [ + ...(node.__dts__references ?? []), + ...Array.from(node.getImports()).map( + ([i, version]) => + `/// ` + ) + ].join(`\n`); + + // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. + const imports = Array.from(node.getImports()) + .map( + ([i, version]) => + `import ${i} from 'gi://${i}${options.versionedImports ? `?version=${version}` : ""}';` + ) + .join(`\n`); + + const metadata = ` + /** + * Name of the imported GIR library + * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188 + */ +export const __name__: string; +/** + * Version of the imported GIR library + * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189 + */ +export const __version__: string; +`; + + const moduleIdentifier = `gi://${name}`; + const versionedNamespaceIdentifier = `${name}${node.version.split('.')[0].replace(/[^A-z0-9_]/g, '_')}`; + const versionedModuleIdentifier = `${moduleIdentifier}?version=${node.version}`; + + const [versionedModuleHeader, versionedModuleSuffix] = [ + `declare module "${versionedModuleIdentifier}" { + namespace ${versionedNamespaceIdentifier} {`, + `}; + + export default ${versionedNamespaceIdentifier}; + }` + ]; + const moduleDefinition = `declare module "${moduleIdentifier}" { + export * from "${versionedModuleIdentifier}"; + }`; + + const output = [ + references, + header, + versionedModuleHeader, + imports, + base, + content, + suffix, + metadata, + versionedModuleSuffix, + moduleDefinition + ].join(`\n\n`); + + if (options.verbose) { + console.debug(`Printing ${namespace.name}...`); + } + + return output; + } catch (err) { + console.error(`Failed to generate namespace: ${node.name}`); + console.error(err); + + return null; + } + } + + async stringifyNamespace(node: GirNamespace): Promise { + return this.generateNamespace(node); + } +} diff --git a/packages/lib/src/newlib/generators/dts.ts b/packages/lib/src/newlib/generators/dts.ts new file mode 100644 index 000000000..18b6f8010 --- /dev/null +++ b/packages/lib/src/newlib/generators/dts.ts @@ -0,0 +1,875 @@ +import { FormatGenerator } from "./generator.js"; +import { GirNamespace } from "../gir/namespace.js"; + +import { + GirBaseClass, + GirRecord, + GirInterface, + GirClass, + filterConflicts, + filterFunctionConflict, + FilterBehavior, + promisifyFunctions +} from "../gir/class.js"; +import { GirConst } from "../gir/const.js"; +import { GirEnum, GirError, GirEnumMember } from "../gir/enum.js"; +import { GirProperty, GirField } from "../gir/property.js"; +import { GirSignal, GirSignalType } from "../gir/signal.js"; +import { GirFunction, GirConstructor, GirFunctionParameter, GirCallback, GirDirectAllocationConstructor } from "../gir/function.js"; +import { GirClassFunction, GirStaticClassFunction, GirVirtualClassFunction } from "../gir/function.js"; +import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js"; +import { + TypeExpression, + NativeType, + AnyType, + VoidType, + StringType, + NumberType, + ArrayType, + AnyFunctionType, + Generic, + ConflictType, + TypeConflict, + BinaryType, + GirBase +} from "../gir.js"; +import { Direction } from "@gi.ts/parser"; +import { GirAlias } from "../gir/alias.js"; +import { GenerationOptions } from "../types.js"; + +export function versionImportFormat(versionFormat: string, namespace: string, version: string) { + const versionSlug = version.toLowerCase().split(".")[0]; + const namespaceLowercase = namespace.toLowerCase(); + + return `${versionFormat.replace('{version}', version).replace('{version-slug}', versionSlug).replace('{namespace}', namespace).replace('{namespace-lower}', namespaceLowercase)}`; +} + +export abstract class DtsGenerator extends FormatGenerator { + constructor(namespace: GirNamespace, options: GenerationOptions) { + super(namespace, options); + } + + protected generateParameters(parameters: GirFunctionParameter[]): string { + return parameters + .map(p => { + return p.asString(this); + }) + .join(", "); + } + + generateGenerics(nodes: Generic[], withDefaults = true) { + const { namespace, options } = this; + + const list = nodes.map(generic => { + const Type = generic.type.rootPrint(namespace, options); + + if (generic.defaultType && withDefaults) { + let defaultType = generic.defaultType.rootPrint(namespace, options); + + if (generic.constraint) { + let constraint = generic.constraint.rootPrint(namespace, options); + return `${Type} extends ${constraint} = ${defaultType}`; + } + + return `${Type} = ${defaultType}`; + } else if (generic.constraint && withDefaults) { + let constraint = generic.constraint.rootPrint(namespace, options); + return `${Type} extends ${constraint}`; + } else { + return `${Type}`; + } + }); + + if (list.length > 0) { + return `<${list.join(", ")}>`; + } + + return ""; + } + + generateCallbackType(node: GirCallback): [string, string] { + const { namespace, options } = this; + + const Parameters = this.generateParameters(node.parameters); + + if (node.generics.length > 0) { + const GenericDefinitions = this.generateGenerics(node.generics); + + return [ + `${GenericDefinitions}`, + `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}` + ]; + } + return [``, `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`]; + } + + generateCallback(node: GirCallback): string { + return `${this.docString(node)}export type ${node.name}${this.generateCallbackType(node).join(" = ")};`; + } + + generateReturn(return_type: TypeExpression, output_parameters: GirFunctionParameter[]) { + const { namespace, options } = this; + + let resolved_return_type = + resolveDirectedType(return_type, Direction.Out)?.resolve(namespace, options) ?? + return_type.resolve(namespace, options); + + const type = resolved_return_type.rootPrint(namespace, options); + + if (output_parameters.length > 0) { + const exclude_first = type === "void" || type === ""; + const returns = [ + ...(exclude_first ? [] : [`${type}`]), + ...output_parameters + .map(op => { + return ( + resolveDirectedType(op.type, Direction.Out)?.resolve(namespace, options) ?? + op.type.resolve(namespace, options) + ); + }) + .map(p => p.rootPrint(namespace, options)) + ]; + if (returns.length > 1) { + return `[${returns.join(", ")}]`; + } else { + return `${returns[0]}`; + } + } + + return type; + } + + generateEnum(node: GirEnum): string { + const { namespace } = this; + + const isInvalidEnum = Array.from(node.members.keys()).some( + name => name.match(/^[0-9]+$/) || name === "NaN" || name === "Infinity" + ); + + if (isInvalidEnum) { + return node.asClass().asString(this); + } + + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); + + return ` +export namespace ${node.name} { + export const $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${node.name}>; +} + +${this.docString(node)}export enum ${node.name} { + ${Array.from(node.members.values()) + .map(member => `${member.asString(this)}`) + .join(`\n `)} +}`; + } + + generateError(node: GirError): string { + const { namespace } = this; + const clazz = node.asClass(); + + clazz.members = []; + clazz.members.push(...Array.from(node.functions.values())); + + const GLib = namespace.assertInstalledImport("GLib"); + const GLibError = GLib.assertClass("Error"); + + clazz.parent = GLibError.getType(); + + // Manually construct a GLib.Error constructor. + clazz.mainConstructor = new GirConstructor({ + name: "new", + parameters: [ + new GirFunctionParameter({ + name: "options", + type: NativeType.of("{ message: string, code: number}"), + direction: Direction.In + }) + ], + return_type: clazz.getType() + }); + + return clazz.asString(this); + } + + generateConst(node: GirConst): string { + const { namespace, options } = this; + + return `${this.docString(node)}export const ${node.name}: ${node.type.resolve(namespace, options).print(namespace, options)};`; + } + + protected implements(node: GirClass) { + const { namespace, options } = this; + + const interfaces = node.interfaces.map(i => { + const identifier = i.resolveIdentifier(namespace, options); + + if (!identifier) { + throw new Error( + `Unable to resolve type: ${i.name} from ${i.namespace} in ${node.namespace.name} ${node.namespace.version}` + ); + } + + return identifier; + }); + + if (interfaces.length > 0) { + return ` implements ${interfaces + .map(i => { + const Type = i.print(namespace, options); + return `${Type}`; + }) + .join(", ")}`; + } + + return ""; + } + + protected extends(node: GirBaseClass) { + const { namespace: ns, options } = this; + if (node.parent) { + const ResolvedType = node.parent.resolveIdentifier(ns, options); + const Type = ResolvedType?.print(ns, options); + + if (Type) { + return ` extends ${Type}`; + } + + throw new Error( + `Unable to resolve type: ${node.parent.name} from ${node.parent.namespace} in ${node.namespace.name} ${node.namespace.version}` + ); + } + + return ""; + } + + generateInterface(node: GirInterface): string { + const { namespace, options } = this; + + const isGObject = node.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); + + const name = node.name; + + let generics = node.generics; + + let Generics = ""; + let GenericTypes = ""; + + if (generics.length > 0) { + Generics = `${this.generateGenerics(generics)}`; + GenericTypes = `${this.generateGenerics(generics, false)}`; + } + + const Extends = this.extends(node); + const filteredFunctions = filterFunctionConflict(node.namespace, node, node.members, []); + const functions = options.promisify ? promisifyFunctions(filteredFunctions) : filteredFunctions; + + const staticFunctions = functions.filter(f => f instanceof GirStaticClassFunction); + const staticFields = node.fields + .filter(f => f.isStatic) + .map(f => + f.copy({ + isStatic: false + }) + ); + + const nonStaticFunctions = functions.filter(f => !(f instanceof GirStaticClassFunction)); + const nonStaticFields = node.fields.filter(f => !f.isStatic); + + const hasNamespace = isGObject || staticFunctions.length > 0 || node.callbacks.length > 0; + + if (isGObject) { + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); + } + + return ` + ${ + node.callbacks.length > 0 + ? `export module ${name} { + ${node.callbacks.map(c => c.asString(this)).join(`\n`)} + }` + : "" + } + ${ + hasNamespace + ? `${this.docString(node)}export interface ${name}Namespace { + ${isGObject ? `$gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>;` : ""} + prototype: ${name}Prototype; + ${staticFields.length > 0 ? staticFields.map(sf => sf.asString(this)).join(`\n`) : ""} + ${ + staticFunctions.length > 0 + ? staticFunctions.map(sf => GirClassFunction.prototype.asString.call(sf, this)).join(`\n`) + : "" + } + }` + : "" + } +export type ${name}${Generics} = ${name}Prototype${GenericTypes}; +export interface ${name}Prototype${Generics}${Extends} {${ + node.indexSignature ? `\n${node.indexSignature}\n` : "" + } + ${node.props.length > 0 ? `// Properties` : ""} + ${filterConflicts(node.namespace, node, node.props) + .map(p => p.asString(this)) + .join(`\n`)} + ${nonStaticFields.length > 0 ? `// Fields` : ""} + ${filterConflicts(node.namespace, node, nonStaticFields) + .map(p => p.asString(this)) + .join(`\n`)} + ${nonStaticFunctions.length > 0 ? `// Members\n` : ""} + ${nonStaticFunctions.map(m => m.asString(this)).join(`\n`)} + }${hasNamespace ? `\n\nexport const ${name}: ${name}Namespace;\n` : ""}`; + } + + generateRecord(node: GirRecord): string { + const { options, namespace } = this; + + const { name } = node; + + const Extends = this.extends(node); + + let Generics = ""; + + if (node.generics.length > 0) { + Generics = `${this.generateGenerics(node.generics)}`; + } + + let MainConstructor: string = ""; + + if (node.isForeign()) { + MainConstructor = ""; + } else if (node.mainConstructor) { + MainConstructor = node.mainConstructor.asString(this); + } + + const hasCallbacks = node.callbacks.length > 0; + + const Properties = filterConflicts(node.namespace, node, node.props) + .map(v => v.asString(this)) + .join(`\n`); + + const Fields = filterConflicts(node.namespace, node, node.fields) + .map(v => v.asString(this)) + .join(`\n`); + + const Constructors = filterConflicts(node.namespace, node, node.constructors) + .map(v => this.generateConstructorFunction(v)) + .join(`\n`); + + const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []); + const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers) + .map(v => v.asString(this)) + .join(`\n`); + + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); + + return `${ + hasCallbacks + ? `export module ${name} { + ${node.callbacks.map(c => c.asString(this)).join(`\n`)} +}` + : `` + } + +${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSignature ? `\n${node.indexSignature}\n` : ""} + static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>; + + ${MainConstructor} + constructor(copy: ${node.name}); + + ${node.props.length > 0 ? `// Properties` : ""} + ${Properties} + + ${node.fields.length > 0 ? `// Fields` : ""} + ${Fields} + + ${node.constructors.length > 0 ? `// Constructors` : ""} + ${Constructors} + + ${node.members.length > 0 ? `// Members` : ""} + ${Members} +}`; + } + + generateClass(node: GirClass): string { + const { options, namespace } = this; + + const name = node.name; + + let injectConstructorBucket = !node.mainConstructor; + + let Generics = ""; + let GenericTypes = ""; + + if (node.generics.length > 0) { + Generics = `${this.generateGenerics(node.generics)}`; + GenericTypes = `${this.generateGenerics(node.generics, false)}`; + } + + const Extends = this.extends(node); + const Implements = this.implements(node); + + const implementedProperties = node.implementedProperties(); + const implementedMethods = node.implementedMethods(implementedProperties); + + let MainConstructor: string = ""; + + if (node.mainConstructor) { + MainConstructor = `\n${node.mainConstructor.asString(this)}`; + } else { + MainConstructor = `\nconstructor(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]);\n`; + + if (!options.noInitTypes) { + MainConstructor += `_init(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]): void;\n`; + } else { + MainConstructor += `_init(...args: any[]): void;\n`; + } + } + + const ConstructorProps = filterConflicts( + node.namespace, + node, + // TODO: Include properties from interface parents too. + node.props + ) + .map(v => v.asString(this, true)) + .join(`\n `); + + const Properties = filterConflicts(node.namespace, node, node.props) + .map(v => v.asString(this)) + .join(`\n `); + + const Fields = filterConflicts(node.namespace, node, node.fields) + .map(v => v.asString(this)) + .join(`\n `); + + const Constructors = filterFunctionConflict(node.namespace, node, node.constructors, []) + .map(v => this.generateConstructorFunction(v)) + .join(`\n `); + + const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []); + const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers) + .map(v => v.asString(this)) + .join(`\n `); + + const ImplementedProperties = filterConflicts(node.namespace, node, implementedProperties) + .map(m => m.asString(this)) + .join(`\n `); + + const FilteredImplMethods = filterFunctionConflict(node.namespace, node, implementedMethods, []); + const ImplementedMethods = ( + options.promisify ? promisifyFunctions(FilteredImplMethods) : FilteredImplMethods + ) + .map(m => m.asString(this)) + .join(`\n `); + + // TODO Move these to a cleaner place. + + const Connect = new GirClassFunction({ + name: "connect", + parent: node, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: NumberType + }); + + const ConnectAfter = new GirClassFunction({ + name: "connect_after", + parent: node, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: NumberType + }); + + const Emit = new GirClassFunction({ + name: "emit", + parent: node, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "args", + isVarArgs: true, + type: new ArrayType(AnyType), + direction: Direction.In + }) + ], + return_type: VoidType + }); + + let default_signals = [] as GirClassFunction[]; + let hasConnect, hasConnectAfter, hasEmit; + + if (node.signals.length > 0) { + hasConnect = node.members.some(m => m.name === "connect"); + hasConnectAfter = node.members.some(m => m.name === "connect_after"); + hasEmit = node.members.some(m => m.name === "emit"); + + if (!hasConnect) { + default_signals.push(Connect); + } + if (!hasConnectAfter) { + default_signals.push(ConnectAfter); + } + if (!hasEmit) { + default_signals.push(Emit); + } + + default_signals = filterConflicts(namespace, node, default_signals, FilterBehavior.DELETE); + + hasConnect = !default_signals.some(s => s.name === "connect"); + hasConnectAfter = !default_signals.some(s => s.name === "connect_after"); + hasEmit = !default_signals.some(s => s.name === "emit"); + } + + const SignalsList = [ + // TODO Relocate these. + ...default_signals.map(s => s.asString(this)), + ...node.signals + .map(s => { + const methods = [] as string[]; + + if (!hasConnect) methods.push(s.asString(this, GirSignalType.CONNECT)); + if (!hasConnectAfter) methods.push(s.asString(this, GirSignalType.CONNECT_AFTER)); + if (!hasEmit) methods.push(s.asString(this, GirSignalType.EMIT)); + + return methods; + }) + .flat() + ]; + + const hasSignals = SignalsList.length > 0; + const Signals = SignalsList.join(`\n`); + + const hasCallbacks = node.callbacks.length > 0; + const hasModule = injectConstructorBucket || hasCallbacks; + + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); + + let [ExtendsInterface, ExtendsGenerics = ""] = Extends.split("<"); + + if (ExtendsGenerics.length > 0) { + ExtendsGenerics = `<${ExtendsGenerics}`; + } + + return `${ + hasModule + ? `export module ${name} { + ${hasCallbacks ? node.callbacks.map(c => c.asString(this)).join(`\n`) : ""} + ${ + injectConstructorBucket + ? `export interface ConstructorProperties${Generics}${ + Extends ? `${ExtendsInterface}.ConstructorProperties${ExtendsGenerics}` : "" + } { + [key: string]: any; + ${ConstructorProps} +}` + : "" + } +}` + : "" + } + export ${node.isAbstract ? `abstract ` : ""}class ${name}${Generics}${Extends}${Implements} {${ + node.indexSignature ? `\n${node.indexSignature}\n` : "" + } + static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>; + + ${MainConstructor} + + ${node.props.length > 0 ? `// Properties` : ""} + ${Properties} + + ${node.fields.length > 0 ? `// Fields` : ""} + ${Fields} + + ${hasSignals ? `// Signals\n` : ""} + ${Signals} + + ${implementedProperties.length > 0 ? `// Implemented Properties\n` : ""} + ${ImplementedProperties} + + ${node.constructors.length > 0 ? `// Constructors\n` : ""} + ${Constructors} + + ${node.members.length > 0 ? `// Members\n` : ""} + ${Members} + + ${implementedMethods.length > 0 ? `// Implemented Members\n` : ""} + ${ImplementedMethods} +}`; + } + + generateField(node: GirField): string { + const { namespace, options } = this; + const { name, computed } = node; + const invalid = isInvalid(name); + + const Static = node.isStatic ? "static" : ""; + const ReadOnly = node.writable ? "" : "readonly"; + + const Modifier = [Static, ReadOnly].filter(a => a !== "").join(" "); + + const Name = computed ? `[${name}]` : invalid ? `"${name}"` : name; + + let { type } = node; + let fieldAnnotation = ""; + if (type instanceof TypeConflict) { + if (type.conflictType === ConflictType.PROPERTY_ACCESSOR_CONFLICT) { + fieldAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. +// @ts-expect-error\n`; + } + + type = new BinaryType(type.unwrap(), AnyType); + } + + return `${this.docString(node)}${fieldAnnotation}${Modifier} ${Name}${node.optional ? "?" : ""}: ${type + .resolve(namespace, options) + .rootPrint(namespace, options)};`; + } + + generateProperty(node: GirProperty, construct: boolean = false): string { + const { namespace, options } = this; + + const invalid = isInvalid(node.name); + const Name = invalid ? `"${node.name}"` : node.name; + + let type = node.type; + let getterAnnotation = ""; + let setterAnnotation = ""; + let getterSetterAnnotation = ""; + + if (type instanceof TypeConflict) { + switch (type.conflictType) { + case ConflictType.FUNCTION_NAME_CONFLICT: + case ConflictType.FIELD_NAME_CONFLICT: + getterSetterAnnotation = + setterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + // @ts-expect-error\n`; + case ConflictType.ACCESSOR_PROPERTY_CONFLICT: + getterSetterAnnotation = + getterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + // @ts-expect-error\n`; + type = type.unwrap(); + break; + case ConflictType.PROPERTY_ACCESSOR_CONFLICT: + type = new BinaryType(type.unwrap(), AnyType); + break; + case ConflictType.PROPERTY_NAME_CONFLICT: + getterSetterAnnotation = + setterAnnotation = + getterAnnotation = + `// This accessor conflicts with another accessor's type in a parent class or interface.\n`; + type = new BinaryType(type.unwrap(), AnyType); + break; + } + + if (construct && !(type instanceof BinaryType)) { + // For constructor properties we just convert to any. + type = new BinaryType(type, AnyType); + } + } + + let Type = type.resolve(namespace, options).rootPrint(namespace, options) || "any"; + + if (construct) { + return `${Name}: ${Type};`; + } + + const { readable, writable, constructOnly } = node; + + let hasGetter = readable; + let hasSetter = writable && !constructOnly; + + if (node.parent instanceof GirInterface) { + if (!hasSetter && hasGetter) { + return `readonly ${Name}: ${Type};`; + } else { + return `${Name}: ${Type};`; + } + } + + if (hasGetter && hasSetter) { + return `${getterAnnotation} get ${Name}(): ${Type}; + ${setterAnnotation} set ${Name}(val: ${Type});`; + } else if (hasGetter) { + return `${getterSetterAnnotation} get ${Name}(): ${Type};`; + } else { + return `${getterSetterAnnotation} set ${Name}(val: ${Type});`; + } + } + + generateSignal(node: GirSignal, type: GirSignalType = GirSignalType.CONNECT): string { + switch (type) { + case GirSignalType.CONNECT: + return node.asConnect(false).asString(this); + case GirSignalType.CONNECT_AFTER: + return node.asConnect(true).asString(this); + case GirSignalType.EMIT: + return node.asEmit().asString(this); + } + } + + generateEnumMember(node: GirEnumMember): string { + const invalid = isInvalid(node.name); + if (node.value != null && !Number.isNaN(Number.parseInt(node.value, 10))) { + return invalid ? `${this.docString(node)}"${node.name}" = ${node.value},` : `${this.docString(node)}${node.name} = ${node.value},`; + } else { + return invalid ? `${this.docString(node)}"${node.name}",` : `${this.docString(node)}${node.name},`; + } + } + + generateParameter(node: GirFunctionParameter): string { + const { namespace, options } = this; + + let type: string = + resolveDirectedType(node.type, node.direction) + ?.resolve(namespace, options) + .rootPrint(namespace, options) ?? node.type.resolve(namespace, options).rootPrint(namespace, options); + + if (node.isVarArgs) { + return `...args: ${type}`; + } + + if (node.isOptional) { + return `${node.name}?: ${type}`; + } else { + return `${node.name}: ${type}`; + } + } + + docString(node: GirBase) { + // TODO: Support node.doc not being a string? + return typeof node.doc === 'string' && this.options.withDocs ? `/** +${node.doc.split('\n').map(line => ` * ${line.trim() + .replace('*/', '*\\/') +.replace(/@([a-z_]+?)([. ])/g, '`$1$2`')}` +.replace(/@([a-z])/g, '$1')) +.join('\n')} + */\n` : '' + } + + generateFunction(node: GirFunction): string { + const { namespace } = this; + // Register our identifier with the sanitized identifiers. + // We avoid doing this in fromXML because other class-level function classes + // depends on that code. + sanitizeIdentifierName(namespace.name, node.raw_name); + + const Parameters = this.generateParameters(node.parameters); + const ReturnType = this.generateReturn(node.return(), node.output_parameters); + const Generics = this.generateGenerics(node.generics); + return `${this.docString(node)}export function ${node.name}${Generics}(${Parameters}): ${ReturnType};`; + } + + generateConstructorFunction(node: GirConstructor): string { + const { namespace, options } = this; + + const Parameters = this.generateParameters(node.parameters); + + const invalid = isInvalid(node.name); + const name = invalid ? `["${node.name}"]` : node.name; + const warning = node.getWarning(); + return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${name}(${Parameters}): ${node + .return() + .resolve(namespace, options) + .rootPrint(namespace, options)};`; + } + + generateConstructor(node: GirConstructor): string { + const Parameters = this.generateParameters(node.parameters); + + return `constructor(${Parameters});`; + } + + generateDirectAllocationConstructor(node: GirDirectAllocationConstructor): string { + const ConstructorFields = node.fields.map(field => field.asString(this)).join(`\n`); + + return ` + constructor(properties?: Partial<{ + ${ConstructorFields} + }>);`; + } + + generateClassFunction(node: GirClassFunction): string { + const invalid = isInvalid(node.name); + + let parameters = node.parameters; + let output_parameters = node.output_parameters; + let return_type = node.return(); + + const Parameters = this.generateParameters(parameters); + let ReturnType = this.generateReturn(return_type, output_parameters); + + const Generics = this.generateGenerics(node.generics); + + if (node.shouldAnyify()) { + return `${ + invalid ? `["${node.name}"]` : node.name + }: ${Generics}((${Parameters}) => ${ReturnType}) | any;`; + } + + const warning = node.getWarning(); + return `${warning ? `${warning}\n` : ""}${this.docString(node)}${ + invalid ? `["${node.name}"]` : node.name + }${Generics}(${Parameters}): ${ReturnType};`; + } + + generateStaticClassFunction(node: GirStaticClassFunction): string { + const Generics = this.generateGenerics(node.generics); + + let ReturnType = this.generateReturn(node.return(), node.output_parameters); + + const warning = node.getWarning(); + return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${node.name}${Generics}(${this.generateParameters( + node.parameters + )}): ${ReturnType};`; + } + + generateAlias(node: GirAlias): string { + const { namespace, options } = this; + const Type = node.type.resolve(namespace, options).print(namespace, options); + const GenericBase = node.generics + .map(g => { + if (g.type) { + return `${g.name} = ${g.type.resolve(namespace, options).rootPrint(namespace, options)}`; + } + + return `${g.name}`; + }) + .join(", "); + const Generic = GenericBase ? `<${GenericBase}>` : ""; + + return `${this.docString(node)}export type ${node.name}${Generic} = ${Type};`; + } + + generateVirtualClassFunction(node: GirVirtualClassFunction): string { + return this.generateClassFunction(node); + } +} diff --git a/packages/lib/src/newlib/generators/dts/gio.ts b/packages/lib/src/newlib/generators/dts/gio.ts new file mode 100644 index 000000000..9d8222712 --- /dev/null +++ b/packages/lib/src/newlib/generators/dts/gio.ts @@ -0,0 +1,9 @@ +import { GirNamespace } from "../../gir/namespace.js"; + +export function override(_node: GirNamespace) { + return ` + export function _promisify(klass: any, function_name: string, finish_function_name: string): void; + export interface _LocalFilePrototype extends FilePrototype {} + export const _LocalFilePrototype: _LocalFilePrototype; + `; +} diff --git a/packages/lib/src/newlib/generators/dts/glib.ts b/packages/lib/src/newlib/generators/dts/glib.ts new file mode 100644 index 000000000..eb8026ec5 --- /dev/null +++ b/packages/lib/src/newlib/generators/dts/glib.ts @@ -0,0 +1,516 @@ +import { GirNamespace } from "../../gir/namespace.js"; + +export function override(node: GirNamespace) { + // We provide manually written versions of these types below. + node.assertClass("Variant").noEmit(); + node.assertClass("VariantType").noEmit(); + node.assertClass("VariantBuilder").noEmit(); + node.assertClass("VariantDict").noEmit(); + + return ` + // Variant parsing inspired by https://jamie.build/ slightly infamous JSON-in-TypeScript parsing. + + type CreateIndexType = + Key extends \`s\` | \`o\` | \`g\` ? { [key: string]: Value } : + Key extends \`n\` | \`q\` | \`t\` | \`d\` | \`u\` | \`i\` | \`x\` | \`y\` ? { [key: number]: Value } : never; + + type VariantTypeError = { error: true } & T; + + /** + * Handles the {kv} of a{kv} where k is a basic type and v is any possible variant type string. + */ + type $ParseDeepVariantDict = {}> = + string extends State + ? VariantTypeError<"$ParseDeepVariantDict: 'string' is not a supported type."> + // Hitting the first '}' indicates the dictionary type is complete + : State extends \`}\${infer State}\` + ? [Memo, State] + // This separates the key (basic type) from the rest of the remaining expression. + : State extends \`\${infer Key}\${''}\${infer State}\` + ? $ParseDeepVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`}\${infer State}\` + ? [CreateIndexType, State] + : VariantTypeError<\`$ParseDeepVariantDict encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseDeepVariantValue returned unexpected value for: \${State}\`> + : VariantTypeError<\`$ParseDeepVariantDict encountered an invalid variant string: \${State} (2)\`>; + + /** + * Handles parsing values within a tuple (e.g. (vvv)) where v is any possible variant type string. + */ + type $ParseDeepVariantArray = + string extends State + ? VariantTypeError<"$ParseDeepVariantArray: 'string' is not a supported type."> + : State extends \`)\${infer State}\` + ? [Memo, State] + : $ParseDeepVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`\${infer NextValue})\${infer NextState}\` + ? $ParseDeepVariantArray + : State extends \`)\${infer State}\` + ? [[...Memo, Value], State] + : VariantTypeError<\`1: $ParseDeepVariantArray encountered an invalid variant string: \${State}\`> + : VariantTypeError<\`2: $ParseDeepVariantValue returned unexpected value for: \${State}\`>; + + /** + * Handles parsing {kv} without an 'a' prefix (key-value pair) where k is a basic type + * and v is any possible variant type string. + */ + type $ParseDeepVariantKeyValue = + string extends State + ? VariantTypeError<"$ParseDeepVariantKeyValue: 'string' is not a supported type."> + : State extends \`}\${infer State}\` + ? [Memo, State] + : State extends \`\${infer Key}\${''}\${infer State}\` + ? $ParseDeepVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`}\${infer State}\` + ? [[...Memo, $ParseVariant, Value], State] + : VariantTypeError<\`$ParseDeepVariantKeyValue encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseDeepVariantKeyValue returned unexpected value for: \${State}\`> + : VariantTypeError<\`$ParseDeepVariantKeyValue encountered an invalid variant string: \${State} (2)\`>; + + /** + * Handles parsing any variant 'value' or base unit. + * + * - ay - Array of bytes (Uint8Array) + * - a* - Array of type * + * - a{k*} - Dictionary + * - {k*} - KeyValue + * - (**) - tuple + * - s | o | g - string types + * - n | q | t | d | u | i | x | y - number types + * - b - boolean type + * - v - unknown Variant type + * - h | ? - unknown types + */ + type $ParseDeepVariantValue = + string extends State + ? unknown + : State extends \`\${\`s\` | \`o\` | \`g\`}\${infer State}\` + ? [string, State] + : State extends \`\${\`n\` | \`q\` | \`t\` | \`d\` | \`u\` | \`i\` | \`x\` | \`y\`}\${infer State}\` + ? [number, State] + : State extends \`b\${infer State}\` + ? [boolean, State] + : State extends \`v\${infer State}\` + ? [Variant, State] + : State extends \`\${'h' | '?'}\${infer State}\` + ? [unknown, State] + : State extends \`(\${infer State}\` + ? $ParseDeepVariantArray + : State extends \`a{\${infer State}\` + ? $ParseDeepVariantDict + : State extends \`{\${infer State}\` + ? $ParseDeepVariantKeyValue + : State extends \`ay\${infer State}\` ? + [Uint8Array, State] + : State extends \`m\${infer State}\` + ? $ParseDeepVariantValue extends [infer Value, \`\${infer State}\`] + ? [Value | null, State] + : VariantTypeError<\`$ParseDeepVariantValue encountered an invalid variant string: \${State} (3)\`> + : State extends \`a\${infer State}\` ? + $ParseDeepVariantValue extends [infer Value, \`\${infer State}\`] ? + [Value[], State] + : VariantTypeError<\`$ParseDeepVariantValue encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseDeepVariantValue encountered an invalid variant string: \${State} (2)\`>; + + type $ParseDeepVariant = + $ParseDeepVariantValue extends infer Result + ? Result extends [infer Value, string] + ? Value + : Result extends VariantTypeError + ? Result + : VariantTypeError<"$ParseDeepVariantValue returned unexpected Result"> + : VariantTypeError<"$ParseDeepVariantValue returned uninferrable Result">; + + type $ParseRecursiveVariantDict = {}> = + string extends State + ? VariantTypeError<"$ParseRecursiveVariantDict: 'string' is not a supported type."> + : State extends \`}\${infer State}\` + ? [Memo, State] + : State extends \`\${infer Key}\${''}\${infer State}\` + ? $ParseRecursiveVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`}\${infer State}\` + ? [CreateIndexType, State] + : VariantTypeError<\`$ParseRecursiveVariantDict encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseRecursiveVariantValue returned unexpected value for: \${State}\`> + : VariantTypeError<\`$ParseRecursiveVariantDict encountered an invalid variant string: \${State} (2)\`>; + + type $ParseRecursiveVariantArray = + string extends State + ? VariantTypeError<"$ParseRecursiveVariantArray: 'string' is not a supported type."> + : State extends \`)\${infer State}\` + ? [Memo, State] + : $ParseRecursiveVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`\${infer NextValue})\${infer NextState}\` + ? $ParseRecursiveVariantArray + : State extends \`)\${infer State}\` + ? [[...Memo, Value], State] + : VariantTypeError<\`$ParseRecursiveVariantArray encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseRecursiveVariantValue returned unexpected value for: \${State} (2)\`>; + + type $ParseRecursiveVariantKeyValue = + string extends State + ? VariantTypeError<"$ParseRecursiveVariantKeyValue: 'string' is not a supported type."> + : State extends \`}\${infer State}\` + ? [Memo, State] + : State extends \`\${infer Key}\${''}\${infer State}\` + ? $ParseRecursiveVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`}\${infer State}\` + ? [[...Memo, Key, Value], State] + : VariantTypeError<\`$ParseRecursiveVariantKeyValue encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseRecursiveVariantKeyValue returned unexpected value for: \${State}\`> + : VariantTypeError<\`$ParseRecursiveVariantKeyValue encountered an invalid variant string: \${State} (2)\`>; + + type $ParseRecursiveVariantValue = + string extends State + ? unknown + : State extends \`\${\`s\` | \`o\` | \`g\`}\${infer State}\` + ? [string, State] + : State extends \`\${\`n\` | \`q\` | \`t\` | \`d\` | \`u\` | \`i\` | \`x\` | \`y\`}\${infer State}\` + ? [number, State] + : State extends \`b\${infer State}\` + ? [boolean, State] + : State extends \`v\${infer State}\` + ? [unknown, State] + : State extends \`\${'h' | '?'}\${infer State}\` + ? [unknown, State] + : State extends \`(\${infer State}\` + ? $ParseRecursiveVariantArray + : State extends \`a{\${infer State}\` + ? $ParseRecursiveVariantDict + : State extends \`{\${infer State}\` + ? $ParseRecursiveVariantKeyValue + : State extends \`ay\${infer State}\` ? + [Uint8Array, State] + : State extends \`m\${infer State}\` + ? $ParseRecursiveVariantValue extends [infer Value, \`\${infer State}\`] + ? [Value | null, State] + : VariantTypeError<\`$ParseRecursiveVariantValue encountered an invalid variant string: \${State} (3)\`> + : State extends \`a\${infer State}\` ? + $ParseRecursiveVariantValue extends [infer Value, \`\${infer State}\`] ? + [Value[], State] + : VariantTypeError<\`$ParseRecursiveVariantValue encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseRecursiveVariantValue encountered an invalid variant string: \${State} (2)\`>; + + type $ParseRecursiveVariant = + $ParseRecursiveVariantValue extends infer Result + ? Result extends [infer Value, string] + ? Value + : Result extends VariantTypeError + ? Result + : never + : never; + + type $ParseVariantDict = {}> = + string extends State + ? VariantTypeError<"$ParseVariantDict: 'string' is not a supported type."> + : State extends \`}\${infer State}\` + ? [Memo, State] + : State extends \`\${infer Key}\${''}\${infer State}\` + ? $ParseVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`}\${infer State}\` + ? [CreateIndexType>, State] + : VariantTypeError<\`$ParseVariantDict encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseVariantValue returned unexpected value for: \${State}\`> + : VariantTypeError<\`$ParseVariantDict encountered an invalid variant string: \${State} (2)\`>; + + type $ParseVariantArray = + string extends State + ? VariantTypeError<"$ParseVariantArray: 'string' is not a supported type."> + : State extends \`)\${infer State}\` + ? [Memo, State] + : $ParseVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`\${infer NextValue})\${infer NextState}\` + ? $ParseVariantArray]> + : State extends \`)\${infer State}\` + ? [[...Memo, Variant], State] + : VariantTypeError<\`$ParseVariantArray encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseVariantValue returned unexpected value for: \${State} (2)\`>; + + type $ParseVariantKeyValue = + string extends State + ? VariantTypeError<"$ParseVariantKeyValue: 'string' is not a supported type."> + : State extends \`}\${infer State}\` + ? [Memo, State] + : State extends \`\${infer Key}\${''}\${infer State}\` + ? $ParseVariantValue extends [infer Value, \`\${infer State}\`] + ? State extends \`}\${infer State}\` + ? [[...Memo, Variant, Variant], State] + : VariantTypeError<\`$ParseVariantKeyValue encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseVariantKeyValue returned unexpected value for: \${State}\`> + : VariantTypeError<\`$ParseVariantKeyValue encountered an invalid variant string: \${State} (2)\`>; + + type $ParseShallowRootVariantValue = + string extends State + ? unknown + : State extends \`\${\`s\` | \`o\` | \`g\`}\${infer State}\` + ? [string, State] + : State extends \`\${\`n\` | \`q\` | \`t\` | \`d\` | \`u\` | \`i\` | \`x\` | \`y\`}\${infer State}\` + ? [number, State] + : State extends \`b\${infer State}\` + ? [boolean, State] + : State extends \`v\${infer State}\` + ? [Variant, State] + : State extends \`h\${infer State}\` + ? [unknown, State] + : State extends \`?\${infer State}\` + ? [unknown, State] + : State extends \`(\${infer State}\` + ? $ParseVariantArray + : State extends \`a{\${infer State}\` + ? $ParseVariantDict + : State extends \`{\${infer State}\` + ? $ParseVariantKeyValue + : State extends \`ay\${infer State}\` ? + [Uint8Array, State] + : State extends \`m\${infer State}\` + ? $ParseVariantValue extends [infer Value, \`\${infer State}\`] + ? [Value | null, State] + : VariantTypeError<\`$ParseShallowRootVariantValue encountered an invalid variant string: \${State} (2)\`> + : State extends \`a\${infer State}\` ? + [Variant[], State] + : VariantTypeError<\`$ParseShallowRootVariantValue encountered an invalid variant string: \${State} (1)\`>; + + type $ParseVariantValue = + string extends State + ? unknown + : State extends \`s\${infer State}\` + ? ['s', State] + : State extends \`o\${infer State}\` + ? ['o', State] + : State extends \`g\${infer State}\` + ? ['g', State] + : State extends \`n\${infer State}\` + ? ["n", State] + : State extends \`q\${infer State}\` + ? ["q", State] + : State extends \`t\${infer State}\` + ? ["t", State] + : State extends \`d\${infer State}\` + ? ["d", State] + : State extends \`u\${infer State}\` + ? ["u", State] + : State extends \`i\${infer State}\` + ? ["i", State] + : State extends \`x\${infer State}\` + ? ["x", State] + : State extends \`y\${infer State}\` + ? ["y", State] + : State extends \`b\${infer State}\` + ? ['b', State] + : State extends \`v\${infer State}\` + ? ['v', State] + : State extends \`h\${infer State}\` + ? ['h', State] + : State extends \`?\${infer State}\` + ? ['?', State] + : State extends \`(\${infer State}\` + ? $ParseVariantArray + : State extends \`a{\${infer State}\` + ? $ParseVariantDict + : State extends \`{\${infer State}\` + ? $ParseVariantKeyValue + : State extends \`ay\${infer State}\` ? + [Uint8Array, State] + : State extends \`m\${infer State}\` + ? $ParseVariantValue extends [infer Value, \`\${infer State}\`] + ? [Value | null, State] + : VariantTypeError<\`$ParseVariantValue encountered an invalid variant string: \${State} (3)\`> + : State extends \`a\${infer State}\` ? + $ParseVariantValue extends [infer Value, \`\${infer State}\`] ? + [Value[], State] + : VariantTypeError<\`$ParseVariantValue encountered an invalid variant string: \${State} (1)\`> + : VariantTypeError<\`$ParseVariantValue encountered an invalid variant string: \${State} (2)\`>; + + type $ParseVariant = + $ParseShallowRootVariantValue extends infer Result + ? Result extends [infer Value, string] + ? Value + : Result extends VariantTypeError + ? Result + : never + : never; + + type $VariantTypeToString = T extends VariantType ? S : never; + + export class Variant { + static $gtype: GObject.GType; + constructor(sig: S, value: $ParseDeepVariant); + constructor(copy: Variant); + _init(sig: S, value: any): Variant; + // Constructors + static ["new"](sig: S, value: $ParseDeepVariant): Variant; + static _new_internal(sig: S, value: $ParseDeepVariant): Variant; + static new_array( + child_type: VariantType | null, + children: typeof child_type extends VariantType + ? Variant<$VariantTypeToString>[] + : Variant[] + ): Variant<\`a\${C}\`>; + static new_boolean(value: boolean): Variant<'b'>; + static new_byte(value: number): Variant<'y'>; + static new_bytestring(string: Uint8Array | string): Variant<'ay'>; + static new_bytestring_array(strv: string[]): Variant<'aay'>; + static new_dict_entry(key: Variant, value: Variant): Variant<'{vv}'>; + static new_double(value: number): Variant<'d'>; + static new_fixed_array(element_type: VariantType, elements: Variant<$VariantTypeToString>[] | null, n_elements: number, element_size: number): Variant<\`a\${C}\`>; + static new_from_bytes(type: VariantType, bytes: Bytes | Uint8Array, trusted: boolean): Variant; + static new_from_data(type: VariantType, data: Uint8Array | string, trusted: boolean, user_data?: any | null): Variant; + static new_handle(value: number): Variant<'h'>; + static new_int16(value: number): Variant<'n'>; + static new_int32(value: number): Variant<'i'>; + static new_int64(value: number): Variant<'x'>; + static new_maybe(child_type?: VariantType | null, child?: Variant | null): Variant<'mv'>; + static new_object_path(object_path: string): Variant<'o'>; + static new_objv(strv: string[]): Variant<'ao'>; + static new_signature(signature: string): Variant<'g'>; + static new_string(string: string): Variant<'s'>; + static new_strv(strv: string[]): Variant<'as'>; + static new_tuple | readonly [VariantType])>(children: Items): Variant<\`(\${$ToTuple})\`>; + static new_uint16(value: number): Variant<'q'>; + static new_uint32(value: number): Variant<'u'>; + static new_uint64(value: number): Variant<'t'>; + static new_variant(value: Variant): Variant<'v'>; + // Members + byteswap(): Variant; + check_format_string(format_string: string, copy_only: boolean): boolean; + classify(): VariantClass; + compare(two: Variant): number; + dup_bytestring(): Uint8Array; + dup_bytestring_array(): string[]; + dup_objv(): string[]; + dup_string(): [string, number]; + dup_strv(): string[]; + equal(two: Variant): boolean; + get_boolean(): boolean; + get_byte(): number; + get_bytestring(): Uint8Array; + get_bytestring_array(): string[]; + get_child_value(index_: number): Variant; + get_data(): any | null; + get_data_as_bytes(): Bytes; + get_double(): number; + get_handle(): number; + get_int16(): number; + get_int32(): number; + get_int64(): number; + get_maybe(): Variant | null; + get_normal_form(): Variant; + get_objv(): string[]; + get_size(): number; + get_string(): [string, number | null]; + get_strv(): string[]; + get_type(): VariantType; + get_type_string(): string; + get_uint16(): number; + get_uint32(): number; + get_uint64(): number; + get_variant(): Variant; + hash(): number; + is_container(): boolean; + is_floating(): boolean; + is_normal_form(): boolean; + is_of_type(type: VariantType): boolean; + lookup_value(key: string, expected_type?: VariantType | null): Variant; + n_children(): number; + print(type_annotate: boolean): string; + ref(): Variant; + ref_sink(): Variant; + store(data: any): void; + take_ref(): Variant; + unref(): void; + static is_object_path(string: string): boolean; + static is_signature(string: string): boolean; + static parse(type: VariantType | null, text: string, limit?: string | null, endptr?: string | null): Variant; + static parse_error_print_context(error: Error, source_str: string): string; + static parse_error_quark(): Quark; + static parser_get_error_quark(): Quark; + unpack(): $ParseVariant; + deepUnpack(): $ParseDeepVariant; + deep_unpack(): $ParseDeepVariant; + recursiveUnpack(): $ParseRecursiveVariant; + } + + type $ElementSig = + E extends [infer Element] ? Element : + E extends [infer Element, ...infer Elements] ? Element | $ElementSig : + E extends globalThis.Array ? Element : never; + + export class VariantBuilder { + static $gtype: GObject.GType; + constructor(type: VariantType); + constructor(copy: VariantBuilder); + // Constructors + static ["new"](type: VariantType): VariantBuilder; + // Members + add_value(value: $ElementSig<$ParseDeepVariant>): void; + close(): void; + end(): Variant; + open(type: VariantType): void; + ref(): VariantBuilder; + unref(): void; + } + + export class VariantDict { + static $gtype: GObject.GType; + constructor(from_asv?: Variant | null); + constructor(copy: VariantDict); + // Constructors + static ["new"](from_asv?: Variant | null): VariantDict; + // Members + clear(): void; + contains(key: string): boolean; + end(): Variant; + insert_value(key: string, value: Variant): void; + lookup_value(key: string, expected_type?: VariantType | null): Variant; + ref(): VariantDict; + remove(key: string): boolean; + unref(): void; + lookup(key: any, variantType?: any, deep?: boolean): any; + } + + type $ToTuple = + T extends [] ? '' : + T extends [VariantType] ? \`\${S}\` : + T extends [VariantType, ...infer U] ? ( + U extends [...VariantType[]] ? \`\${S}\${$ToTuple}\` : never) : + '?'; + + export class VariantType { + static $gtype: GObject.GType; + constructor(type_string: S); + constructor(copy: VariantType); + // Constructors + static ["new"](type_string: S): VariantType; + static new_array(element: VariantType): VariantType<\`a\${S}\`>; + static new_dict_entry(key: VariantType, value: VariantType): VariantType<\`{\${K}\${V}}\`>; + static new_maybe(element: VariantType): VariantType<\`m\${S}\`>; + static new_tuple | readonly [VariantType])>(items: Items): VariantType<\`(\${$ToTuple})\`>; + // Members + copy(): VariantType; + dup_string(): string; + element(): VariantType; + equal(type2: VariantType): boolean; + first(): VariantType; + free(): void; + get_string_length(): number; + hash(): number; + is_array(): boolean; + is_basic(): boolean; + is_container(): boolean; + is_definite(): boolean; + is_dict_entry(): boolean; + is_maybe(): boolean; + is_subtype_of(supertype: VariantType): boolean; + is_tuple(): boolean; + is_variant(): boolean; + key(): VariantType; + n_items(): number; + next(): VariantType; + value(): VariantType; + static checked_(arg0: string): VariantType; + static string_get_depth_(type_string: string): number; + static string_is_valid(type_string: string): boolean; + static string_scan(string: string, limit?: string | null): [boolean, string | null]; + } + `; +} diff --git a/packages/lib/src/newlib/generators/dts/gobject.ts b/packages/lib/src/newlib/generators/dts/gobject.ts new file mode 100644 index 000000000..205b168c0 --- /dev/null +++ b/packages/lib/src/newlib/generators/dts/gobject.ts @@ -0,0 +1,202 @@ +import { Direction } from "@gi.ts/parser"; +import { NativeType, NeverType } from "../../gir.js"; +import { GirClassFunction, GirFunctionParameter } from "../../gir/function.js"; +import { GirNamespace } from "../../gir/namespace.js"; + +export function override(node: GirNamespace) { + const ParamSpec = node.assertClass("ParamSpec"); + + // We only inject __type__ for .d.ts files. + const type_function = new GirClassFunction({ + name: "__type__", + parent: ParamSpec, + parameters: [ + new GirFunctionParameter({ + name: "arg", + type: NeverType, + direction: Direction.In + }) + ], + return_type: new NativeType("A") + // TODO: Add support for generic native type replacement. + // return_type: UnknownType + }); + + ParamSpec.members.push(type_function.copy()); + + return ` +// GJS OVERRIDES + +// __type__ forces all GTypes to not match structurally. + +export type GType = { __type__(arg: never): T }; + +// Correctly types interface checks. +export function type_is_a(obj: Object, is_a_type: { $gtype: GType }): obj is T; + +export class Interface { + static _classInit: (klass: any) => any; + __name__: string; + _construct: (params: any, ...otherArgs: any[]) => any; + _init: (params: any) => void; + $gtype?: GType; +} + +export function signal_connect(object: Object, name: string, handler: Function): number; +export function signal_connect_after(object: Object, name: string, handler: Function): number; +export function signal_emit_by_name(object: Object, name: string, ...args: any[]): void; + +export const __gtkCssName__: unique symbol; +export const __gtkTemplate__: unique symbol; +export const __gtkChildren__: unique symbol; +export const __gtkInternalChildren__: unique symbol; + +// Expose GObject static properties for ES6 classes + +export const GTypeName: unique symbol; +export const requires: unique symbol; +export const interfaces: unique symbol; +export const properties: unique symbol; +export const signals: unique symbol; + +export enum AccumulatorType { + NONE, + FIRST_WINS, + TRUE_HANDLED +} + +export class NotImplementedError extends Error { +} + +export let gtypeNameBasedOnJSPath: boolean; + +export let TYPE_BOOLEAN: GType; +export let Boolean: BooleanConstructor; + +export let TYPE_ENUM: GType; +export let TYPE_FLAGS: GType; + +export let TYPE_DOUBLE: GType; +export let Double: NumberConstructor; + +export let TYPE_STRING: GType; +export let String: StringConstructor; + +declare global { + interface BooleanConstructor { + $gtype: GType; + } + + interface NumberConstructor { + $gtype: GType; + } + + interface StringConstructor { + $gtype: GType; + } +} + +export let TYPE_NONE: GType; +export let TYPE_POINTER: GType; +export let TYPE_BOXED: GType; +export let TYPE_PARAM: GType; +export let TYPE_INTERFACE: GType; +export let TYPE_OBJECT: GType; +export let TYPE_VARIANT: GType; +export let TYPE_INT: GType; +export let TYPE_UINT: GType; +export let TYPE_INT64: GType; +export let TYPE_UINT64: GType; + +export function registerClass< + P extends {}, + T extends new (...args: any[]) => P, + >( + klass: T + ): RegisteredClass; + +export type Property = K extends ParamSpec + ? T + : any; + +export type Properties< + Prototype extends {}, + Properties extends { [key: string]: ParamSpec } + > = Omit<{ + [key in (keyof Properties | keyof Prototype)]: key extends keyof Prototype ? never : + key extends keyof Properties ? Property : never; + }, keyof Prototype>; + +export type SignalDefinition = { + param_types?: readonly GType[]; + [key: string]: any; +}; + +type UnionToIntersection = + (T extends any ? (x: T) => any : never) extends + (x: infer R) => any ? R : never + +type IFaces }[]> = { [key in keyof Interfaces]: Interfaces[key] extends { $gtype: GType } ? I : never }; + +export type RegisteredPrototype

= + Properties & SnakeToUnderscore> & UnionToIntersection & P; + +type SnakeToUnderscoreCase = + S extends \`\${infer T}-\${infer U}\` ? \`\${T}_\${SnakeToUnderscoreCase}\` : + S extends \`\${infer T}\` ? \`\${T}\` : + never; + +type SnakeToCamelCase = + S extends \`\${infer T}-\${infer U}\` ? \`\${Lowercase}\${SnakeToPascalCase}\` : + S extends \`\${infer T}\` ? \`\${Lowercase}\` : + SnakeToPascalCase; + +type SnakeToPascalCase = + string extends S ? string : + S extends \`\${infer T}-\${infer U}\` ? \`\${Capitalize>}\${SnakeToPascalCase}\` : + S extends \`\${infer T}\` ? \`\${Capitalize>}\` : + never; + +type SnakeToCamel = { [P in keyof T as P extends string ? SnakeToCamelCase

: P]: T[P] }; +type SnakeToUnderscore = { [P in keyof T as P extends string ? SnakeToUnderscoreCase

: P]: T[P] }; + +type Ctor = new (...a: any[]) => object; + +type Init = { _init(...args: any[]): void }; + +export type RegisteredClass< + T extends Ctor, + Props extends { [key: string]: ParamSpec }, + Interfaces extends { $gtype: GType }[] + > = T extends { prototype: infer P } ? { + $gtype: GType>>; + new(...args: P extends Init ? Parameters : [void]): RegisteredPrototype>; + prototype: RegisteredPrototype>; + } : never; + +export function registerClass< + T extends Ctor, + Props extends { [key: string]: ParamSpec }, + Interfaces extends { $gtype: GType }[], + Sigs extends { + [key: string]: { + param_types?: readonly GType[]; + [key: string]: any; + } + } +>( + options: { + GTypeName?: string; + GTypeFlags?: TypeFlags; + Properties?: Props; + Signals?: Sigs; + Implements?: Interfaces; + CssName?: string; + Template?: string; + Children?: string[]; + InternalChildren?: string[]; + }, + klass: T +): RegisteredClass; +`; +} diff --git a/packages/lib/src/newlib/generators/generator.ts b/packages/lib/src/newlib/generators/generator.ts new file mode 100644 index 000000000..5da95ebfc --- /dev/null +++ b/packages/lib/src/newlib/generators/generator.ts @@ -0,0 +1,52 @@ +import { GirNamespace } from "../gir/namespace.js"; +import { GirClass, GirRecord, GirInterface } from "../gir/class.js"; +import { GirConst } from "../gir/const.js"; +import { GirEnum, GirError, GirEnumMember } from "../gir/enum.js"; +import { GirProperty, GirField } from "../gir/property.js"; +import { GirSignal, GirSignalType } from "../gir/signal.js"; +import { GirFunction, GirFunctionParameter, GirConstructor, GirCallback, GirDirectAllocationConstructor } from "../gir/function.js"; +import { GirClassFunction } from "../gir/function.js"; +import { GirStaticClassFunction } from "../gir/function.js"; +import { GirVirtualClassFunction } from "../gir/function.js"; +import { GirAlias } from "../gir/alias.js"; +import { TypeExpression } from "../gir.js"; +import { GenerationOptions } from "../types.js"; + +export interface GenericDescriptor { + type: TypeExpression; + name: string; +} + +export abstract class FormatGenerator { + protected namespace: GirNamespace; + protected options: GenerationOptions; + + constructor(namespace: GirNamespace, options: GenerationOptions) { + this.namespace = namespace; + this.options = options; + } + + abstract generateNamespace(node: GirNamespace): Promise; + abstract stringifyNamespace(node: GirNamespace): Promise; + + abstract generateCallback(node: GirCallback): T; + abstract generateAlias(node: GirAlias): T; + abstract generateConstructor(node: GirConstructor): T; + abstract generateDirectAllocationConstructor(node: GirDirectAllocationConstructor): T; + abstract generateConstructorFunction(node: GirConstructor): T; + abstract generateRecord(node: GirRecord): T; + abstract generateInterface(node: GirInterface): T; + abstract generateEnumMember(node: GirEnumMember): T; + abstract generateError(node: GirError): T; + abstract generateEnum(node: GirEnum): T; + abstract generateConst(node: GirConst): T; + abstract generateClass(node: GirClass): T; + abstract generateParameter(node: GirFunctionParameter): T; + abstract generateProperty(node: GirProperty, construct?: boolean): T; + abstract generateField(node: GirField): T; + abstract generateSignal(node: GirSignal, type?: GirSignalType): T; + abstract generateFunction(node: GirFunction): T; + abstract generateClassFunction(node: GirClassFunction): T; + abstract generateStaticClassFunction(node: GirStaticClassFunction): T; + abstract generateVirtualClassFunction(node: GirVirtualClassFunction): T; +} diff --git a/packages/lib/src/newlib/generators/index.ts b/packages/lib/src/newlib/generators/index.ts new file mode 100644 index 000000000..64e8900b0 --- /dev/null +++ b/packages/lib/src/newlib/generators/index.ts @@ -0,0 +1,6 @@ +export * from "./generator.js"; + +export { JsonGenerator } from "./json.js"; +export { DtsModuleGenerator as DtsGenerator } from "./dts-modules.js"; +export { DtsInlineGenerator } from './dts-inline.js'; +export { DtsGenerator as DtsAbstractGenerator } from './dts.js'; \ No newline at end of file diff --git a/packages/lib/src/newlib/generators/json.ts b/packages/lib/src/newlib/generators/json.ts new file mode 100644 index 000000000..21ea40403 --- /dev/null +++ b/packages/lib/src/newlib/generators/json.ts @@ -0,0 +1,1294 @@ +import { FormatGenerator } from "./generator.js"; +import { GirNamespace } from "../gir/namespace.js"; + +import { GirBaseClass, GirRecord, GirInterface, GirClass } from "../gir/class.js"; +import { GirConst } from "../gir/const.js"; +import { GirEnum, GirError, GirEnumMember } from "../gir/enum.js"; +import { GirProperty, GirField } from "../gir/property.js"; +import { GirSignal, GirSignalType } from "../gir/signal.js"; +import { + GirFunction, + GirConstructor, + GirFunctionParameter, + GirCallback, + GirDirectAllocationConstructor +} from "../gir/function.js"; +import { GirClassFunction, GirStaticClassFunction, GirVirtualClassFunction } from "../gir/function.js"; +import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js"; +import { + TypeExpression, + NativeType, + AnyType, + VoidType, + StringType, + NumberType, + ArrayType, + TypeIdentifier, + OrType, + TupleType, + NullableType, + ClosureType, + GirBase, + AnyFunctionType, + TypeConflict, + GirMetadata +} from "../gir.js"; +import { Direction } from "@gi.ts/parser"; +import { GirAlias } from "../gir/alias.js"; +import { GenerationOptions } from "../types.js"; + +export const enum NodeKind { + class = "class", + interface = "interface", + function = "function", + classFunction = "class_function", + staticClassFunction = "static_class_function", + virtualClassFunction = "virtual_class_function", + prop = "prop", + field = "field", + alias = "alias", + namespace = "namespace", + callback = "callback", + constant = "constant", + record = "record", + constructor = "constructor", + propertiesConstructor = "properties_constructor", + parameter = "parameter", + enum = "enum", + enumMember = "enum_member", + error = "error" +} + +export type Primitive = string[] | number[] | boolean[] | null | string | number | boolean; +export type Json = { + [key: string]: Primitive | Json | Json[]; +}; +export type NodeJson = { + kind: NodeKind; + doc: string | null; + metadata: MetadataJson | null; + private: boolean; +} & Json; + +export const enum TypeKind { + or = "or", + tuple = "tuple", + identifier = "identifier", + native = "native", + array = "array", + nulled = "null", + closure = "closure" +} + +function generateType(type: TypeExpression): TypeJson { + if (type instanceof TypeIdentifier) { + return { + kind: TypeKind.identifier, + name: type.name, + namespace: type.namespace + }; + } else if (type instanceof NativeType) { + return { + kind: TypeKind.native, + type: type.expression() + }; + } else if (type instanceof ClosureType) { + return { + kind: TypeKind.closure, + type: generateType(type.type), + user_data: type.user_data + }; + } else if (type instanceof ArrayType) { + return { + kind: TypeKind.array, + type: generateType(type.type), + depth: type.arrayDepth + }; + } else if (type instanceof NullableType) { + return { + kind: TypeKind.nulled, + type: generateType(type.type) + }; + } else if (type instanceof TypeConflict) { + // Type conflicts aren't considered in JSON outputs. + return generateType(type.type); + } else if (type instanceof TupleType) { + return { + kind: TypeKind.tuple, + types: type.types.map(t => generateType(t)) + }; + } else if (type instanceof OrType) { + return { + kind: TypeKind.or, + types: type.types.map(t => generateType(t)) + }; + } else { + return { + kind: TypeKind.native, + type: "any" + }; + } +} + +function capitalize(str: string) { + if (str.length === 0) { + return ""; + } + + if (str.length === 1) { + return str[0].toUpperCase(); + } + + return str[0].toUpperCase() + str.substring(1).toLowerCase(); +} + +export interface ParameterJson extends NodeJson { + kind: NodeKind.parameter; + optional: boolean; + varargs: boolean; + name: string; + type: TypeJson; +} + +export type TypeJson = Json & + ( + | { + kind: TypeKind.native; + type: string; + } + | { + kind: TypeKind.array; + depth: number; + type: TypeJson; + } + | { + kind: TypeKind.or | TypeKind.tuple; + types: TypeJson[]; + } + | { + kind: TypeKind.nulled; + type: TypeJson; + } + | { + kind: TypeKind.closure; + user_data: number | null; + type: TypeJson; + } + | { + kind: TypeKind.identifier; + namespace: string; + name: string; + } + ); +export interface EnumMemberJson extends NodeJson { + kind: NodeKind.enumMember; + name: string; + value: string | null; +} + +export interface EnumJson extends NodeJson { + kind: NodeKind.enum; + name: string; + members: EnumMemberJson[]; +} +export interface CallbackJson extends NodeJson { + kind: NodeKind.callback; + name: string; + type: [Json, Json]; + parameters: ParameterJson[]; + returnType: TypeJson; +} +export interface PropertyJson extends NodeJson { + kind: NodeKind.prop; + name: string; + type: TypeJson; +} +export interface FieldJson extends NodeJson { + kind: NodeKind.field; + name: string; + type: TypeJson; +} + +export interface MethodJson extends NodeJson { + kind: NodeKind.classFunction; + name: string; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; +} + +export interface StaticMethodJson extends NodeJson { + kind: NodeKind.staticClassFunction; + name: string; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; +} +export interface VirtualMethodJson extends NodeJson { + kind: NodeKind.virtualClassFunction; + name: string; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; +} +export interface MetadataJson extends Json {} +export interface ConstJson extends NodeJson { + kind: NodeKind.constant; + name: string; + type: TypeJson; +} + +export interface InterfaceJson extends NodeJson { + kind: NodeKind.interface; + name: string; + extends: TypeJson | null; + type: TypeJson; + props: PropertyJson[]; + methods: MethodJson[]; + staticMethods: StaticMethodJson[]; + virtualMethods: VirtualMethodJson[]; +} + +export interface BaseClassJson extends NodeJson { + name: string; + type: TypeJson; + constructors: MethodJson[]; + mainConstructor: PropertiesConstructorJson | ConstructorJson | null; + extends: TypeJson | null; + implements: TypeJson[]; + props: PropertyJson[]; + fields: FieldJson[]; + methods: MethodJson[]; + staticMethods: StaticMethodJson[]; + virtualMethods: VirtualMethodJson[]; +} + +export interface ClassJson extends BaseClassJson { + kind: NodeKind.class; + abstract: boolean; +} + +export interface RecordJson extends BaseClassJson { + kind: NodeKind.record; + mainConstructor: ConstructorJson | null; +} + +export interface ErrorJson extends BaseClassJson { + kind: NodeKind.error; + mainConstructor: ConstructorJson | null; +} + +export interface FunctionJson extends NodeJson { + name: string; + kind: NodeKind.function; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; +} + +export interface AliasJson extends NodeJson { + name: string; + kind: NodeKind.alias; + type: TypeJson; +} + +export interface PropertiesConstructorJson extends NodeJson { + name: string; + kind: NodeKind.propertiesConstructor; + properties: ParameterJson[]; +} + +export interface ConstructorJson extends NodeJson { + name: string; + kind: NodeKind.constructor; + parameters: ParameterJson[]; +} + +export type ImportsJson = { [lib: string]: string }; + +export interface NamespaceJson extends Json { + kind: NodeKind.namespace; + imports: ImportsJson; + version: string; + name: string; + alias: AliasJson[]; + enums: EnumJson[]; + errors: ErrorJson[]; + functions: FunctionJson[]; + callbacks: CallbackJson[]; + constants: ConstJson[]; + records: RecordJson[]; + interfaces: InterfaceJson[]; + classes: ClassJson[]; +} + +export class JsonGenerator extends FormatGenerator { + constructor(namespace: GirNamespace, options: GenerationOptions) { + super(namespace, options); + } + + /** + * Intelligently reformats # and () references + * to handle c-prefixes and namespacing. + * + * @param doc + */ + private generateDoc(doc: string): string { + const { namespace } = this; + + function resolveClass(ns: GirNamespace, className: string): readonly [GirBase | null, boolean] { + let classes = ns.getMembers(className); + + let plural = false; + + if (classes.length === 0 && className.endsWith("Class")) { + classes = ns.getMembers(className.slice(0, -5)); + } + + if (classes.length === 0 && className.endsWith("Iface")) { + classes = ns.getMembers(className.slice(0, -5)); + } + + if (classes.length === 0 && className.endsWith("Interface")) { + classes = ns.getMembers(className.slice(0, -9)); + } + + if (classes.length === 0 && className.endsWith("s")) { + plural = true; + classes = ns.getMembers(className.slice(0, -1)); + } + + return [classes[0] ?? null, plural] as const; + } + + function formatReference(identifier: string, member_name: string, punc?: string): string | null { + const parts = identifier + .split(/([A-Z])/) + .filter(p => p != "") + .reduce((prev, next) => { + if (next.toUpperCase() === next) { + prev.push(`${next}`); + } else { + const lastCapital = prev.pop(); + + prev.push(`${lastCapital}${next}`); + } + + return prev; + }, [] as string[]); + + let [base_part] = parts; + + const [, , namespaces, className] = parts.slice(1).reduce( + ([underscore, camel, ns, selected], next) => { + const next_underscore = [underscore, next.toLowerCase()].join("_"); + + const namespaces = namespace.getImportsForCPrefix(next_underscore); + const nextCamel = camel + capitalize(next); + + if (namespaces.length > 0) { + return [next_underscore, nextCamel, namespaces, capitalize(next)] as const; + } + + return [next_underscore, nextCamel, ns, selected + capitalize(next)] as const; + }, + [ + base_part.toLowerCase(), + capitalize(base_part), + namespace.getImportsForCPrefix(base_part.toLowerCase()), + "" + ] as const + ); + + let ns = namespaces.find(n => n.hasSymbol(className)); + + if (!ns) { + ns = namespaces.find(n => { + const [c] = resolveClass(n, className); + + return c != null; + }); + } + + if (ns) { + const is_prop = punc === ":"; + const modified_name = is_prop ? member_name.replace(/[\-]/g, "_") : member_name; + + let [clazz, plural] = resolveClass(ns, className); + + if (clazz instanceof GirBaseClass || clazz instanceof GirEnum) { + const r = `#${plural ? "{" : ""}${ns.name}.${clazz.name}${punc ? `${punc}${modified_name}` : ""}${ + plural ? "}s" : "" + }`; + return r; + } + + return `#${ns.name}${punc ? ` (${punc}${modified_name})` : ""}`; + } else { + return null; + } + } + + function formatFunctionReference(func: string, upper = false): string | null { + // namespace_class_do_thing() + + const parts = func.toLowerCase().split("_"); + + // ['namespace', 'class', 'do', 'thing'] + + const [base_part] = parts; + + // ['namespace'] + + const namespaceBase = [ + base_part.toLowerCase(), + capitalize(base_part), + namespace.getImportsForCPrefix(base_part.toLowerCase()), + 0 + ] as const; + + // ['namespace', 'Namespace', { Namespace }, -1] + + const [, , namespaces, i] = parts + .slice(1) + .reduce(([prev, camel, currentNamespaces, selected], next, i) => { + const underscore = [prev, next.toLowerCase()].join("_"); + const namespaces = namespace.getImportsForCPrefix(underscore); + const identifier = camel + capitalize(next); + + // We've found namespace(s) which matches the c_prefix + if (namespaces.length > 0) { + return [underscore, identifier, namespaces, i] as const; + } + + return [underscore, identifier, currentNamespaces, selected] as const; + }, namespaceBase); + + // If no namespaces are found for the function's c_prefix, we return the original reference. + if (namespaces.length === 0) { + return null; + } + + // ['class', 'do', 'thing'] + + const nameParts = parts.slice(i + 1); + + // 'class_do_thing' + + const functionName = nameParts.join("_"); + const functionNamespace = namespaces.find(n => n.hasSymbol(functionName.toLowerCase())); + const constNamespace = namespaces.find(n => n.hasSymbol(functionName.toUpperCase())); + const enumNamespace = namespaces.find(n => n.enum_constants.has(func.toUpperCase())); + + if (functionNamespace) { + const [member = null] = functionNamespace.getMembers(functionName.toLowerCase()); + + if (member instanceof GirFunction) { + return `${functionNamespace.name}.${member.name}`; + } + + return null; + } else if (constNamespace) { + const [member = null] = constNamespace.getMembers(functionName.toUpperCase()); + + if (member instanceof GirConst) { + return `${constNamespace.name}.${member.name}`; + } + + return null; + } else if (enumNamespace) { + const constantInfo = enumNamespace.enum_constants.get(func.toUpperCase()); + + if (constantInfo) { + const [enumName, memberName] = constantInfo; + + const [klass = null] = enumNamespace.getMembers(enumName); + + if (klass instanceof GirEnum) { + return `${enumNamespace.name}.${klass.name}.${memberName.toUpperCase()}`; + } + } + + return null; + } else { + // ['class', 'do', 'thing'] + + const { selectedClassName, resolvedNamespace, selectedIndex } = parts.slice(i + 1).reduce( + ({ className, selectedClassName, resolvedNamespace, selectedIndex }, next, i) => { + // Class + const identifier = `${className}${capitalize(next)}`; + + const withSymbol = namespaces.find(n => n.hasSymbol(identifier)); + + if (withSymbol) { + // { className: Class, resolvedNamespace: {Namespace}, selectedIndex: 0 } + return { + className: identifier, + selectedClassName: identifier, + resolvedNamespace: withSymbol, + selectedIndex: i + } as const; + } + + return { className: identifier, selectedClassName, resolvedNamespace, selectedIndex } as const; + }, + { + className: "" as string, + selectedClassName: "" as string, + resolvedNamespace: null as GirNamespace | null, + selectedIndex: -1 + } + ); + + if (resolvedNamespace && selectedIndex >= 0) { + const nextIndex = i + selectedIndex + 1 /* (slice omits first index) */ + 1; /* (the next index) */ + const functionName = parts.slice(nextIndex).join("_"); + + let [klass] = resolveClass(resolvedNamespace, selectedClassName); + + if (klass instanceof GirBaseClass || klass instanceof GirEnum) { + return `${resolvedNamespace.name}.${klass.name}.${ + upper ? functionName.toUpperCase() : functionName + }`; + } + + return `${resolvedNamespace.name}.${selectedClassName}.${ + upper ? functionName.toUpperCase() : functionName + }`; + } + } + + return null; + } + + return `${doc}` + .replace( + /[#]{0,1}([A-Z][A-z]+)\.([a-z_]+)\(\)/g, + (original, identifier: string, member_name: string) => { + const resolved = formatReference(identifier, member_name, "."); + return resolved != null ? `${resolved}()` : original; + } + ) + .replace( + /#([A-Z][A-z]*)(([:]{1,2})([a-z\-]+)){0,1}/g, + (original, identifier: string, _: string, punc: string, member_name: string) => { + const resolved = formatReference(identifier, member_name, punc); + return resolved != null ? resolved : original; + } + ) + .replace( + /([A-Z][A-z]*)(([:]{1,2})([a-z\-]+))/g, + (original, identifier: string, _: string, punc: string, member_name: string) => { + const resolved = formatReference(identifier, member_name, punc); + return resolved != null ? resolved : original; + } + ) + .replace(/(\s)([a-z_]+)\(\)/g, (original: string, w: string, func: string) => { + const resolved = formatFunctionReference(func); + return resolved != null ? `${w}${resolved}()` : original; + }) + .replace(/%([A-Z_]+)/g, (original: string, identifier: string) => { + const resolved = formatFunctionReference(identifier.toLowerCase(), true); + return resolved != null ? `%${resolved}` : original; + }) + .replace(/#([A-Z_]+)/g, (original: string, identifier: string) => { + const resolved = formatFunctionReference(identifier.toLowerCase(), true); + return resolved != null ? `#${resolved}` : original; + }); + } + + private generateMetadata(metadata: GirMetadata): MetadataJson { + return { ...metadata } as MetadataJson; + } + + private generateParameters(parameters: GirFunctionParameter[]): ParameterJson[] { + const { namespace, options } = this; + + return parameters.map(p => ({ + kind: NodeKind.parameter, + direction: p.direction, + optional: p.isOptional, + varargs: p.isVarArgs, + name: p.name, + resoleNames: p.resolve_names, + type: generateType(p.type.resolve(namespace, options)), + ...this._generateDocAndMetadata(p) + })); + } + + generateCallbackType(node: GirCallback): [Json, Json] { + return [{}, {}]; + } + + generateCallback(node: GirCallback): CallbackJson { + const { namespace, options } = this; + + const parameters = this.generateParameters(node.parameters); + + return { + kind: NodeKind.callback, + name: node.name, + type: this.generateCallbackType(node), + parameters, + returnType: generateType(node.return().resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } + + generateReturn( + return_type: TypeExpression, + output_parameters: GirFunctionParameter[] + ): TypeJson | TypeJson[] { + const { namespace, options } = this; + const type = return_type.resolve(namespace, options); + + if (output_parameters.length > 0) { + const exclude_first = type.equals(VoidType); + const returns = [ + ...(exclude_first ? [] : [type]), + ...output_parameters.map(op => op.type.resolve(namespace, options)) + ]; + + return returns.map(r => generateType(r)); + } + + return generateType(type); + } + + generateEnum(node: GirEnum): EnumJson { + return { + kind: NodeKind.enum, + name: node.name, + members: Array.from(node.members.values()).map(member => member.asString(this)), + ...this._generateDocAndMetadata(node) + }; + } + + generateError(node: GirError): ErrorJson { + const { namespace } = this; + const clazz = node.asClass(); + + clazz.members = []; + clazz.members.push(...Array.from(node.functions.values())); + + const GLib = namespace.assertInstalledImport("GLib"); + const GLibError = GLib.assertClass("Error"); + + clazz.parent = GLibError.getType(); + + // Manually construct a GLib.Error constructor. + clazz.mainConstructor = new GirConstructor({ + name: "new", + parameters: [ + new GirFunctionParameter({ + name: "options", + type: NativeType.of("{ message: string, code: number}"), + direction: Direction.In + }) + ], + return_type: clazz.getType() + }); + + return { + ...clazz.asString(this), + kind: NodeKind.error + }; + } + + _generateDocAndMetadata(node: GirBase) { + const { options } = this; + + if (options.withDocs) { + return { + private: node.isPrivate, + doc: this.generateDoc(node.doc ?? "") ?? null, + metadata: this.generateMetadata(node.metadata ?? {}) ?? null + }; + } + + return { + private: false, + doc: null, + metadata: null + }; + } + + generateConst(node: GirConst): ConstJson { + const { namespace, options } = this; + + return { + kind: NodeKind.constant, + name: node.name, + type: generateType(node.type.resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } + + private implements(node: GirClass): TypeIdentifier[] { + const { namespace, options } = this; + + if (node.interfaces.length > 0) { + return node.interfaces + .map(i => i.resolveIdentifier(namespace, options)) + .filter((i): i is TypeIdentifier => i != null); + } + + return []; + } + + private extends(node: GirBaseClass): TypeIdentifier | null { + const { namespace: ns, options } = this; + + if (node.parent) { + return node.parent.resolveIdentifier(ns, options); + } + + return null; + } + + generateInterface(node: GirInterface): InterfaceJson { + const { namespace } = this; + // If an interface does not list a prerequisite type, we fill it with GObject.Object + if (node.parent == null) { + const gobject = namespace.assertInstalledImport("GObject"); + + // TODO Optimize GObject.Object + if (!gobject) { + throw new Error("GObject not generated, all interfaces extend from GObject.Object!"); + } + + const GObject = gobject.getClass("Object"); + + if (!GObject) { + throw new Error( + `GObject.Object could not be found while generating ${node.namespace.name}.${node.name}` + ); + } + + node.parent = GObject.getType(); + } + + const { name } = node; + + const Extends = this.extends(node); + + const Properties = node.props.map(v => v && v.asString(this)); + + const Methods = node.members + .filter(m => !(m instanceof GirStaticClassFunction) && !(m instanceof GirVirtualClassFunction)) + .map(v => v && v.asString(this)); + const StaticMethods = node.members + .filter((m): m is GirStaticClassFunction => m instanceof GirStaticClassFunction) + .map(v => v && v.asString(this)); + const VirtualMethods = node.members + .filter((m): m is GirVirtualClassFunction => m instanceof GirVirtualClassFunction) + .map(v => v && v.asString(this)); + + return { + kind: NodeKind.interface, + name, + type: generateType(node.getType()), + extends: Extends ? generateType(Extends) : null, + props: Properties, + methods: Methods, + staticMethods: StaticMethods, + virtualMethods: VirtualMethods, + ...this._generateDocAndMetadata(node) + }; + } + + generateRecord(node: GirRecord): RecordJson { + const { name } = node; + + const Extends = this.extends(node); + + const Properties = node.props.map(v => v && v.asString(this)); + + const Fields = node.fields.map(v => v && v.asString(this)); + + const Constructors = node.constructors.map(v => v && this.generateConstructorFunction(v)); + + const Methods = node.members + .filter(m => !(m instanceof GirStaticClassFunction) && !(m instanceof GirVirtualClassFunction)) + .map(v => v && v.asString(this)); + const StaticMethods = node.members + .filter((m): m is GirStaticClassFunction => m instanceof GirStaticClassFunction) + .map(v => v && v.asString(this)); + const VirtualMethods = node.members + .filter((m): m is GirVirtualClassFunction => m instanceof GirVirtualClassFunction) + .map(v => v && v.asString(this)); + + const Callbacks = node.callbacks.map(c => c && c.asString(this)); + + return { + kind: NodeKind.record, + name, + type: generateType(node.getType()), + mainConstructor: node.mainConstructor?.asString(this) ?? null, + extends: Extends ? generateType(Extends) : null, + implements: [], + props: Properties, + fields: Fields, + constructors: Constructors, + methods: Methods, + staticMethods: StaticMethods, + virtualMethods: VirtualMethods, + callbacks: Callbacks, + ...this._generateDocAndMetadata(node) + }; + } + + generateClass(node: GirClass): ClassJson { + const Extends = this.extends(node); + const Implements = this.implements(node); + + let MainConstructor: PropertiesConstructorJson | ConstructorJson | null = null; + + const ConstructorProps = node.props.map(v => this.generateProperty(v, true)); + + if (node.mainConstructor) { + MainConstructor = this.generateConstructor(node.mainConstructor); + } else { + MainConstructor = { + kind: NodeKind.propertiesConstructor, + name: "new", + private: false, + properties: ConstructorProps.map(p => ({ + kind: NodeKind.parameter, + private: p.private, + varargs: false, + name: p.name, + type: p.type, + doc: p.doc, + metadata: p.metadata, + optional: true + })), + doc: null, + metadata: null + }; + } + + const Properties = node.props.map(v => v.asString(this)); + + const Fields = node.fields.map(v => v.asString(this)); + + const Constructors = node.constructors.map(v => this.generateConstructorFunction(v)); + + const Methods = node.members + .filter(m => !(m instanceof GirStaticClassFunction) && !(m instanceof GirVirtualClassFunction)) + .map(v => v && v.asString(this)); + const StaticMethods = node.members + .filter((m): m is GirStaticClassFunction => m instanceof GirStaticClassFunction) + .map(v => v && v.asString(this)); + const VirtualMethods = node.members + .filter((m): m is GirVirtualClassFunction => m instanceof GirVirtualClassFunction) + .map(v => v && v.asString(this)); + + // TODO Move these to a cleaner place. + + const Connect = new GirClassFunction({ + name: "connect", + parent: node, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: NumberType + }); + + const ConnectAfter = new GirClassFunction({ + name: "connect_after", + parent: node, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: NumberType + }); + + const Emit = new GirClassFunction({ + name: "emit", + parent: node, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "args", + isVarArgs: true, + type: new ArrayType(AnyType), + direction: Direction.In + }) + ], + return_type: VoidType + }); + + let default_signals = [] as GirClassFunction[]; + let hasConnect, hasConnectAfter, hasEmit; + + if (node.signals.length > 0) { + hasConnect = node.members.some(m => m.name === "connect"); + hasConnectAfter = node.members.some(m => m.name === "connect_after"); + hasEmit = node.members.some(m => m.name === "emit"); + + if (!hasConnect) { + default_signals.push(Connect); + } + if (!hasConnectAfter) { + default_signals.push(ConnectAfter); + } + if (!hasEmit) { + default_signals.push(Emit); + } + + hasConnect = !default_signals.some(s => s.name === "connect"); + hasConnectAfter = !default_signals.some(s => s.name === "connect_after"); + hasEmit = !default_signals.some(s => s.name === "emit"); + } + + const SignalsList = [ + ...default_signals.map(s => s.asString(this)), + ...node.signals + .map(s => { + const methods = [] as Json[]; + + if (!hasConnect) methods.push(s.asString(this, GirSignalType.CONNECT)); + if (!hasConnectAfter) methods.push(s.asString(this, GirSignalType.CONNECT_AFTER)); + if (!hasEmit) methods.push(s.asString(this, GirSignalType.EMIT)); + + return methods; + }) + .flat() + ]; + + const Signals = SignalsList; + + return { + kind: NodeKind.class, + abstract: node.isAbstract, + type: generateType(node.getType()), + name: node.name, + mainConstructor: MainConstructor, + signals: Signals, + extends: Extends ? generateType(Extends) : null, + implements: Implements.map(i => generateType(i)), + props: Properties, + fields: Fields, + constructors: Constructors, + methods: Methods, + staticMethods: StaticMethods, + virtualMethods: VirtualMethods, + ...this._generateDocAndMetadata(node) + }; + } + + generateField(node: GirField): FieldJson { + const { namespace, options } = this; + const { name, computed } = node; + const invalid = isInvalid(name); + + const Static = node.isStatic; + const ReadOnly = node.writable; + + return { + kind: NodeKind.field, + readonly: ReadOnly, + static: Static, + computed, + type: generateType(node.type.resolve(namespace, options)), + name: invalid ? `"${name}"` : name, + ...this._generateDocAndMetadata(node) + }; + } + + generateProperty(node: GirProperty, construct: boolean = false): PropertyJson { + const { namespace, options } = this; + + const invalid = isInvalid(node.name); + const ReadOnly = node.writable || construct; + + const Name = invalid ? `"${node.name}"` : node.name; + + let Type = generateType(node.type.resolve(namespace, options)); + return { + kind: NodeKind.prop, + readonly: ReadOnly, + constructOnly: node.constructOnly, + readable: node.readable, + writable: node.writable, + static: false, + type: Type, + name: Name, + ...this._generateDocAndMetadata(node) + }; + } + + generateSignal(node: GirSignal, type: GirSignalType = GirSignalType.CONNECT): MethodJson { + switch (type) { + case GirSignalType.CONNECT: + return node.asConnect(false).asString(this); + case GirSignalType.CONNECT_AFTER: + return node.asConnect(true).asString(this); + case GirSignalType.EMIT: + return node.asEmit().asString(this); + } + } + + generateEnumMember(node: GirEnumMember): EnumMemberJson { + const invalid = isInvalid(node.name); + + let enumMember: { + name: string; + value: string | null; + }; + + if ( + node.value != null && + !Number.isNaN(Number.parseInt(node.value, 10)) && + Number.isNaN(Number.parseInt(node.name, 10)) && + node.name !== "NaN" + ) { + enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: `${node.value}` }; + } else { + enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: null }; + } + + return { + kind: NodeKind.enumMember, + ...enumMember, + ...this._generateDocAndMetadata(node) + }; + } + + generateParameter(node: GirFunctionParameter): ParameterJson { + const { namespace, options } = this; + + let type = generateType( + resolveDirectedType(node.type, node.direction)?.resolve(namespace, options) ?? + node.type.resolve(namespace, options) + ); + + return { + kind: NodeKind.parameter, + name: node.name, + type, + varargs: node.isVarArgs, + optional: node.isOptional, + ...this._generateDocAndMetadata(node) + }; + } + + generateFunction(node: GirFunction): FunctionJson { + const { namespace } = this; + // Register our identifier with the sanitized identifiers. + // We avoid doing this in fromXML because other class-level function classes + // depends on that code. + sanitizeIdentifierName(namespace.name, node.raw_name); + + const Parameters = this.generateParameters(node.parameters); + const ReturnType = this.generateReturn(node.return(), node.output_parameters); + + return { + kind: NodeKind.function, + name: node.name, + parameters: Parameters, + returnType: ReturnType, + ...this._generateDocAndMetadata(node) + }; + } + + generateConstructorFunction(node: GirConstructor): MethodJson { + const { namespace, options } = this; + + const Parameters = this.generateParameters(node.parameters); + + return { + kind: NodeKind.classFunction, + static: true, + name: node.name, + parameters: Parameters, + returnType: generateType(node.return().resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } + + generateConstructor(node: GirConstructor): ConstructorJson { + return { + name: node.name, + kind: NodeKind.constructor, + parameters: this.generateParameters(node.parameters), + ...this._generateDocAndMetadata(node) + }; + } + + generateDirectAllocationConstructor(node: GirDirectAllocationConstructor): ConstructorJson { + return { + name: node.name, + kind: NodeKind.constructor, + parameters: this.generateParameters( + node.fields.map( + field => + new GirFunctionParameter({ + name: field.name, + direction: Direction.In, + type: field.type, + isOptional: true + }) + ) + ), + ...this._generateDocAndMetadata(node) + }; + } + + generateClassFunction(node: GirClassFunction): MethodJson { + let parameters = node.parameters.map(p => this.generateParameter(p)); + let output_parameters = node.output_parameters; + let return_type = node.return(); + + const ReturnType = this.generateReturn(return_type, output_parameters); + + return { + kind: NodeKind.classFunction, + name: node.name, + parameters, + returnType: ReturnType, + ...this._generateDocAndMetadata(node) + }; + } + + generateStaticClassFunction(node: GirStaticClassFunction): StaticMethodJson { + let parameters = node.parameters.map(p => this.generateParameter(p)); + let output_parameters = node.output_parameters; + let return_type = node.return(); + + const ReturnType = this.generateReturn(return_type, output_parameters); + + return { + kind: NodeKind.staticClassFunction, + name: node.name, + parameters, + returnType: ReturnType, + ...this._generateDocAndMetadata(node) + }; + } + + generateAlias(node: GirAlias): AliasJson { + const { namespace, options } = this; + const type = node.type.resolve(namespace, options); + + const { name } = node; + + return { + kind: NodeKind.alias, + name, + type: generateType(type.resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } + + generateVirtualClassFunction(node: GirVirtualClassFunction): VirtualMethodJson { + return { + ...this.generateClassFunction(node), + kind: NodeKind.virtualClassFunction + }; + } + + async generateNamespace(node: GirNamespace): Promise { + function shouldGenerate(node: GirBase) { + return node.emit; + } + + const { name, version } = node; + + const members = Array.from(node.members.values()) + .flatMap(m => m) + .filter(shouldGenerate); + + const classes = members.filter((m): m is GirClass => m instanceof GirClass).map(m => m.asString(this)); + const interfaces = members + + .filter((m): m is GirInterface => m instanceof GirInterface) + .map(m => m.asString(this)); + const records = members.filter((m): m is GirRecord => m instanceof GirRecord).map(m => m.asString(this)); + const constants = members.filter((m): m is GirConst => m instanceof GirConst).map(m => m.asString(this)); + const callbacks = members + + .filter((m): m is GirCallback => m instanceof GirCallback) + .map(m => m.asString(this)); + // Functions can have overrides. + const functions = [ + ...members + + .filter((m): m is GirFunction => !(m instanceof GirCallback) && m instanceof GirFunction) + .reduce((prev, next) => { + if (!prev.has(next.name)) prev.set(next.name, next.asString(this)); + + return prev; + }, new Map()) + .values() + ]; + const errors = members.filter((m): m is GirError => m instanceof GirError).map(m => m.asString(this)); + const enums = members + + .filter((m): m is GirEnum => !(m instanceof GirError) && m instanceof GirEnum) + .map(m => m.asString(this)); + const alias = members.filter((m): m is GirAlias => m instanceof GirAlias).map(m => m.asString(this)); + + // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. + const imports = node.getImports(); + + return { + kind: NodeKind.namespace, + name, + version, + imports: Object.fromEntries(imports), + classes, + interfaces, + records, + constants, + functions, + callbacks, + errors, + enums, + alias + }; + } + + async stringifyNamespace(node: GirNamespace): Promise { + const { namespace, options } = this; + + if (options.verbose) { + console.debug(`Resolving the types of ${namespace.name}...`); + } + + try { + const output = await this.generateNamespace(node); + + if (options.verbose) { + console.debug(`Printing ${namespace.name}...`); + } + + if (!output) return null; + + return JSON.stringify(output, null, 4); + } catch (err) { + console.error(`Failed to generate namespace: ${node.name}`); + console.error(err); + return null; + } + } +} diff --git a/packages/lib/src/newlib/generics/clutter.ts b/packages/lib/src/newlib/generics/clutter.ts new file mode 100644 index 000000000..fdd862969 --- /dev/null +++ b/packages/lib/src/newlib/generics/clutter.ts @@ -0,0 +1,53 @@ +import { GenericType } from "../gir.js"; +import { GirNamespace } from "../gir/namespace.js"; + +export default { + namespace: "Clutter", + modifier: (namespace: GirNamespace, inferGenerics: boolean) => { + if (!inferGenerics) { + return; + } + + const Actor = namespace.assertClass("Actor"); + const Content = namespace.assertClass("Content"); + const LayoutManager = namespace.assertClass("LayoutManager"); + + Actor.addGeneric({ + default: LayoutManager.getType(), + constraint: LayoutManager.getType() + }); + + Actor.addGeneric({ + default: Content.getType(), + constraint: Content.getType() + }); + + Actor.props + .filter(p => p.name === "layout_manager" || p.name === "layoutManager") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("A", Content.getType()); + }); + + Actor.props + .filter(p => p.name === "content") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("B", Content.getType()); + }); + + const Clone = namespace.assertClass("Clone"); + + Clone.addGeneric({ + default: Actor.getType(), + constraint: Actor.getType() + }); + + Clone.props + .filter(p => p.name === "source") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("A", Content.getType()); + }); + } +}; diff --git a/packages/lib/src/newlib/generics/generify.ts b/packages/lib/src/newlib/generics/generify.ts new file mode 100644 index 000000000..6f735c1dd --- /dev/null +++ b/packages/lib/src/newlib/generics/generify.ts @@ -0,0 +1,47 @@ +import gio from "./gio.js"; +import glib from "./glib.js"; +import clutter from "./clutter.js"; +import st from "./st.js"; +import meta from "./meta.js"; + +import { GirNamespace } from "../gir/namespace.js"; +import { GirNSRegistry } from "../gir/registry.js"; +import { GenericVisitor } from "./visitor.js"; + +type NamespaceModifier = (namespace: GirNamespace, inferGenerics: boolean) => void; + +function generifyDefinitions(registry: GirNSRegistry, inferGenerics: boolean, required: boolean = true) { + return (definition: { namespace: string; version?: string; modifier: NamespaceModifier }) => { + const version = definition?.version ?? registry.defaultVersionOf(definition.namespace); + + if (version) { + const ns = registry.namespace(definition.namespace, version); + + if (ns) { + definition.modifier(ns, inferGenerics); + return; + } + } + + if (required) { + console.error(`Failed to generify ${definition.namespace}`); + } + }; +} + +export function generify(registry: GirNSRegistry, inferGenerics: boolean) { + const $ = generifyDefinitions(registry, inferGenerics); + + $(gio); + $(glib); + + const $_ = generifyDefinitions(registry, inferGenerics, false); + + $_(clutter); + $_(st); + $_(meta); + + const visitor = new GenericVisitor(registry, inferGenerics); + + registry.registerTransformation(visitor); +} diff --git a/packages/lib/src/newlib/generics/gio.ts b/packages/lib/src/newlib/generics/gio.ts new file mode 100644 index 000000000..4bf21ff48 --- /dev/null +++ b/packages/lib/src/newlib/generics/gio.ts @@ -0,0 +1,66 @@ +import { AnyType, Generic, GenericType, GenerifiedTypeIdentifier, StringType, TypeIdentifier } from "../gir.js"; +import { GirNamespace } from "../gir/namespace.js"; + +export default { + namespace: "Gio", + version: "2.0", + modifier: (namespace: GirNamespace) => { + const AsyncInitable = namespace.getClass("AsyncInitable"); + + if (!AsyncInitable) { + throw new Error("Gio.AsyncInitable not found."); + } + + const GObject = namespace.assertInstalledImport("GObject").assertClass("Object"); + + AsyncInitable.addGeneric({ + constraint: GObject.getType(), + default: GObject.getType(), + propagate: false + }); + + const ListModel = namespace.getClass("ListModel"); + + if (!ListModel) { + throw new Error("Gio.ListModel not found."); + } + + ListModel.addGeneric({ + default: GObject.getType(), + constraint: GObject.getType() + }); + + const ListStore = namespace.getClass("ListStore"); + + if (!ListStore) { + throw new Error("Gio.ListStore not found."); + } + + ListStore.addGeneric({ + deriveFrom: ListModel.getType(), + default: GObject.getType(), + constraint: GObject.getType() + }); + + const Settings = namespace.assertClass("Settings"); + + Settings.members = Settings.members.map(m => { + if (m.name === "get_value" || m.name === "get_default_value" || m.name === "get_user_value") { + m.generics.push(new Generic(new GenericType("T"), AnyType, undefined, StringType)); + const returnType = m.return().deepUnwrap(); + + if (returnType instanceof TypeIdentifier && returnType.is("GLib", "Variant")) { + return m.copy({ + returnType: m + .return() + .rewrap(new GenerifiedTypeIdentifier("Variant", "GLib", [new GenericType("T")])) + }); + } + + return m; + } + + return m; + }); + } +}; diff --git a/packages/lib/src/newlib/generics/glib.ts b/packages/lib/src/newlib/generics/glib.ts new file mode 100644 index 000000000..a5d69c80b --- /dev/null +++ b/packages/lib/src/newlib/generics/glib.ts @@ -0,0 +1,22 @@ +import { AnyType, StringType } from "../gir.js"; +import { GirNamespace } from "../gir/namespace.js"; + +export default { + namespace: "GLib", + version: "2.0", + modifier: (namespace: GirNamespace) => { + const HashTable = namespace.getClass("HashTable"); + + if (!HashTable) { + throw new Error("GLib.HashTable not found."); + } + + HashTable.addGeneric({ + default: StringType + }); + + HashTable.addGeneric({ + default: AnyType + }); + } +}; diff --git a/packages/lib/src/newlib/generics/meta.ts b/packages/lib/src/newlib/generics/meta.ts new file mode 100644 index 000000000..8826f9e78 --- /dev/null +++ b/packages/lib/src/newlib/generics/meta.ts @@ -0,0 +1,27 @@ +import { GenerifiedTypeIdentifier } from "../gir.js"; +import { GirNamespace } from "../gir/namespace.js"; + +export default { + namespace: "Meta", + modifier: (namespace: GirNamespace, inferGenerics: boolean) => { + if (!inferGenerics) { + return; + } + + // Connect BackgroundActor to BackgroundContent + + const LayoutManager = namespace.assertInstalledImport("Clutter").assertClass("LayoutManager"); + + const BackgroundContent = namespace.assertClass("BackgroundContent"); + const BackgroundActor = namespace.assertClass("BackgroundActor"); + + const parent = BackgroundActor.parent; + + if (parent) { + BackgroundActor.parent = new GenerifiedTypeIdentifier(parent.name, parent.namespace, [ + LayoutManager.getType(), + BackgroundContent.getType() + ]); + } + } +}; diff --git a/packages/lib/src/newlib/generics/st.ts b/packages/lib/src/newlib/generics/st.ts new file mode 100644 index 000000000..6c5f659ae --- /dev/null +++ b/packages/lib/src/newlib/generics/st.ts @@ -0,0 +1,112 @@ +import { GenericType, GenerifiedTypeIdentifier } from "../gir.js"; +import { GirNamespace } from "../gir/namespace.js"; + +export default { + namespace: "St", + version: "1.0", + modifier: (namespace: GirNamespace, inferGenerics: boolean) => { + if (!inferGenerics) { + return; + } + + const Bin = namespace.assertClass("Bin"); + const Button = namespace.assertClass("Button"); + const ScrollView = namespace.assertClass("ScrollView"); + const ScrollBar = namespace.assertClass("ScrollBar"); + const Widget = namespace.assertClass("Widget"); + // TODO: Create a way to propagate this generic to child classes. + const Viewport = namespace.assertClass("Viewport"); + const StBoxLayout = namespace.assertClass("BoxLayout"); + + const Clutter = namespace.assertInstalledImport("Clutter"); + + const Actor = Clutter.assertClass("Actor"); + const Content = Clutter.assertClass("Content"); + const Container = Clutter.assertClass("Container"); + const LayoutManager = Clutter.assertClass("LayoutManager"); + const ClutterBoxLayout = Clutter.assertClass("BoxLayout"); + + Widget.addGeneric({ + deriveFrom: Actor.getType(), + default: LayoutManager.getType(), + constraint: LayoutManager.getType() + }); + + Widget.addGeneric({ + deriveFrom: Actor.getType(), + default: Content.getType(), + constraint: Content.getType() + }); + + Viewport.addGeneric({ + deriveFrom: Widget.getType(), + default: LayoutManager.getType(), + constraint: LayoutManager.getType() + }); + + Viewport.addGeneric({ + deriveFrom: Widget.getType(), + default: Content.getType(), + constraint: Content.getType() + }); + + Container.addGeneric({ + default: Actor.getType(), + constraint: Actor.getType() + }); + + StBoxLayout.addGeneric({ + deriveFrom: Container.getType(), + default: Actor.getType(), + constraint: Actor.getType() + }); + + if (StBoxLayout.parent) { + StBoxLayout.parent = new GenerifiedTypeIdentifier( + StBoxLayout.parent.name, + StBoxLayout.parent.namespace, + [ClutterBoxLayout.getType()] + ); + } + + Bin.addGeneric({ + default: Actor.getType(), + constraint: Actor.getType() + }); + + Button.addGeneric({ + deriveFrom: Bin.getType(), + default: Actor.getType(), + constraint: Actor.getType() + }); + + const get_hscroll_bar = ScrollView.members.find(member => member.name === "get_hscroll_bar"); + const get_vscroll_bar = ScrollView.members.find(member => member.name === "get_vscroll_bar"); + + if (get_hscroll_bar) { + const fixed_get_h = get_hscroll_bar?.copy({ returnType: ScrollBar.getType() }); + + const index = ScrollView.members.indexOf(get_hscroll_bar); + ScrollView.members.splice(index, 1, fixed_get_h); + } + + if (get_vscroll_bar) { + const fixed_get_v = get_vscroll_bar?.copy({ returnType: ScrollBar.getType() }); + const index = ScrollView.members.indexOf(get_vscroll_bar); + ScrollView.members.splice(index, 1, fixed_get_v); + } + + ScrollView.addGeneric({ + deriveFrom: Bin.getType(), + default: Actor.getType(), + constraint: Actor.getType() + }); + + Bin.props + .filter(p => p.name === "child") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("A", Actor.getType()); + }); + } +}; diff --git a/packages/lib/src/newlib/generics/visitor.ts b/packages/lib/src/newlib/generics/visitor.ts new file mode 100644 index 000000000..aaacc915b --- /dev/null +++ b/packages/lib/src/newlib/generics/visitor.ts @@ -0,0 +1,368 @@ +import { + ClosureType, + GenericType, + Generic, + TypeIdentifier, + GenerifiedTypeIdentifier, + ThisType +} from "../gir.js"; +import { GirClass, GirBaseClass, GirInterface } from "../gir/class.js"; +import { + GirCallback, + GirFunctionParameter, + GirFunction, + GirClassFunction, + GirStaticClassFunction, + GirVirtualClassFunction +} from "../gir/function.js"; +import { GenericNameGenerator } from "../gir/generics.js"; +import { GirNSRegistry } from "../gir/registry.js"; +import { resolveTypeIdentifier } from "../gir/util.js"; +import { GirVisitor } from "../visitor.js"; + +export class GenericVisitor extends GirVisitor { + registry: GirNSRegistry; + inferGenerics: boolean; + + constructor(registry: GirNSRegistry, inferGenerics: boolean) { + super(); + + this.registry = registry; + this.inferGenerics = inferGenerics; + } + + visitCallback = (node: GirCallback) => { + if (!this.inferGenerics) { + return node; + } + + const shouldGenerify = node.parameters.some(p => { + const type = p.type.unwrap(); + return type instanceof TypeIdentifier && type.is("GObject", "Object"); + }); + + if (shouldGenerify) { + const generateName = GenericNameGenerator.new(); + + let generics = [] as Generic[]; + + const GenerifiedParameters = node.parameters.map(p => { + const type = p.type.unwrap(); + + if (type instanceof TypeIdentifier && type.is("GObject", "Object")) { + const Identifier = generateName(); + const generic = new GenericType(Identifier, type); + generics.push(new Generic(generic, type)); + + return p.copy({ + type: p.type.rewrap(generic) + }); + } + + return p; + }); + + const generified = node.copy({ + parameters: GenerifiedParameters + }); + + generified.generics = generics; + + return generified; + } + + return node; + }; + + visitClass = (node: GirClass) => { + return this.visitBaseClass(node); + }; + + visitInterface = (node: GirInterface) => { + return this.visitBaseClass(node); + }; + + visitBaseClass = (_node: T): T => { + const node = _node.copy() as T; + + const { namespace } = _node; + + const resolvedParent = node.parent ? resolveTypeIdentifier(namespace, node.parent) : null; + let derivatives = node.generics.filter(generic => generic.parent != null); + + if (node instanceof GirClass) { + const resolvedInterfaces = node.interfaces + .map(i => resolveTypeIdentifier(namespace, i)) + .filter((c): c is GirBaseClass => c != null); + + node.interfaces = node.interfaces.map(iface => { + const generic = derivatives.filter(d => d.parent?.is(iface.namespace, iface.name)); + + if (generic.length > 0) { + return new GenerifiedTypeIdentifier( + iface.name, + iface.namespace, + generic.map(g => g.type) + ); + } + + const resolved = resolvedInterfaces.find(i => i.getType().equals(iface)); + + if (resolved) { + if (resolved.generics.length === 1) { + const generic = resolved.generics[0]; + + if (generic.propagate) { + const constrainedGeneric = node.generics.find( + d => generic.constraint && d.constraint?.equals(generic.constraint) + ); + + if (constrainedGeneric) { + return new GenerifiedTypeIdentifier(iface.name, iface.namespace, [constrainedGeneric.type]); + } + + if ( + !generic.defaultType?.equals(node.getType()) && + !generic.constraint?.equals(node.getType()) + ) { + node.addGeneric({ + constraint: generic.constraint ?? undefined, + default: generic.defaultType ?? undefined, + deriveFrom: resolved.getType() + }); + + const firstGeneric = node.generics[node.generics.length - 1]; + + return new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + firstGeneric.type + ]); + } + } + + return new GenerifiedTypeIdentifier(iface.name, iface.namespace, [node.getType()]); + } + } + + return iface; + }); + } + + if (node.parent) { + const parentType = node.parent; + + const generic = derivatives.filter(d => d.parent?.is(parentType.namespace, parentType.name)); + + if (node.parent instanceof GenerifiedTypeIdentifier) { + // Do nothing + } else if (generic.length > 0) { + node.parent = new GenerifiedTypeIdentifier( + parentType.name, + parentType.namespace, + generic.map(g => g.type) + ); + } else { + const resolved = resolvedParent; + + if (resolved?.generics.length === 1) { + const [generic] = resolved.generics; + + if (generic.propagate) { + const constrainedGeneric = node.generics.find( + d => generic.constraint && d.constraint?.equals(generic.constraint) + ); + + if (constrainedGeneric) { + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + constrainedGeneric.type + ]); + } else { + if ( + !generic.defaultType?.equals(node.getType()) && + !generic.constraint?.equals(node.getType()) + ) { + node.addGeneric({ + constraint: generic.constraint ?? undefined, + default: generic.defaultType ?? undefined, + deriveFrom: resolved.getType() + }); + + const firstGeneric = node.generics[node.generics.length - 1]; + + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + firstGeneric.type + ]); + } else if ( + [...node.resolveParents()].some( + c => generic.defaultType && c.identifier.equals(generic.defaultType) + ) + ) { + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.getType() + ]); + } + } + } else if ( + [...node.resolveParents()].some( + c => generic.defaultType && c.identifier.equals(generic.defaultType) + ) + ) { + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.getType() + ]); + } + } + } + } + + return node; + }; + + visitParameter = (node: GirFunctionParameter) => { + const { inferGenerics } = this; + + const member = node.parent; + + const unwrapped = node.type.unwrap(); + // TODO I need a better system for this, but handling Gio.AsyncReadyCallback is the most common. + + if (inferGenerics && unwrapped instanceof ClosureType) { + const internal = unwrapped.type.unwrap(); + + if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { + if (member instanceof GirFunction && member.parameters.length >= 2) { + const generified = node.copy({ + type: node.type.rewrap( + new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parameters[0].type]) + ) + }); + + return generified; + } else if (member instanceof GirStaticClassFunction) { + const generified = node.copy({ + type: node.type.rewrap( + new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parent.getType()]) + ) + }); + + return generified; + } else if (member instanceof GirClassFunction) { + const generified = node.copy({ + type: node.type.rewrap( + new GenerifiedTypeIdentifier(internal.name, internal.namespace, [ThisType]) + ) + }); + + return generified; + } + } + } + + return node; + }; + + visitFunction = (node: GirFunction) => { + if (!this.inferGenerics) { + return node; + } + + const unwrapped = node.return_type.unwrap(); + const shouldGenerify = unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "Object"); + + if (shouldGenerify) { + const genericReturnType = new GenericType("T", unwrapped); + + const copied = node.copy({ + return_type: genericReturnType + }); + + copied.generics.push(new Generic(genericReturnType, unwrapped)); + + return copied; + } + + return node; + }; + + private generifyStandaloneClassFunction = (node: GirClassFunction) => { + const unwrapped = node.return().unwrap(); + + if (node.parent.getType().is("GObject", "Object")) { + return node; + } + + if (unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "Object")) { + const genericReturnType = new GenericType("T", unwrapped); + + const copied = node.copy({ + returnType: genericReturnType + }); + + copied.generics.push(new Generic(genericReturnType, unwrapped, unwrapped)); + + return copied; + } + + return node; + }; + + visitStaticClassFunction = (node: GirStaticClassFunction) => { + if (this.inferGenerics) { + return this.generifyStandaloneClassFunction(node); + } + + return node; + }; + + visitClassFunction = (node: GirClassFunction) => { + if (node.parent instanceof GirBaseClass) { + const clazz = node.parent; + + if (clazz.generics.length > 0) { + let returnType = node.return(); + + for (const generic of clazz.generics) { + if (generic.defaultType?.equals(node.return().deepUnwrap())) { + returnType = node.return().rewrap(generic.type); + break; + } + } + + return node.copy({ + parameters: node.parameters.map(p => { + for (const generic of clazz.generics) { + if (generic.defaultType?.equals(p.type.deepUnwrap())) { + return p.copy({ + type: p.type.rewrap(generic.type) + }); + } + } + + return p; + }), + outputParameters: node.output_parameters.map(p => { + for (const generic of clazz.generics) { + if (generic.defaultType?.equals(p.type.unwrap())) { + return p.copy({ + type: p.type.rewrap(generic.type) + }); + } + } + + return p; + }), + returnType + }); + } + } + + if (this.inferGenerics) { + return this.generifyStandaloneClassFunction(node); + } + + return node; + }; + + visitVirtualClassFunction = (node: GirVirtualClassFunction) => { + return this.visitClassFunction(node); + }; +} diff --git a/packages/lib/src/newlib/gir.ts b/packages/lib/src/newlib/gir.ts new file mode 100644 index 000000000..1ce06cb22 --- /dev/null +++ b/packages/lib/src/newlib/gir.ts @@ -0,0 +1,758 @@ +import { GirNamespace } from "./gir/namespace.js"; +import { GirProperty, GirField } from "./gir/property.js"; +import { FormatGenerator } from "./generators/generator.js"; +import { GenerationOptions, LoadOptions } from "./types.js"; +import { sanitizeIdentifierName } from "./gir/util.js"; +import { GirVisitor } from "./visitor.js"; + +export {GirBase, GirOptions, GirMetadata} from './gir/base.js'; + +export abstract class TypeExpression { + isPointer = false; + + abstract equals(type: TypeExpression): boolean; + abstract unwrap(): TypeExpression; + + deepUnwrap(): TypeExpression { + return this.unwrap(); + } + + abstract rewrap(type: TypeExpression): TypeExpression; + abstract resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression; + + abstract print(namespace: GirNamespace, options: GenerationOptions): string; + rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + return this.print(namespace, options); + } +} + +export class TypeIdentifier extends TypeExpression { + readonly name: string; + readonly namespace: string; + + constructor(name: string, namespace: string) { + super(); + this.name = name; + this.namespace = namespace; + } + + equals(type: TypeExpression): boolean { + return type instanceof TypeIdentifier && type.name === this.name && type.namespace === this.namespace; + } + + is(namespace: string, name: string) { + return this.namespace === namespace && this.name === name; + } + + unwrap() { + return this; + } + + rewrap(type: TypeExpression): TypeExpression { + return type; + } + + protected _resolve(namespace: GirNamespace, options: GenerationOptions): TypeIdentifier | null { + const type = this; + let name: string = sanitizeIdentifierName(null, type.name); + let ns_name = type.namespace; + + let ns = namespace.assertInstalledImport(ns_name); + + if (ns.hasSymbol(name)) { + const c = ns.getClass(name); + + // Some records are structs for other class types. + // GirRecord.prototype.getType resolves this relationship. + if (c) return c.getType(); + + return new TypeIdentifier(name, ns_name); + } + + // Handle "class callback" types (they're in a definition-merged module) + let [cb, corrected_name] = ns.findClassCallback(name); + let resolved_name: string | null = null; + + if (!cb) { + resolved_name = ns.resolveSymbolFromTypeName(name); + } + + let c_resolved_name: string | null = null; + + if (!c_resolved_name) { + c_resolved_name = ns.resolveSymbolFromTypeName(`${ns_name}${name}`); + } + + if (!cb && !resolved_name && !c_resolved_name) { + // Don't warn if a missing import is at fault, this will be dealt with later. + if (namespace.name === ns_name) { + console.error(`Attempting to fall back on c:type inference for ${ns_name}.${name}.`); + } + + [cb, corrected_name] = ns.findClassCallback(`${ns_name}${name}`); + + if (cb) { + console.error( + `Falling back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` + ); + } + } + + if (cb) { + if (options.verbose) { + console.debug(`Callback found: ${cb}.${corrected_name}`); + } + + return new TypeIdentifier(corrected_name, cb); + } else if (resolved_name) { + return new TypeIdentifier(resolved_name, ns_name); + } else if (c_resolved_name) { + console.error( + `Fell back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` + ); + + return new TypeIdentifier(c_resolved_name, ns_name); + } else if (namespace.name === ns_name) { + console.error(`Unable to resolve type ${type.name} in same namespace ${ns_name}!`); + return null; + } + + console.error(`Type ${type.namespace}.${type.name} could not be resolved in ${namespace.name}`); + return null; + } + + resolveIdentifier(namespace: GirNamespace, options: GenerationOptions): TypeIdentifier | null { + return this._resolve(namespace, options); + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + const resolved = this._resolve(namespace, options); + + // Generally if we can't resolve a type it is not introspectable, + // thus we annotate it as "never". + return resolved ?? NeverType; + } + + static new({ name, namespace }: { name: string; namespace: string }) { + return new TypeIdentifier(name, namespace); + } + + print(namespace: GirNamespace, _options: GenerationOptions): string { + if (namespace.name === this.namespace) { + return `${this.name}`; + } else { + return `${this.namespace}.${this.name}`; + } + } +} + +export class GenerifiedTypeIdentifier extends TypeIdentifier { + generics: TypeExpression[]; + + constructor(name: string, namespace: string, generics: TypeExpression[] = []) { + super(name, namespace); + this.generics = generics; + } + + print(namespace: GirNamespace, _options: GenerationOptions): string { + const Generics = this.generics.map(generic => generic.print(namespace, _options)).join(", "); + + if (namespace.name === this.namespace) { + return `${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + } else { + return `${this.namespace}.${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + } + } + + _resolve(namespace: GirNamespace, options: GenerationOptions): TypeIdentifier | null { + const iden = super._resolve(namespace, options); + + if (iden) { + return new GenerifiedTypeIdentifier(iden.name, iden.namespace, [...this.generics]); + } + + return iden; + } +} + +export class NativeType extends TypeExpression { + readonly expression: (options?: GenerationOptions) => string; + + constructor(expression: ((options?: GenerationOptions) => string) | string) { + super(); + + this.expression = typeof expression === "string" ? () => expression : expression; + } + + rewrap(type: TypeExpression): TypeExpression { + return type; + } + + resolve(_namespace: GirNamespace, _options: GenerationOptions): TypeExpression { + return this; + } + + print(_namespace: GirNamespace, options: GenerationOptions) { + return this.expression(options); + } + + equals(type: TypeExpression, options?: GenerationOptions): boolean { + return type instanceof NativeType && this.expression(options) === type.expression(options); + } + + unwrap(): TypeExpression { + return this; + } + + static withGenerator(generator: (options?: GenerationOptions) => string): TypeExpression { + return new NativeType(generator); + } + + static of(nativeType: string) { + return new NativeType(nativeType); + } +} + +export class OrType extends TypeExpression { + readonly types: ReadonlyArray; + + constructor(type: TypeExpression, ...types: TypeExpression[]) { + super(); + this.types = [type, ...types]; + } + + rewrap(type: TypeExpression): TypeExpression { + return type; + } + + unwrap(): TypeExpression { + return this; + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + const [type, ...types] = this.types; + + return new OrType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); + } + + print(namespace: GirNamespace, options: GenerationOptions): string { + return `(${this.types.map(t => t.print(namespace, options)).join(" | ")})`; + } + + rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + return `${this.types.map(t => t.print(namespace, options)).join(" | ")}`; + } + + equals(type: TypeExpression) { + if (type instanceof OrType) { + return this.types.every(t => type.types.some(type => type.equals(t))); + } else { + return false; + } + } +} + +export class TupleType extends OrType { + print(namespace: GirNamespace, options: GenerationOptions): string { + return `[${this.types.map(t => t.print(namespace, options)).join(", ")}]`; + } + + rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + return this.print(namespace, options); + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + const [type, ...types] = this.types; + + return new TupleType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); + } + + equals(type: TypeExpression) { + if (type instanceof TupleType) { + return this.types.length === type.types.length && this.types.every((t, i) => type.types[i].equals(t)); + } else { + return false; + } + } +} + +export class BinaryType extends OrType { + constructor(primary: TypeExpression, secondary: TypeExpression) { + super(primary, secondary); + } + + unwrap(): TypeExpression { + return this; + } + + resolve(namespace: GirNamespace, options: GenerationOptions) { + return new BinaryType(this.a.resolve(namespace, options), this.b.resolve(namespace, options)); + } + + is(_namespace: string | null, _name: string) { + return false; + } + + get a() { + return this.types[0]; + } + + get b() { + return this.types[1]; + } +} + +export class FunctionType extends TypeExpression { + parameterTypes: { [name: string]: TypeExpression }; + returnType: TypeExpression; + + constructor(parameters: { [name: string]: TypeExpression }, returnType: TypeExpression) { + super(); + + this.parameterTypes = parameters; + this.returnType = returnType; + } + + equals(type: TypeExpression): boolean { + if (type instanceof FunctionType) { + return ( + Object.values(this.parameterTypes).every(t => + Object.values(type.parameterTypes).some(tp => t.equals(tp)) + ) && + Object.values(type.parameterTypes).every(t => + Object.values(this.parameterTypes).some(tp => t.equals(tp)) + ) && + this.returnType.equals(type.returnType) + ); + } + + return false; + } + + rewrap(type: TypeExpression): TypeExpression { + return type; + } + + unwrap(): TypeExpression { + return this; + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + return new FunctionType( + Object.fromEntries( + Object.entries(this.parameterTypes).map(([k, p]) => { + return [k, p.resolve(namespace, options)]; + }) + ), + this.returnType.resolve(namespace, options) + ); + } + + rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + const Parameters = Object.entries(this.parameterTypes) + .map(([k, v]) => { + return `${k}: ${v.rootPrint(namespace, options)}`; + }) + .join(", "); + + return `(${Parameters}) => ${this.returnType.print(namespace, options)}`; + } + + print(namespace: GirNamespace, options: GenerationOptions): string { + return `(${this.rootPrint(namespace, options)})`; + } +} + +export class Generic { + private _deriveFrom: TypeIdentifier | null; + private _genericType: GenericType; + private _defaultType: TypeExpression | null; + private _constraint: TypeExpression | null; + private _propagate: boolean; + + constructor( + genericType: GenericType, + defaultType?: TypeExpression, + deriveFrom?: TypeIdentifier, + constraint?: TypeExpression, + propagate = true + ) { + this._genericType = genericType; + this._defaultType = defaultType ?? null; + this._deriveFrom = deriveFrom ?? null; + this._constraint = constraint ?? null; + this._propagate = propagate; + } + + unwrap() { + return this.type; + } + + get propagate() { + return this._propagate; + } + + get type() { + return this._genericType; + } + + get defaultType() { + return this._defaultType; + } + + get constraint() { + return this._constraint; + } + + get parent() { + return this._deriveFrom; + } +} + +export class GenerifiedType extends TypeExpression { + type: TypeExpression; + generic: GenericType; + + constructor(type: TypeExpression, generic: GenericType) { + super(); + + this.type = type; + this.generic = generic; + } + + resolve(namespace: GirNamespace, options: GenerationOptions) { + return new GenerifiedType( + this.type.resolve(namespace, options), + this.generic.resolve(namespace, options) + ); + } + + unwrap() { + return this.type; + } + + rootPrint(namespace: GirNamespace, options: GenerationOptions) { + return `${this.type.print(namespace, options)}<${this.generic.print(namespace, options)}>`; + } + + print(namespace: GirNamespace, options: GenerationOptions) { + return `${this.type.print(namespace, options)}<${this.generic.print(namespace, options)}>`; + } + + equals(type: TypeExpression): boolean { + if (type instanceof GenerifiedType) { + return type.type.equals(this.type) && type.generic.equals(this.generic); + } + + return false; + } + + rewrap(type: TypeExpression): TypeExpression { + return new GenerifiedType(this.type.rewrap(type), this.generic); + } +} + +export class GenericType extends TypeExpression { + identifier: string; + replacedType?: TypeExpression; + + constructor(identifier: string, replacedType?: TypeExpression) { + super(); + this.identifier = identifier; + this.replacedType = replacedType; + } + + equals(type: TypeExpression): boolean { + if (type instanceof GenericType) { + return type.identifier === this.identifier; + } + + return false; + } + + unwrap(): TypeExpression { + return this; + } + + rewrap(type: TypeExpression): TypeExpression { + return type; + } + + resolve(_namespace: GirNamespace, _options: GenerationOptions): GenericType { + return this; + } + + print(_namespace: GirNamespace, _options: GenerationOptions): string { + return `${this.identifier}`; + } +} + +export class NullableType extends BinaryType { + constructor(type: TypeExpression) { + super(type, NullType); + } + + unwrap() { + return this.type; + } + + rewrap(type: TypeExpression): TypeExpression { + return new NullableType(this.type.rewrap(type)); + } + + get type() { + return this.a; + } +} + +export class PromiseType extends TypeExpression { + type: TypeExpression; + + constructor(type: TypeExpression) { + super(); + this.type = type; + } + + equals(type: TypeExpression): boolean { + return type instanceof PromiseType && type.type.equals(this.type); + } + + unwrap() { + return this.type; + } + + rewrap(type: TypeExpression): TypeExpression { + return new PromiseType(this.type.rewrap(type)); + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + return new PromiseType(this.type.resolve(namespace, options)); + } + + print(namespace: GirNamespace, options: GenerationOptions): string { + // TODO: Optimize this check. + if (!namespace.hasSymbol("Promise")) { + return `Promise<${this.type.print(namespace, options)}>`; + } + + return `globalThis.Promise<${this.type.print(namespace, options)}>`; + } +} + +/** + * A list of possible type conflicts. + * + * The format is CHILD_PARENT_CONFLICT so + * ACCESSOR_PROPERTY_CONFLICT means there + * is an accessor on a child class and a + * property on the parent class, which is a + * conflict. + * + * Starts at '1' because the value is often + * used as truthy. + */ +export enum ConflictType { + PROPERTY_NAME_CONFLICT = 1, + FIELD_NAME_CONFLICT, + FUNCTION_NAME_CONFLICT, + ACCESSOR_PROPERTY_CONFLICT, + PROPERTY_ACCESSOR_CONFLICT +} + +/** + * This is one of the more interesting usages of our type + * system. To handle type conflicts we wrap conflicting types + * in this class with a ConflictType to denote why they are a + * conflict. + * + * TypeConflict will throw if it is printed or resolved, so generators + * must unwrap it and "resolve" the conflict. Some generators like JSON + * just disregard this info, other generators like DTS attempt to + * resolve the conflicts so the typing stays sound. + */ +export class TypeConflict extends TypeExpression { + readonly conflictType: ConflictType; + readonly type: TypeExpression; + + constructor(type: TypeExpression, conflictType: ConflictType) { + super(); + this.type = type; + this.conflictType = conflictType; + } + + rewrap(type: TypeExpression) { + return new TypeConflict(this.type.rewrap(type), this.conflictType); + } + + unwrap() { + return this.type; + } + + // TODO: This constant "true" is a remnant of the Anyified type. + equals(_type: TypeExpression) { + return true; + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + throw new Error( + `Type conflict was not resolved for ${this.type + .resolve(namespace, options) + .print(namespace, options)} in ${namespace}` + ); + } + + print(namespace: GirNamespace, options: GenerationOptions): string { + throw new Error( + `Type conflict was not resolved for ${this.type + .resolve(namespace, options) + .print(namespace, options)} in ${namespace}` + ); + } +} + +export class ClosureType extends TypeExpression { + type: TypeExpression; + user_data: number | null = null; + + constructor(type: TypeExpression) { + super(); + this.type = type; + } + + equals(type: TypeExpression): boolean { + if (type instanceof ClosureType) { + const closureType = type; + return this.type.equals(closureType.type); + } + + return false; + } + + deepUnwrap(): TypeExpression { + return this.type; + } + + rewrap(type: TypeExpression): TypeExpression { + const closure = new ClosureType(this.type.rewrap(type)); + + closure.user_data = this.user_data; + + return closure; + } + + unwrap(): TypeExpression { + return this; + } + + resolve(namespace: GirNamespace, options: GenerationOptions) { + const { user_data, type } = this; + + return ClosureType.new({ + user_data, + type: type.resolve(namespace, options) + }); + } + + print(namespace: GirNamespace, options: GenerationOptions): string { + return this.type.print(namespace, options); + } + + static new({ type, user_data = null }: { type: TypeExpression; user_data?: number | null }) { + const vt = new ClosureType(type); + vt.user_data = user_data; + return vt; + } +} + +export class ArrayType extends TypeExpression { + type: TypeExpression; + arrayDepth: number = 1; + length: number | null = null; + + constructor(type: TypeExpression) { + super(); + this.type = type; + } + + deepUnwrap(): TypeExpression { + return this.type; + } + + unwrap(): TypeExpression { + return this; + } + + rewrap(type: TypeExpression): TypeExpression { + const array = new ArrayType(this.type.rewrap(type)); + + array.arrayDepth = this.arrayDepth; + array.length = this.length; + + return array; + } + + equals(type: TypeExpression) { + if (type instanceof ArrayType) { + const arrayType: ArrayType = type; + + return arrayType.type.equals(this.type) && type.arrayDepth === this.arrayDepth; + } + + return false; + } + + resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + const { type, arrayDepth, length } = this; + return ArrayType.new({ + type: type.resolve(namespace, options), + arrayDepth, + length + }); + } + + print(namespace: GirNamespace, options: GenerationOptions): string { + const depth = this.arrayDepth; + let typeSuffix: string = ""; + + if (depth === 0) { + typeSuffix = ""; + } else if (depth === 1) { + typeSuffix = "[]"; + } else { + typeSuffix = "".padStart(2 * depth, "[]"); + } + + return `${this.type.print(namespace, options)}${typeSuffix}`; + } + + static new({ + type, + arrayDepth = 1, + length = null + }: { + type: TypeExpression; + length?: number | null; + arrayDepth?: number; + }) { + const vt = new ArrayType(type); + vt.length = length; + vt.arrayDepth = arrayDepth; + return vt; + } +} + +export const GTypeType = new TypeIdentifier("GType", "GObject"); +export const ThisType = new NativeType("this"); +export const ObjectType = new NativeType("object"); +export const AnyType = new NativeType("any"); +export const NeverType = new NativeType("never"); +export const Uint8ArrayType = new NativeType("Uint8Array"); +export const BooleanType = new NativeType("boolean"); +export const StringType = new NativeType("string"); +export const NumberType = new NativeType("number"); +export const NullType = new NativeType("null"); +export const VoidType = new NativeType("void"); +export const UnknownType = new NativeType("unknown"); +export const AnyFunctionType = new NativeType("(...args: any[]) => any"); + +export type GirClassField = GirProperty | GirField; diff --git a/packages/lib/src/newlib/gir/alias.ts b/packages/lib/src/newlib/gir/alias.ts new file mode 100644 index 000000000..4a8a6008b --- /dev/null +++ b/packages/lib/src/newlib/gir/alias.ts @@ -0,0 +1,74 @@ +import { TypeExpression } from "../gir.js"; +import {GirBase, GirOptions, GirMetadata} from './base.js'; + +import { AliasElement } from "@gi.ts/parser"; +import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { sanitizeIdentifierName, getAliasType, parseDoc, parseMetadata } from "./util.js"; +import { FormatGenerator, GenericDescriptor } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; + +export class GirAlias extends GirBase { + readonly type: TypeExpression; + readonly generics: GenericDescriptor[]; + + constructor({ + name, + type, + generics = [], + ...args + }: GirOptions<{ + name: string; + type: TypeExpression; + generics?: GenericDescriptor[]; + }>) { + super(name, { ...args }); + + this.type = type; + this.generics = generics; + } + + accept(visitor: GirVisitor): GirAlias { + const node = this.copy({ + type: visitor.visitType?.(this.type) + }); + + return visitor.visitAlias?.(node) ?? node; + } + + copy(options?: { parent?: undefined; type?: TypeExpression }): GirAlias { + const { name, type } = this; + + return new GirAlias({ name, type: options?.type ?? type })._copyBaseProperties(this); + } + + asString>(generator: T): ReturnType { + return generator.generateAlias(this); + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + _parent, + m: AliasElement + ): GirAlias | null { + if (!m.$.name) { + console.error(`Alias in ${modName} lacks name.`); + return null; + } + + const alias = new GirAlias({ + name: sanitizeIdentifierName(ns.name, m.$.name), + type: getAliasType(modName, ns, m), + isIntrospectable: isIntrospectable(m) + }); + + if (options.loadDocs) { + alias.doc = parseDoc(m); + alias.metadata = parseMetadata(m); + } + + return alias; + } +} diff --git a/packages/lib/src/newlib/gir/base.ts b/packages/lib/src/newlib/gir/base.ts new file mode 100644 index 000000000..18ac7d437 --- /dev/null +++ b/packages/lib/src/newlib/gir/base.ts @@ -0,0 +1,102 @@ +import { FormatGenerator } from "../generators/index.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; +import { GirNamespace } from "./nodes.js"; + +export interface GirMetadata { + deprecated?: boolean; + deprecatedVersion?: string; + deprecatedDoc?: string; + introducedVersion?: string; + } + + export interface GirBaseOptions { + isPrivate?: boolean; + isIntrospectable?: boolean; + } + + export type GirOptions = GirBaseOptions & T; + + export abstract class GirBase { + name: string; + doc?: string | null; + metadata?: GirMetadata; + deprecated?: boolean; + resolve_names: string[] = []; + private _emit = true; + private _commentWarning?: string; + private _isPrivate: boolean; + private _isIntrospectable: boolean; + + constructor(name: string, options: GirBaseOptions = {}) { + this.name = name; + + this._isPrivate = options.isPrivate ?? false; + this._isIntrospectable = options.isIntrospectable ?? true; + } + + /** + * Set a warning to be emitted with this node. Often used to note type + * conflicts or potential differences from GJS code. + * + * @param warning + */ + setWarning(warning: string) { + this._commentWarning = warning; + } + + getWarning(): string | undefined { + return this._commentWarning; + } + + get isIntrospectable() { + return this._isIntrospectable; + } + + get isPrivate() { + return this._isPrivate; + } + + setPrivate(priv: boolean) { + this._isPrivate = priv; + } + + noEmit() { + this._emit = false; + } + + get emit() { + return this._emit; + } + + protected _copyBaseProperties(from: this): this { + this.doc = from.doc; + this.metadata = from.metadata; + this.deprecated = from.deprecated; + this.resolve_names = from.resolve_names; + + // Whether this node should be emitted. + this._emit = from._emit; + this._isPrivate = from._isPrivate; + this._isIntrospectable = from.isIntrospectable; + + return this; + } + + abstract copy(options?: { parent?: GirBase }): GirBase; + + abstract accept(visitor: GirVisitor): GirBase; + + static fromXML( + _modName: string, + _ns: GirNamespace, + _options: LoadOptions, + _parent: GirBase | null, + _gir: object + ): GirBase | null { + throw new Error("GirBase cannot be instantiated"); + } + + abstract asString, K extends any>(generator: T): K | null; + } + \ No newline at end of file diff --git a/packages/lib/src/newlib/gir/class.ts b/packages/lib/src/newlib/gir/class.ts new file mode 100644 index 000000000..1d8df724f --- /dev/null +++ b/packages/lib/src/newlib/gir/class.ts @@ -0,0 +1,1618 @@ +import { + + NativeType, + TypeIdentifier, + + NeverType, + ArrayType, + ClosureType, + BinaryType, + PromiseType, + VoidType, + TupleType, + BooleanType, + Generic, + GenericType, + GenerifiedTypeIdentifier, + AnyType, + ConflictType, + TypeConflict +} from "../gir.js"; +import { TypeExpression } from "../gir.js"; +import {GirBase, GirOptions, GirMetadata} from './base.js'; + +import { InterfaceElement, ClassElement, RecordElement, Direction, UnionElement } from "@gi.ts/parser"; +import { + GirClassFunction, + GirVirtualClassFunction, + GirStaticClassFunction, + GirCallback, + GirFunction, + GirConstructor, + GirFunctionParameter, + GirDirectAllocationConstructor +} from "./function.js"; +import { GirProperty, GirField } from "./property.js"; +import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { + sanitizeIdentifierName, + parseTypeIdentifier, + isSubtypeOf, + resolveTypeIdentifier, + parseDoc, + parseMetadata +} from "./util.js"; +import { GirSignal } from "./signal.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; +import { GenericNameGenerator } from "./generics.js"; +import { findMap } from "../util.js"; + +export enum FilterBehavior { + DELETE, + PRESERVE +} + +export function filterConflicts( + ns: GirNamespace, + c: GirBaseClass, + elements: T[], + behavior = FilterBehavior.PRESERVE +): T[] { + const filtered = [...elements.filter(p => p && p.name)]; + const prev = [] as T[]; + const thisType = c.getType(); + for (const next of filtered) { + const field_conflicts = c.findParentMap(resolved_parent => { + return findMap([...resolved_parent.fields], p => { + if (p.name && p.name == next.name) { + if (next instanceof GirProperty) { + return ConflictType.ACCESSOR_PROPERTY_CONFLICT; + } + + if ( + next instanceof GirField && + !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) + ) { + return ConflictType.FIELD_NAME_CONFLICT; + } + } + + return undefined; + }); + }); + + const prop_conflicts = !field_conflicts + ? c.findParentMap(resolved_parent => { + return findMap([...resolved_parent.props], p => { + if (p.name && p.name == next.name) { + if (next instanceof GirField) { + return ConflictType.PROPERTY_ACCESSOR_CONFLICT; + } + + if ( + next instanceof GirProperty && + !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) + ) { + console.log( + `>> Conflict in ${next.parent?.name}.${next.name} with ${p.parent?.name}.${p.name}.` + ); + return ConflictType.PROPERTY_NAME_CONFLICT; + } + } + + return undefined; + }); + }) + : undefined; + + let function_conflicts = + !field_conflicts && !prop_conflicts + ? c.findParentMap(resolved_parent => + findMap([...resolved_parent.constructors, ...resolved_parent.members], p => { + if (p.name && p.name == next.name) { + if ( + !(next instanceof GirClassFunction) || + isConflictingFunction(ns, thisType, next, resolved_parent.getType(), p) + ) { + return ConflictType.FUNCTION_NAME_CONFLICT; + } + } + + return undefined; + }) + ) + : undefined; + const conflict = field_conflicts || prop_conflicts || function_conflicts; + if (conflict) { + if (behavior === FilterBehavior.PRESERVE) { + if (next instanceof GirField || next instanceof GirProperty) { + prev.push( + next.copy({ + type: new TypeConflict(next.type, conflict) + }) as T + ); + } else { + prev.push(next); + } + } + } else { + prev.push(next); + } + } + + return prev; +} + +function isConflictingFunction( + namespace: GirNamespace, + childThis: TypeIdentifier, + child: GirFunction | GirClassFunction | GirConstructor, + parentThis: TypeIdentifier, + parent: GirClassFunction | GirFunction | GirConstructor +) { + if (child instanceof GirConstructor && parent instanceof GirConstructor) { + return ( + child.parameters.length > parent.parameters.length || + !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || + child.parameters.some( + (p, i) => !isSubtypeOf(namespace, childThis, parentThis, p.type, parent.parameters[i].type) + ) + ); + } else if (child instanceof GirConstructor || parent instanceof GirConstructor) { + return true; + } + + // This occurs if two functions of the same name are passed but they + // are different types (e.g. GirStaticClassFunction vs GirClassFunction) + if (Object.getPrototypeOf(child) !== Object.getPrototypeOf(parent)) { + return false; + } + + return ( + child.parameters.length > parent.parameters.length || + child.output_parameters.length !== parent.output_parameters.length || + !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || + child.parameters.some( + (np, i) => !isSubtypeOf(namespace, childThis, parentThis, np.type, parent.parameters[i].type) + ) || + child.output_parameters.some( + (np, i) => !isSubtypeOf(namespace, childThis, parentThis, np.type, parent.output_parameters[i].type) + ) + ); +} + +export function filterFunctionConflict< + T extends GirStaticClassFunction | GirVirtualClassFunction | GirClassFunction | GirConstructor +>(ns: GirNamespace, base: GirBaseClass, elements: T[], conflict_ids: string[]) { + const nextType = base.getType(); + return elements + .filter(m => m.name) + .reduce((prev, next) => { + // TODO This should catch most of them. + let msg: string | null = null; + let conflicts = + conflict_ids.includes(next.name) || + base.someParent(resolved_parent => { + const parentType = resolved_parent.getType(); + return [...resolved_parent.constructors, ...resolved_parent.members].some(p => { + if (p.name && p.name == next.name) { + let conflicting = isConflictingFunction(ns, nextType, next, parentType, p); + + if (conflicting) { + msg = `// Conflicted with ${resolved_parent.namespace.name}.${resolved_parent.name}.${p.name}`; + return true; + } + return conflicting; + } + return false; + }); + }); + + let field_conflicts = base.someParent(resolved_parent => + [...resolved_parent.props, ...resolved_parent.fields].some(p => p.name && p.name == next.name) + ); + + const isGObject = base.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); + + if (isGObject) { + conflicts = conflicts || ["connect", "connect_after", "emit"].includes(next.name); + } + + if (conflicts) { + let never: GirConstructor | GirFunction | GirStaticClassFunction | GirVirtualClassFunction; + + const never_param = new GirFunctionParameter({ + name: "args", + direction: Direction.In, + isVarArgs: true, + type: new ArrayType(NeverType) + }); + + const neverOptions = { + name: next.name, + parameters: [never_param], + return_type: AnyType + }; + + if (next instanceof GirConstructor) { + never = new GirConstructor(neverOptions); + } else if (next instanceof GirStaticClassFunction) { + never = new GirStaticClassFunction({ ...neverOptions, parent: next.parent }); + } else if (next instanceof GirVirtualClassFunction && next.parent instanceof GirClass) { + never = new GirVirtualClassFunction({ ...neverOptions, parent: next.parent }); + } else if (next instanceof GirClassFunction) { + never = new GirClassFunction({ ...neverOptions, parent: next.parent }); + } else { + throw new Error(`Unknown function type ${Object.getPrototypeOf(next)?.name} encountered.`); + } + + if (msg) never.setWarning(msg); + + prev.push(next, never as T); + } else if (field_conflicts) { + console.error(`Omitting ${next.name} due to field conflict.`); + } else { + prev.push(next); + } + + return prev; + }, [] as T[]); +} + +export function promisifyFunctions(functions: GirClassFunction[]) { + return functions + .map(node => { + if (node.parameters.length > 0) { + const last_param = node.parameters[node.parameters.length - 1]; + + if (last_param) { + const last_param_unwrapped = last_param.type.unwrap(); + + if (last_param_unwrapped instanceof ClosureType) { + const internal = last_param_unwrapped.type; + if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { + const parent = node.parent; + const interfaceParent = node.interfaceParent; + + if (parent instanceof GirBaseClass) { + let async_res = ( + node instanceof GirStaticClassFunction + ? [ + ...parent.constructors, + ...parent.members.filter(m => m instanceof GirStaticClassFunction) + ] + : [ + ...(interfaceParent instanceof GirInterface ? [...interfaceParent.members] : []), + ...parent.members.filter(m => !(m instanceof GirStaticClassFunction)) + ] + ).find( + m => + m.name === `${node.name.replace(/_async$/, "")}_finish` || + m.name === `${node.name}_finish` + ); + + if (async_res) { + const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); + const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); + const output_parameters = + async_res instanceof GirConstructor ? [] : async_res.output_parameters; + + let async_return = new PromiseType(async_res.return()); + + if (output_parameters.length > 0) { + const raw_return = async_res.return(); + if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { + const [output_type, ...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(output_type, ...output_types)); + } else { + const [...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(raw_return, ...output_types)); + } + } + + return [ + node.copy({ + parameters: async_parameters, + returnType: async_return + }), + node.copy({ + parameters: sync_parameters + }), + node.copy({ + returnType: new BinaryType(async_return, node.return()) + }) + ]; + } + } + } + } + } + } + + return node; + }) + .flat(1); +} + +export const enum ClassInjectionMember { + MEMBER = "member", + CONSTRUCTOR = "_constructor", + PROPERTY = "prop", + FIELD = "field", + MAIN_CONSTRUCTOR = "constructor" +} + +export interface ClassDefinition { + parent: TypeIdentifier; + interfaces: TypeIdentifier[]; + mainConstructor: GirConstructor; + constructors: GirConstructor[]; + members: GirClassFunction[]; + props: GirProperty[]; + fields: GirField[]; + callbacks: GirCallback[]; +} + +export interface ResolutionNode { + identifier: TypeIdentifier; + node: GirBaseClass; +} + +export interface InterfaceResolution extends ResolutionNode, Iterable { + extends(): InterfaceResolution | ClassResolution | undefined; + node: GirInterface; +} + +export interface ClassResolution extends ResolutionNode, Iterable { + extends(): ClassResolution | undefined; + implements(): InterfaceResolution[]; + node: GirClass; +} + +export interface RecordResolution extends ResolutionNode, Iterable { + extends(): RecordResolution | undefined; + node: GirRecord; +} + +export abstract class GirBaseClass extends GirBase { + namespace: GirNamespace; + indexSignature?: string; + parent: TypeIdentifier | null; + + mainConstructor: null | GirConstructor | GirDirectAllocationConstructor; + constructors: GirConstructor[]; + members: GirClassFunction[]; + props: GirProperty[]; + fields: GirField[]; + callbacks: GirCallback[]; + + // Generics support + generics: Generic[] = []; + + constructor( + options: { + name: string; + namespace: GirNamespace; + isIntrospectable?: boolean; + } & Partial + ) { + const { + name, + namespace, + parent = null, + mainConstructor = null, + constructors = [], + members = [], + props = [], + fields = [], + callbacks = [], + ...args + } = options; + + super(name, { ...args }); + + this.namespace = namespace; + this.parent = parent; + + this.mainConstructor = mainConstructor?.copy() ?? null; + this.constructors = [...constructors.map(c => c.copy())]; + this.members = [...members.map(m => m.copy({ parent: this }))]; + this.props = [...props.map(p => p.copy({ parent: this }))]; + this.fields = [...fields.map(f => f.copy({ parent: this }))]; + this.callbacks = [...callbacks.map(c => c.copy())]; + } + + abstract accept(visitor: GirVisitor): GirBaseClass; + + abstract copy(options?: { + parent?: undefined; + constructors?: GirConstructor[]; + members?: GirClassFunction[]; + props?: GirProperty[]; + fields?: GirField[]; + callbacks?: GirCallback[]; + }): GirBaseClass; + + getGenericName = GenericNameGenerator.new(); + + abstract resolveParents(): RecordResolution | InterfaceResolution | ClassResolution; + abstract someParent(predicate: (b: GirBaseClass) => boolean): boolean; + abstract findParent(predicate: (b: GirBaseClass) => boolean): GirBaseClass | undefined; + abstract findParentMap(predicate: (b: GirBaseClass) => K | undefined): K | undefined; + + addGeneric(definition: { + deriveFrom?: TypeIdentifier; + default?: TypeExpression; + constraint?: TypeExpression; + propagate?: boolean; + }) { + const param = new Generic( + new GenericType(this.getGenericName(), definition.constraint), + definition.default, + definition.deriveFrom, + definition.constraint, + definition.propagate + ); + + this.generics.push(param); + } + + getType(): TypeIdentifier { + return new TypeIdentifier(this.name, this.namespace.name); + } + + static fromXML( + _modName: string, + _ns: GirNamespace, + _options: LoadOptions, + _parent, + _klass: ClassElement | InterfaceElement | RecordElement + ): GirBaseClass { + throw new Error("fromXML is not implemented on GirBaseClass"); + } + + abstract asString(generator: FormatGenerator): T; +} + +export class GirClass extends GirBaseClass { + signals: GirSignal[] = []; + interfaces: TypeIdentifier[] = []; + isAbstract: boolean = false; + mainConstructor: null | GirConstructor = null; + private _staticDefinition: string | null = null; + + constructor(name: string, namespace: GirNamespace) { + super({ name, namespace }); + } + + accept(visitor: GirVisitor): GirClass { + const node = this.copy({ + signals: this.signals.map(s => s.accept(visitor)), + constructors: this.constructors.map(c => c.accept(visitor)), + members: this.members.map(m => m.accept(visitor)), + props: this.props.map(p => p.accept(visitor)), + fields: this.fields.map(f => f.accept(visitor)), + callbacks: this.callbacks.map(c => c.accept(visitor)) + }); + return visitor.visitClass?.(node) ?? node; + } + + hasInstanceSymbol(s: GirBase): boolean { + return ( + this.members.some(p => s.name === p.name && !(p instanceof GirStaticClassFunction)) || + this.props.some(p => s.name === p.name) || + this.fields.some(p => s.name === p.name) + ); + } + + someParent(predicate: (p: GirClass | GirInterface) => boolean): boolean { + const resolution = this.resolveParents(); + const parent = resolution.extends(); + + if (parent) { + if (predicate(parent.node)) return true; + + const some = parent.node.someParent(predicate); + + if (some) return some; + } + + return ( + resolution + .implements() + .map(i => i.node) + .some(n => predicate(n)) || resolution.implements().some(i => i.node.someParent(predicate)) + ); + } + + findParent(predicate: (p: GirClass | GirInterface) => boolean): GirClass | GirInterface | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); + + if (parent) { + if (predicate(parent.node)) return this; + + const found = parent.node.findParent(predicate); + + if (found) return found; + } + + const interfaces = resolution.implements().map(i => i.node); + return interfaces.find(n => predicate(n)) || interfaces.find(n => n.findParent(predicate)); + } + + findParentMap(predicate: (p: GirClass | GirInterface) => K | undefined): K | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); + + if (parent) { + let found = predicate(parent.node); + + if (found !== undefined) return found; + + found = parent.node.findParentMap(predicate); + + if (found !== undefined) return found; + } + + const interfaces = resolution.implements().map(i => i.node); + + const result = findMap(interfaces, i => predicate(i)); + if (result !== undefined) return result; + + return findMap(interfaces, i => i.findParentMap(predicate)); + } + + implementedProperties(potentialConflicts: GirBase[] = []) { + const resolution = this.resolveParents(); + const implemented_on_parent = [...(resolution.extends() ?? [])] + .map(r => r.implements()) + .flat() + .map(i => i.identifier); + const properties = new Map(); + + const validateProp = (prop: GirProperty) => + !this.hasInstanceSymbol(prop) && + !properties.has(prop.name) && + potentialConflicts.every(p => prop.name !== p.name); + + for (const implemented of resolution.implements()) { + if (implemented.node instanceof GirClass) continue; + + if (implemented_on_parent.some(p => p.equals(implemented.identifier))) continue; + + for (const prop of implemented.node.props) { + if (!validateProp(prop)) { + continue; + } + properties.set(prop.name, prop.copy({ parent: this })); + } + } + + for (const implemented of resolution.implements()) { + [...implemented].forEach(e => { + if (e.node instanceof GirClass) return; + + if (implemented_on_parent.some(p => p.equals(e.identifier))) return; + + for (const prop of e.node.props) { + if (!validateProp(prop)) { + continue; + } + + properties.set(prop.name, prop.copy({ parent: this })); + } + }); + } + + return [...properties.values()]; + } + + implementedMethods(potentialConflicts: GirBase[] = []) { + const resolution = this.resolveParents(); + const implemented_on_parent = [...(resolution.extends() ?? [])].map(r => r.implements()).flat(); + const methods = new Map(); + + const validateMethod = (method: GirClassFunction) => + !(method instanceof GirStaticClassFunction) && + !this.hasInstanceSymbol(method) && + !methods.has(method.name) && + potentialConflicts.every(m => method.name !== m.name); + + for (const implemented of resolution.implements()) { + if (implemented.node instanceof GirClass) continue; + + if ( + implemented_on_parent.find(p => p.identifier.equals(implemented.identifier))?.node?.generics + ?.length === 0 + ) + continue; + for (const member of implemented.node.members) { + if (!validateMethod(member)) continue; + methods.set(member.name, member); + } + } + + for (const implemented of resolution.implements()) { + [...implemented].forEach(e => { + if (e.node instanceof GirClass) return; + + if (implemented_on_parent.find(p => p.identifier.equals(e.identifier))?.node.generics.length === 0) + return; + for (const member of e.node.members) { + if (!validateMethod(member)) continue; + + methods.set(member.name, member); + } + }); + } + + return [...methods.values()].map(f => { + const mapping = new Map(); + if (f.parent instanceof GirBaseClass) { + const inter = this.interfaces.find(i => i.equals(f.parent.getType())); + + if (inter instanceof GenerifiedTypeIdentifier) { + f.parent.generics.forEach((g, i) => { + if (inter.generics.length > i) { + mapping.set(g.type.identifier, inter.generics[i]); + } + }); + } + } + + const unwrapped = f.return().deepUnwrap(); + let modifiedReturn = f.return(); + + if (unwrapped instanceof GenericType && mapping.has(unwrapped.identifier)) { + let mapped = mapping.get(unwrapped.identifier); + + if (mapped) { + modifiedReturn = f.return().rewrap(mapped); + } + // Handles the case where a class implements an interface and thus copies its virtual methods. + } else if (unwrapped.equals(this.getType())) { + modifiedReturn = f.return().rewrap(this.getType()); + } + + return f.copy({ + parent: this, + interfaceParent: f.parent, + parameters: f.parameters.map(p => { + const t = p.type.deepUnwrap(); + if (t instanceof GenericType && mapping.has(t.identifier)) { + const iden = mapping.get(t.identifier); + + if (iden) { + return p.copy({ type: p.type.rewrap(iden) }); + } + } + + return p; + }), + outputParameters: f.output_parameters.map(p => { + const t = p.type.deepUnwrap(); + if (t instanceof GenericType && mapping.has(t.identifier)) { + const iden = mapping.get(t.identifier); + + if (iden) { + return p.copy({ type: p.type.rewrap(iden) }); + } + } + + return p; + }), + returnType: modifiedReturn + }); + }); + } + + resolveParents(): ClassResolution { + let { namespace, parent, interfaces } = this; + + return { + *[Symbol.iterator]() { + let current = this.extends(); + + while (current !== undefined) { + yield current; + current = current.extends(); + } + }, + implements() { + const z = interfaces + .map(i => resolveTypeIdentifier(namespace, i)) + .filter((i): i is GirInterface => i instanceof GirInterface) + .map(i => i.resolveParents()); + + return z; + }, + extends() { + let parentType = parent; + let resolved_parent = parentType && resolveTypeIdentifier(namespace, parentType); + if (resolved_parent instanceof GirClass) return resolved_parent.resolveParents(); + return undefined; + }, + node: this, + identifier: this.getType() + }; + } + + copy( + options: { + parent?: undefined; + signals?: GirSignal[]; + constructors?: GirConstructor[]; + members?: GirClassFunction[]; + props?: GirProperty[]; + fields?: GirField[]; + callbacks?: GirCallback[]; + } = {} + ): GirClass { + const { + name, + namespace, + parent, + interfaces, + members, + constructors, + props, + fields, + callbacks, + isAbstract, + mainConstructor, + signals, + generics, + _staticDefinition + } = this; + + const clazz = new GirClass(name, namespace); + + clazz._copyBaseProperties(this); + + if (parent) { + clazz.parent = parent; + } + + clazz._staticDefinition = _staticDefinition; + clazz.signals = (options.signals ?? signals).map(s => s.copy()); + clazz.interfaces = [...interfaces]; + clazz.props = (options.props ?? props).map(p => p.copy()); + clazz.fields = (options.fields ?? fields).map(f => f.copy()); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.isAbstract = isAbstract; + clazz.mainConstructor = mainConstructor; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); + clazz.generics = [...generics]; + + // Ensure the generic iteration resumes + clazz.getGenericName = GenericNameGenerator.at(this.getGenericName()); + + return clazz; + } + + get staticDefinition() { + return this._staticDefinition; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + _parent, + klass: ClassElement + ): GirClass { + const name = sanitizeIdentifierName(ns.name, klass.$.name); + + if (options.verbose) { + console.debug(` >> GirClass: Parsing definition ${klass.$.name} (${name})...`); + } + + const clazz = new GirClass(name, ns); + + if (options.loadDocs) { + clazz.doc = parseDoc(klass); + clazz.metadata = parseMetadata(klass); + } + + if (klass.$["glib:type-name"]) { + clazz.resolve_names.push(klass.$["glib:type-name"]); + + ns.registerResolveName(klass.$["glib:type-name"], ns.name, name); + } + + if (klass.$["glib:type-struct"]) { + clazz.resolve_names.push(); + + ns.registerResolveName(klass.$["glib:type-struct"], ns.name, name); + } + + if (klass.$["c:type"]) { + clazz.resolve_names.push(klass.$["c:type"]); + + ns.registerResolveName(klass.$["c:type"], ns.name, name); + } + + const typeStruct = klass.$["glib:type-struct"]; + if (typeStruct) { + clazz.registerStaticDefinition(typeStruct); + + clazz.resolve_names.push(typeStruct); + + ns.registerResolveName(typeStruct, ns.name, name); + } + + try { + // Setup parent type if this is an interface or class. + if (klass.$.parent) { + clazz.parent = parseTypeIdentifier(modName, klass.$.parent); + } + + if (klass.$.abstract) { + clazz.isAbstract = true; + } + + if (Array.isArray(klass.constructor)) { + clazz.constructors.push( + ...klass.constructor.map(constructor => + GirConstructor.fromXML(modName, ns, options, clazz, constructor) + ) + ); + } + + if (klass["glib:signal"]) { + clazz.signals.push( + ...klass["glib:signal"].map(signal => GirSignal.fromXML(modName, ns, options, clazz, signal)) + ); + } + + // Properties + if (klass.property) { + klass.property.forEach(prop => { + const property = GirProperty.fromXML(modName, ns, options, clazz, prop); + switch (options.propertyCase) { + case "both": + clazz.props.push(property); + + const camelCase = property.toCamelCase(); + + // Ensure we don't duplicate properties like 'show' + if (property.name !== camelCase.name) { + clazz.props.push(camelCase); + } + + break; + case "camel": + clazz.props.push(property.toCamelCase()); + break; + case "underscore": + clazz.props.push(property); + break; + } + }); + } + + // Instance Methods + if (klass.method) { + clazz.members.push( + ...klass.method.map(method => GirClassFunction.fromXML(modName, ns, options, clazz, method)) + ); + } + + // Fields + if (klass.field) { + klass.field + .filter(field => !("callback" in field)) + .forEach(field => { + const f = GirField.fromXML(modName, ns, options, null, field); + + clazz.fields.push(f); + }); + } + + if (klass.implements) { + klass.implements.forEach(implementee => { + const name = implementee.$.name; + const type = parseTypeIdentifier(modName, name); + + // Sometimes namespaces will implicitly import + // other namespaces like Atk via interface implements. + if (type && type.namespace && type.namespace !== modName && !ns.hasImport(type.namespace)) { + ns.addImport(type.namespace); + } + + if (type) { + clazz.interfaces.push(type); + } + }); + } + + // Callback Types + if (klass.callback) { + clazz.callbacks.push( + ...klass.callback.map(callback => { + if (options.verbose) { + console.debug(`Adding callback ${callback.$.name} for ${modName}`); + } + + return GirCallback.fromXML(modName, ns, options, clazz, callback); + }) + ); + } + + // Virtual Methods + if (klass["virtual-method"]) { + clazz.members.push( + ...klass["virtual-method"].map(method => + GirVirtualClassFunction.fromXML(modName, ns, options, clazz, method) + ) + ); + } + + // Static methods (functions) + if (klass.function) { + clazz.members.push( + ...klass.function.map(func => GirStaticClassFunction.fromXML(modName, ns, options, clazz, func)) + ); + } + } catch (e) { + console.error(`Failed to parse class: ${clazz.name} in ${ns.name}.`); + console.error(e); + } + + return clazz; + } + registerStaticDefinition(typeStruct: string) { + this._staticDefinition = typeStruct; + } + + asString>(generator: T): ReturnType { + return generator.generateClass(this); + } +} + +export class GirRecord extends GirBaseClass { + private _isForeign: boolean = false; + private _structFor: TypeIdentifier | null = null; + private _isSimple: boolean | null = null; + private _isSimpleWithoutPointers: string | null = null; + + isForeign(): boolean { + return this._isForeign; + } + + getType(): TypeIdentifier { + if (this._structFor) { + return this._structFor; + } + + return new TypeIdentifier(this.name, this.namespace.name); + } + + someParent(predicate: (p: GirRecord) => boolean): boolean { + const resolution = this.resolveParents(); + const parent = resolution.extends(); + + return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); + } + + findParent(predicate: (p: GirRecord) => boolean): GirRecord | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); + + if (parent) { + if (predicate(parent.node)) return parent.node; + + const found = parent.node.findParent(predicate); + + if (found) return found; + } + + return undefined; + } + + findParentMap(predicate: (p: GirRecord) => K | undefined): K | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); + + if (parent) { + const result = predicate(parent.node); + + if (result !== undefined) return result; + + return parent.node.findParentMap(predicate); + } + + return undefined; + } + + accept(visitor: GirVisitor): GirRecord { + const node = this.copy({ + constructors: this.constructors.map(c => c.accept(visitor)), + members: this.members.map(m => m.accept(visitor)), + props: this.props.map(p => p.accept(visitor)), + fields: this.fields.map(f => f.accept(visitor)), + callbacks: this.callbacks.map(c => c.accept(visitor)) + }); + + return visitor.visitRecord?.(node) ?? node; + } + + resolveParents(): RecordResolution { + let { namespace, parent } = this; + + return { + *[Symbol.iterator]() { + let current = this.extends(); + + while (current !== undefined) { + yield current; + current = current.extends(); + } + }, + extends() { + let parentType = parent; + let resolved_parent = parentType ? resolveTypeIdentifier(namespace, parentType) : undefined; + if (resolved_parent instanceof GirRecord) return resolved_parent.resolveParents(); + + return undefined; + }, + node: this, + identifier: this.getType() + }; + } + + copy( + options: { + parent?: undefined; + constructors?: GirConstructor[]; + members?: GirClassFunction[]; + props?: GirProperty[]; + fields?: GirField[]; + callbacks?: GirCallback[]; + } = {} + ): GirRecord { + const { + name, + namespace, + parent, + members, + constructors, + _isForeign, + _structFor, + props, + fields, + callbacks, + generics, + mainConstructor + } = this; + + const clazz = new GirRecord({ name, namespace }); + + clazz._copyBaseProperties(this); + + if (parent) { + clazz.parent = parent; + } + + clazz._structFor = _structFor; + clazz._isForeign = _isForeign; + clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); + clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.mainConstructor = mainConstructor?.copy() ?? null; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); + clazz.generics = [...generics]; + + return clazz; + } + + static foreign(name: string, namespace: GirNamespace): GirRecord { + const foreignRecord = new GirRecord({ name, namespace }); + foreignRecord._isForeign = true; + return foreignRecord; + } + + static fromXML( + modName: string, + namespace: GirNamespace, + options: LoadOptions, + klass: RecordElement | UnionElement + ): GirRecord { + if (!klass.$.name) { + throw new Error(`Invalid GIR File: No name provided for union.`); + } + + const name = sanitizeIdentifierName(namespace.name, klass.$.name); + + if (options.verbose) { + console.debug(` >> GirRecord: Parsing definition ${klass.$.name} (${name})...`); + } + + const clazz = new GirRecord({ name, namespace }); + + clazz.setPrivate( + klass.$.name.startsWith("_") || + ("disguised" in klass.$ && klass.$.disguised === "1") || + // Don't generate records for structs + (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) + ); + + if (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) { + clazz.noEmit(); + + // This let's us replace these references when generating. + clazz._structFor = parseTypeIdentifier(modName, klass.$["glib:is-gtype-struct-for"]); + } else { + if (klass.$["glib:type-name"]) { + clazz.resolve_names.push(klass.$["glib:type-name"]); + + namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); + } + + if (klass.$["glib:type-struct"]) { + clazz.resolve_names.push(); + + namespace.registerResolveName(klass.$["glib:type-struct"], namespace.name, name); + } + + if (klass.$["c:type"]) { + clazz.resolve_names.push(klass.$["c:type"]); + + namespace.registerResolveName(klass.$["c:type"], namespace.name, name); + } + } + + if (options.loadDocs) { + clazz.doc = parseDoc(klass); + clazz.metadata = parseMetadata(klass); + } + + try { + // Instance Methods + if (klass.method) { + clazz.members.push( + ...klass.method.map(method => GirClassFunction.fromXML(modName, namespace, options, clazz, method)) + ); + } + + // Constructors + if (Array.isArray(klass.constructor)) { + klass.constructor.forEach(constructor => { + const c = GirConstructor.fromXML(modName, namespace, options, clazz, constructor); + + clazz.constructors.push(c); + }); + } + + // Static methods (functions) + if (klass.function) { + clazz.members.push( + ...klass.function.map(func => + GirStaticClassFunction.fromXML(modName, namespace, options, clazz, func) + ) + ); + } + + // Is this a foreign type? (don't allow construction if foreign) + + clazz._isForeign = "foreign" in klass.$ && klass.$.foreign === "1"; + + // Fields (for "non-class" records) + if (klass.field) { + clazz.fields.push( + ...klass.field + .filter(field => !("callback" in field)) + .map(field => GirField.fromXML(modName, namespace, options, null, field)) + ); + } + } catch (e) { + console.error(`Failed to parse record: ${clazz.name}.`); + console.error(e); + } + + return clazz; + } + + /** + * Calculate if a type expression is "simple" without pointers + */ + isSimpleTypeWithoutPointers(typeContainer: TypeExpression): boolean { + if (!this.isSimpleType(typeContainer)) { + return false; + } + + if (typeContainer.isPointer) { + return false; + } + + // Primitive types can be directly allocated. + if (typeContainer instanceof NativeType) { + return true; + } + + if (typeContainer instanceof ArrayType) { + if (typeContainer.type.equals(this.getType())) { + return true; + } + + return this.isSimpleTypeWithoutPointers(typeContainer.type); + } + + if (typeContainer instanceof TypeIdentifier) { + const type = typeContainer; + + const child_ns = this.namespace.assertInstalledImport(type.namespace); + + const alias = child_ns.getAlias(type.name); + if (alias) { + return this.isSimpleTypeWithoutPointers(alias.type); + } + + const child = child_ns.getClass(type.name); + if (child === this) { + return false; + } + + if (child instanceof GirRecord) { + return child.isSimpleWithoutPointers() !== null; + } + } + + return false; + } + + /** + * Calculate if a type expression is "simple" + */ + isSimpleType(typeContainer: TypeExpression): boolean { + // Primitive types can be directly allocated. + if (typeContainer instanceof NativeType) { + return true; + } + + if (typeContainer instanceof ArrayType) { + if (typeContainer.type.equals(this.getType())) { + return true; + } + + return this.isSimpleType(typeContainer.type); + } + + if (typeContainer instanceof TypeIdentifier) { + const type = typeContainer; + + const child_ns = this.namespace.assertInstalledImport(type.namespace); + + const alias = child_ns.getAlias(type.name); + if (alias) { + return this.isSimpleType(alias.type); + } + + const child = child_ns.getClass(type.name); + if (child === this) { + return false; + } + + if (child instanceof GirRecord) { + return child.isSimple(); + } + } + + return false; + } + + /** + * Check if a record is "simple" and can be constructed by GJS + */ + isSimple() { + // Records with no fields are not + // constructable. + if (this.fields.length === 0) { + return false; + } + + // Because we may have to recursively check + // if types are instantiable we cache whether + // or not a given Record is simple. + if (this._isSimple !== null) { + return this._isSimple; + } + + const isSimple = this.fields.every(f => this.isSimpleType(f.type)); + + this._isSimple = isSimple; + + return isSimple; + } + + isSimpleWithoutPointers() { + // Records which are "simple without pointers" is a subset of + // "simple" records. + if (!this.isSimple()) { + return null; + ("not simple"); + } + + // Because we may have to recursively check + // if types are instantiable we cache whether + // or not a given Record is simple. + if (this._isSimpleWithoutPointers !== null) { + return this._isSimpleWithoutPointers; + } + + const isSimpleWithoutPointers = this.fields.find(f => { + return !this.isSimpleTypeWithoutPointers(f.type); + }); + + if (!isSimpleWithoutPointers) this._isSimpleWithoutPointers = `all fields good`; + else this._isSimpleWithoutPointers = null; + + return this._isSimpleWithoutPointers; + } + + asString>(generator: T): ReturnType { + return generator.generateRecord(this); + } +} + +export class GirComplexRecord extends GirRecord { + isSimple() { + return false; + } +} + +export class GirInterface extends GirBaseClass { + noParent = false; + mainConstructor: null | GirConstructor = null; + + copy( + options: { + parent?: undefined; + noParent?: boolean; + constructors?: GirConstructor[]; + members?: GirClassFunction[]; + props?: GirProperty[]; + fields?: GirField[]; + callbacks?: GirCallback[]; + } = {} + ): GirInterface { + const { + name, + namespace, + parent, + noParent, + members, + constructors, + props, + fields, + callbacks, + mainConstructor, + generics + } = this; + + const clazz = new GirInterface({ name, namespace }); + + clazz._copyBaseProperties(this); + + clazz.noParent = noParent; + + if (parent) { + clazz.parent = parent; + } + + clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); + clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.mainConstructor = mainConstructor?.copy() ?? null; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); + clazz.generics = [...generics]; + + return clazz; + } + + someParent(predicate: (p: GirClass | GirInterface) => boolean): boolean { + const resolution = this.resolveParents(); + const parent = resolution.extends(); + + return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); + } + + findParent(predicate: (p: GirClass | GirInterface) => boolean): GirInterface | GirClass | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); + + if (parent) { + if (predicate(parent.node)) return parent.node; + + const found = parent.node.findParent(predicate); + + if (found) return found; + } + + return undefined; + } + + findParentMap(predicate: (p: GirClass | GirInterface) => K | undefined): K | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); + + if (parent) { + const result = predicate(parent.node); + + if (result !== undefined) return result; + + return parent.node.findParentMap(predicate); + } + + return undefined; + } + + resolveParents(): InterfaceResolution { + let { namespace, parent } = this; + return { + *[Symbol.iterator]() { + let current = this.extends(); + + while (current !== undefined) { + yield current; + current = current.extends(); + } + }, + extends() { + if (!parent) return undefined; + const resolved = resolveTypeIdentifier(namespace, parent); + if (resolved && (resolved instanceof GirClass || resolved instanceof GirInterface)) + return resolved.resolveParents(); + return undefined; + }, + node: this, + identifier: this.getType() + }; + } + + accept(visitor: GirVisitor): GirInterface { + const node = this.copy({ + constructors: this.constructors.map(c => c.accept(visitor)), + members: this.members.map(m => m.accept(visitor)), + props: this.props.map(p => p.accept(visitor)), + fields: this.fields.map(f => f.accept(visitor)), + callbacks: this.callbacks.map(c => c.accept(visitor)) + }); + + return visitor.visitInterface?.(node) ?? node; + } + + static fromXML( + modName: string, + namespace: GirNamespace, + options: LoadOptions, + klass: InterfaceElement + ): GirInterface { + const name = sanitizeIdentifierName(namespace.name, klass.$.name); + + if (options.verbose) { + console.debug(` >> GirInterface: Parsing definition ${klass.$.name} (${name})...`); + } + + const clazz = new GirInterface({ name, namespace }); + + if (options.loadDocs) { + clazz.doc = parseDoc(klass); + clazz.metadata = parseMetadata(klass); + } + + if (klass.$["glib:type-name"]) { + clazz.resolve_names.push(klass.$["glib:type-name"]); + + namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); + } + + if (klass.$["glib:type-struct"]) { + clazz.resolve_names.push(); + + namespace.registerResolveName(klass.$["glib:type-struct"], namespace.name, name); + } + + if (klass.$["c:type"]) { + clazz.resolve_names.push(klass.$["c:type"]); + + namespace.registerResolveName(klass.$["c:type"], namespace.name, name); + } + + try { + // Setup the "parent" (prerequisite) for this interface. + if (klass.prerequisite && klass.prerequisite[0]) { + const [prerequisite] = klass.prerequisite; + + clazz.parent = parseTypeIdentifier(modName, prerequisite.$.name); + } + + if (Array.isArray(klass.constructor)) { + for (let constructor of klass.constructor) { + clazz.constructors.push(GirConstructor.fromXML(modName, namespace, options, clazz, constructor)); + } + } + + // Properties + if (klass.property) { + clazz.props.push( + ...klass.property + + .map(prop => GirProperty.fromXML(modName, namespace, options, clazz, prop)) + .map(prop => { + switch (options.propertyCase) { + case "both": + const camelCase = prop.toCamelCase(); + + // Ensure we don't duplicate properties like 'show' + if (prop.name !== camelCase.name) { + return [prop, prop.toCamelCase()]; + } + + return [prop]; + case "camel": + return [prop.toCamelCase()]; + case "underscore": + return [prop]; + } + }) + .flat(1) + ); + } + + // Instance Methods + if (klass.method) { + for (let method of klass.method) { + const m = GirClassFunction.fromXML(modName, namespace, options, clazz, method); + + clazz.members.push(m); + } + } + + // Virtual Methods + if (klass["virtual-method"]) { + for (let method of klass["virtual-method"]) { + clazz.members.push(GirVirtualClassFunction.fromXML(modName, namespace, options, clazz, method)); + } + } + + // Callback Types + if (klass.callback) { + for (let callback of klass.callback) { + if (options.verbose) { + console.debug(`Adding callback ${callback.$.name} for ${modName}`); + } + + clazz.callbacks.push(GirCallback.fromXML(modName, namespace, options, clazz, callback)); + } + } + + // Static methods (functions) + if (klass.function) { + for (let func of klass.function) { + clazz.members.push(GirStaticClassFunction.fromXML(modName, namespace, options, clazz, func)); + } + } + } catch (e) { + console.error(`Failed to parse interface: ${clazz.name}.`); + console.error(e); + } + return clazz; + } + + asString>(generator: T): ReturnType { + return generator.generateInterface(this); + } +} diff --git a/packages/lib/src/newlib/gir/const.ts b/packages/lib/src/newlib/gir/const.ts new file mode 100644 index 000000000..bf4c55735 --- /dev/null +++ b/packages/lib/src/newlib/gir/const.ts @@ -0,0 +1,78 @@ +import { TypeExpression } from "../gir.js"; +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { ConstantElement } from "@gi.ts/parser"; + +import { GirNamespace } from "./namespace.js"; +import { getType, parseDoc, parseMetadata, sanitizeIdentifierName } from "./util.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; + +export class GirConst extends GirBase { + type: TypeExpression; + value: string | null; + + constructor({ + name, + type, + value + }: { + name: string; + type: TypeExpression; + value: string | null; + isIntrospectable?: boolean; + }) { + super(name); + + this.type = type; + this.value = value; + } + + accept(visitor: GirVisitor): GirConst { + const node = this.copy({ + type: visitor.visitType?.(this.type) + }); + + return visitor.visitConst?.(node) ?? node; + } + + copy( + options: { + parent?: undefined; + type?: TypeExpression; + } = {} + ): GirConst { + const { type, name, value } = this; + + return new GirConst({ + name, + type: options.type ?? type, + value + })._copyBaseProperties(this); + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + _parent, + constant: ConstantElement + ): GirConst { + const c = new GirConst({ + name: sanitizeIdentifierName(ns.name, constant.$.name), + type: getType(modName, ns, constant), + value: constant.$.value ?? null + }); + + if (options.loadDocs) { + c.doc = parseDoc(constant); + c.metadata = parseMetadata(constant); + } + + return c; + } + + asString>(generator: T): ReturnType { + return generator.generateConst(this); + } +} diff --git a/packages/lib/src/newlib/gir/enum.ts b/packages/lib/src/newlib/gir/enum.ts new file mode 100644 index 000000000..129a8154e --- /dev/null +++ b/packages/lib/src/newlib/gir/enum.ts @@ -0,0 +1,258 @@ +import { NumberType, TypeIdentifier } from "../gir.js"; + +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { MemberElement, EnumElement, BitfieldElement } from "@gi.ts/parser"; + +import { GirComplexRecord, GirRecord } from "./class.js"; +import { GirField } from "./property.js"; +import { GirStaticClassFunction } from "./function.js"; +import { GirNamespace } from "./namespace.js"; +import { parseDoc, parseMetadata, sanitizeIdentifierName, sanitizeMemberName } from "./util.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; + +export class GirEnum extends GirBase { + members = new Map(); + flags: boolean = false; + namespace: GirNamespace; + ns: string; + + constructor(name: string, namespace: GirNamespace, options: { isIntrospectable?: boolean } = {}) { + super(sanitizeIdentifierName(namespace.name, name)); + this.namespace = namespace; + this.ns = namespace.name; + } + + copy({ + members + }: { + parent?: undefined; + members?: Map; + } = {}): GirEnum { + const { namespace, name, flags } = this; + + const en = new GirEnum(name, namespace); + + for (const [key, member] of (members ?? this.members).entries()) { + en.members.set(key, member.copy()); + } + + en.flags = flags; + + en._copyBaseProperties(this); + + return en; + } + + accept(visitor: GirVisitor): GirEnum { + const node = this.copy({ + members: new Map( + Array.from(this.members.entries()).map(([name, m]) => { + return [name, m.accept(visitor)]; + }) + ) + }); + + return visitor.visitEnum?.(node) ?? node; + } + + getType(): TypeIdentifier { + return new TypeIdentifier(this.name, this.ns); + } + + asString>(generator: T): ReturnType { + return generator.generateEnum(this); + } + + asClass(): GirRecord { + const { name, namespace } = this; + + const clazz = new GirComplexRecord({ name, namespace }); + + clazz.fields.push( + ...Array.from(this.members.values()).map(m => { + const field = new GirField({ + name: m.name, + type: NumberType, + writable: true, + isStatic: true, + }); + + + field.doc = m.doc; + field.metadata = m.metadata; + + return field; + }) + ); + clazz.members = []; + return clazz; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + _parent, + m: EnumElement | BitfieldElement, + flags = false + ): GirEnum { + const em = new GirEnum(sanitizeMemberName(m.$.name), ns); + + if (m.$["glib:type-name"]) { + em.resolve_names.push(m.$["glib:type-name"]); + + ns.registerResolveName(m.$["glib:type-name"], ns.name, em.name); + } + + if (m.$["c:type"]) { + em.resolve_names.push(m.$["c:type"]); + + ns.registerResolveName(m.$["c:type"], ns.name, em.name); + } + + if (options.loadDocs) { + em.doc = parseDoc(m); + em.metadata = parseMetadata(m); + } + + if (!m.member) { + return em; + } + + m.member.forEach(m => { + const member = GirEnumMember.fromXML(modName, ns, options, em, m); + + em.members.set(member.name, member); + }); + + em.flags = flags; + + return em; + } +} + +export class GirEnumMember extends GirBase { + value: string; + c_identifier: string; + + constructor(name: string, value: string, c_identifier: string) { + super(name); + this.value = value; + this.c_identifier = c_identifier; + } + + accept(visitor: GirVisitor): GirEnumMember { + const node = this.copy(); + return visitor.visitEnumMember?.(node) ?? node; + } + + copy(): GirEnumMember { + const { value, name, c_identifier } = this; + + return new GirEnumMember(name, value, c_identifier)._copyBaseProperties(this); + } + + static fromXML( + _: string, + _ns: GirNamespace, + options: LoadOptions, + _parent, + m: MemberElement + ): GirEnumMember { + const upper = m.$.name.toUpperCase(); + const c_identifier = m.$["c:identifier"]; + + const enumMember = new GirEnumMember(upper, m.$.value, c_identifier); + + if (options.loadDocs) { + enumMember.doc = parseDoc(m); + enumMember.metadata = parseMetadata(m); + } + + return enumMember; + } + + asString>(generator: T): ReturnType { + return generator.generateEnumMember(this); + } +} + +function isEnumElement(e: unknown): e is EnumElement { + return typeof e === "object" && e != null && "function" in e; +} + +export class GirError extends GirEnum { + functions: Map = new Map(); + + asString>(generator: T): ReturnType { + return generator.generateError(this); + } + + copy({ + members + }: { + parent?: undefined; + members?: Map; + } = {}): GirEnum { + const { namespace, name, flags } = this; + + const en = new GirError(name, namespace); + + for (const [key, member] of (members ?? this.members).entries()) { + en.members.set(key, member.copy()); + } + + for (const [key, func] of this.functions.entries()) { + en.functions.set(key, func.copy({ parent: en })); + } + + en.flags = flags; + + return en._copyBaseProperties(this); + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent, + m: EnumElement | BitfieldElement + ): GirEnum { + const err = new GirError(sanitizeMemberName(m.$.name), ns); + + if (m.$["glib:type-name"]) { + err.resolve_names.push(m.$["glib:type-name"]); + + ns.registerResolveName(m.$["glib:type-name"], ns.name, err.name); + } + + if (m.$["c:type"]) { + err.resolve_names.push(m.$["c:type"]); + + ns.registerResolveName(m.$["c:type"], ns.name, err.name); + } + + if (options.loadDocs) { + err.doc = parseDoc(m); + err.metadata = parseMetadata(m); + } + + if (m.member) { + m.member.forEach(m => { + const member = GirEnumMember.fromXML(modName, ns, options, parent, m); + err.members.set(member.name, member); + }); + } + + if (isEnumElement(m) && m.function) { + m.function.forEach(f => { + const func = GirStaticClassFunction.fromXML(modName, ns, options, err, f); + err.functions.set(func.name, func); + }); + } + + return err; + } +} diff --git a/packages/lib/src/newlib/gir/function.ts b/packages/lib/src/newlib/gir/function.ts new file mode 100644 index 000000000..64f8256a5 --- /dev/null +++ b/packages/lib/src/newlib/gir/function.ts @@ -0,0 +1,874 @@ +import { + + TypeIdentifier, + UnknownType, + VoidType, + ArrayType, + ClosureType, + NullableType, + TypeExpression, + Generic, + FunctionType, + +} from "../gir.js"; + +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { + FunctionElement, + MethodElement, + Direction, + CallableParamElement, + CallbackElement, + VirtualMethodElement, + ConstructorElement +} from "@gi.ts/parser"; + +import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { + getType, + isInvalid, + sanitizeMemberName, + sanitizeIdentifierName, + parseDoc, + parseMetadata +} from "./util.js"; +import { GirBaseClass, GirClass } from "./class.js"; +import { GirEnum } from "./enum.js"; +import { GirSignal } from "./signal.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; +import { GirField } from "./property.js"; + +function hasShadow( + obj: FunctionElement | MethodElement +): obj is FunctionElement & { $: { shadows: string } } { + return obj.$["shadows"] != null; +} + +export class GirFunction extends GirBase { + readonly parameters: GirFunctionParameter[]; + readonly output_parameters: GirFunctionParameter[]; + readonly return_type: TypeExpression; + readonly raw_name: string; + + generics: Generic[] = []; + + constructor({ + name, + raw_name, + return_type = UnknownType, + parameters = [], + output_parameters = [], + ...args + }: GirOptions<{ + name: string; + raw_name: string; + return_type?: TypeExpression; + parameters?: GirFunctionParameter[]; + output_parameters?: GirFunctionParameter[]; + }>) { + super(name, { ...args }); + + this.raw_name = raw_name; + this.parameters = parameters.map(p => p.copy({ parent: this })); + this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); + this.return_type = return_type; + } + + copy({ + outputParameters, + parameters, + return_type + }: { + parent?: undefined; + parameters?: GirFunctionParameter[]; + outputParameters?: GirFunctionParameter[]; + return_type?: TypeExpression; + } = {}): GirFunction { + const fn = new GirFunction({ + raw_name: this.raw_name, + name: this.name, + return_type: return_type ?? this.return_type, + output_parameters: outputParameters ?? this.output_parameters, + parameters: parameters ?? this.parameters + }); + + fn.generics = [...this.generics]; + + return fn._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): GirFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + return_type: visitor.visitType?.(this.return_type) + }); + + return visitor.visitFunction?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + _parent, + func: FunctionElement | MethodElement + ): GirFunction { + let raw_name = func.$.name; + let name = sanitizeIdentifierName(null, raw_name); + + if (hasShadow(func)) { + raw_name = func.$["shadows"]; + name = sanitizeIdentifierName(null, func.$["shadows"]); + } + + let return_type: TypeExpression; + + if ("return-value" in func && func["return-value"] && func["return-value"].length > 0) { + const value = func["return-value"][0]; + + return_type = getType(modName, ns, value); + } else { + return_type = VoidType; + } + + let parameters: GirFunctionParameter[] = []; + + if (func.parameters) { + const param = func.parameters[0].parameter; + + if (param) { + const inputs = param.filter((p): p is typeof p & { $: { name: string } } => { + return !!p.$.name; + }); + + parameters.push(...inputs.map(i => GirFunctionParameter.fromXML(modName, ns, options, null, i))); + + const unwrapped = return_type.unwrap(); + + const length_params = + unwrapped instanceof ArrayType && unwrapped.length != null ? [unwrapped.length] : ([] as number[]); + const user_data_params = [] as number[]; + + parameters = parameters + .map(p => { + const unwrapped_type = p.type.unwrap(); + + if (unwrapped_type instanceof ArrayType && unwrapped_type.length != null) { + length_params.push(unwrapped_type.length); + + return p; + } + + if (unwrapped_type instanceof ClosureType && unwrapped_type.user_data != null) { + user_data_params.push(unwrapped_type.user_data); + + return p; + } + + return p; + }) + .filter((_, i) => { + // We remove any length parameters. + return !length_params.includes(i) && !user_data_params.includes(i); + }) + .filter(v => !(v.type instanceof TypeIdentifier && v.type.is("GLib", "DestroyNotify"))) + .reverse() + .reduce( + ({ allowOptions, params }, p) => { + const { type, isOptional } = p; + + if (allowOptions) { + if (type instanceof NullableType) { + params.push(p.copy({ isOptional: true })); + } else if (!isOptional) { + params.push(p); + return { allowOptions: false, params }; + } else { + params.push(p); + } + } else { + if (isOptional) { + params.push(p.copy({ type: new NullableType(type), isOptional: false })); + } else { + params.push(p); + } + } + + return { allowOptions, params }; + }, + { + allowOptions: true, + params: [] as GirFunctionParameter[] + } + ) + .params.reverse() + .filter((p): p is GirFunctionParameter => p != null); + } + } + + let input_parameters = parameters.filter( + param => param.direction === Direction.In || param.direction === Direction.Inout + ); + let output_parameters = parameters + .filter( + param => param.direction && (param.direction === Direction.Out || param.direction === Direction.Inout) + ) + .map(parameter => parameter.copy({ isOptional: false })); + + const fn = new GirFunction({ + parameters: input_parameters, + output_parameters, + return_type, + name, + raw_name, + isIntrospectable: isIntrospectable(func) + }); + + if (options.loadDocs) { + fn.doc = parseDoc(func); + fn.metadata = parseMetadata(func); + } + + return fn; + } + + return() { + return this.return_type; + } + + asCallback(): GirCallback { + const { raw_name, name, output_parameters, parameters, return_type } = this; + + return new GirCallback({ + raw_name, + name, + output_parameters, + parameters, + return_type + }); + } + + asClassFunction(parent: GirBaseClass | GirEnum): GirClassFunction { + const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + return new GirClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + } + + asVirtualClassFunction(parent: GirBaseClass): GirVirtualClassFunction { + const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + return new GirVirtualClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + } + + asStaticClassFunction(parent: GirBaseClass | GirEnum): GirStaticClassFunction { + const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + return new GirStaticClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + } + + asString>(generator: T): ReturnType { + return generator.generateFunction(this); + } +} + +export class GirDirectAllocationConstructor extends GirBase { + fields: GirField[]; + + constructor(fields: GirField[]) { + super("new", { isPrivate: false, isIntrospectable: true }); + + this.fields = fields + .filter(field => { + return !field.isStatic && !field.isPrivate && !field.type.isPointer; + }) + .map(field => field.copy({ parent: this })); + } + + asString>( + generator: T + ): ReturnType { + return generator.generateDirectAllocationConstructor(this); + } + + copy( + options?: { parent?: GirBase | undefined; fields: GirField[] } | undefined + ): GirDirectAllocationConstructor { + const copy = new GirDirectAllocationConstructor(options?.fields ?? this.fields); + + copy._copyBaseProperties(this); + + return copy; + } + + accept(visitor: GirVisitor): GirDirectAllocationConstructor { + const node = this.copy({ + fields: this.fields.map(field => { + return field.accept(visitor); + }) + }); + + return visitor.visitDirectAllocationConstructor?.(node) ?? node; + } +} + +export class GirConstructor extends GirBase { + readonly parameters: GirFunctionParameter[] = []; + readonly return_type: TypeExpression = UnknownType; + + constructor({ + name, + parameters = [], + return_type, + ...args + }: GirOptions<{ + name: string; + parameters?: GirFunctionParameter[]; + return_type: TypeExpression; + }>) { + super(name, { ...args }); + this.return_type = return_type; + this.parameters = parameters.map(p => p.copy({ parent: this })); + } + + copy({ + parameters, + return_type + }: { + parent?: undefined; + parameters?: GirFunctionParameter[]; + return_type?: TypeExpression; + } = {}): GirConstructor { + return new GirConstructor({ + name: this.name, + return_type: return_type ?? this.return_type, + parameters: parameters ?? this.parameters + })._copyBaseProperties(this); + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirBaseClass, + m: ConstructorElement + ): GirConstructor { + return GirClassFunction.fromXML(modName, ns, options, parent, m as FunctionElement).asConstructor(); + } + + accept(visitor: GirVisitor): GirConstructor { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + return_type: visitor.visitType?.(this.return_type) + }); + + return visitor.visitConstructor?.(node) ?? node; + } + + return() { + return this.return_type; + } + + asString>(generator: T): ReturnType { + return generator.generateConstructor(this); + } +} + +export class GirFunctionParameter extends GirBase { + readonly type: TypeExpression; + readonly direction: Direction; + readonly isVarArgs: boolean = false; + readonly isOptional: boolean = false; + readonly isNullable: boolean = false; + readonly parent?: GirClassFunction | GirFunction | GirSignal | GirConstructor; + + constructor({ + name, + direction, + type, + parent, + doc, + isVarArgs = false, + isOptional = false, + isNullable = false, + ...args + }: GirOptions<{ + name: string; + parent?: GirClassFunction | GirFunction | GirSignal | GirConstructor; + type: TypeExpression; + direction: Direction; + doc?: string | null; + isVarArgs?: boolean; + isOptional?: boolean; + isNullable?: boolean; + }>) { + super(name, { ...args }); + + this.parent = parent; + this.type = type; + this.direction = direction; + this.doc = doc; + this.isVarArgs = isVarArgs; + this.isOptional = isOptional; + this.isNullable = isNullable; + } + + copy( + options: { + parent?: GirClassFunction | GirFunction | GirSignal | GirConstructor; + type?: TypeExpression; + isOptional?: boolean; + isNullable?: boolean; + } = { + parent: this.parent + } + ): GirFunctionParameter { + const { type, parent, direction, isVarArgs, isOptional, isNullable, name, doc } = this; + + return new GirFunctionParameter({ + parent: options.parent ?? parent, + name, + direction, + isVarArgs, + isOptional: options.isOptional ?? isOptional, + isNullable: options.isNullable ?? isNullable, + type: options.type ?? type, + doc + })._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): GirFunctionParameter { + const node = this.copy({ + type: visitor.visitType?.(this.type) + }); + + return visitor.visitParameter?.(node) ?? node; + } + + asString>(generator: T): ReturnType { + return generator.generateParameter(this); + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirSignal | GirClassFunction | GirFunction | GirConstructor | null, + parameter: CallableParamElement & { $: { name: string } } + ): GirFunctionParameter { + let name = sanitizeMemberName(parameter.$.name); + + if (isInvalid(name)) { + name = `_${name}`; + } + + let isVarArgs = false; + let isOptional = false; + let isNullable = false; + + let type: TypeExpression; + let direction: Direction; + + if ( + !parameter.$.direction || + parameter.$.direction === Direction.In || + parameter.$.direction === Direction.Inout + ) { + if (name === "...") { + isVarArgs = true; + name = "args"; + } + + // Default to "in" direction + direction = parameter.$.direction || Direction.In; + + const optional = parameter.$.optional === "1"; + const nullable = parameter.$.nullable === "1"; + + if (optional) { + isOptional = true; + } + + if (nullable) { + isNullable = true; + } + + type = getType(modName, ns, parameter); + } else if (parameter.$.direction === Direction.Out || parameter.$.direction === Direction.Inout) { + direction = parameter.$.direction; + type = getType(modName, ns, parameter); + } else { + throw new Error(`Unknown parameter direction: ${parameter.$.direction}`); + } + + const fp = new GirFunctionParameter({ + isVarArgs, + type: isVarArgs ? new ArrayType(type) : type, + direction, + parent: parent ?? undefined, + isOptional, + isNullable, + name, + isIntrospectable: isIntrospectable(parameter) + }); + + if (options.loadDocs) { + fp.doc = parseDoc(parameter); + fp.metadata = parseMetadata(parameter); + } + + return fp; + } +} + +export class GirClassFunction extends GirBase { + readonly parameters: GirFunctionParameter[]; + protected readonly return_type: TypeExpression; + readonly output_parameters: GirFunctionParameter[]; + protected _anyify: boolean = false; + protected _generify: boolean = false; + parent: GirBaseClass | GirEnum; + interfaceParent: GirBaseClass | GirEnum | null = null; + + generics: Generic[] = []; + + constructor({ + name, + parameters = [], + output_parameters = [], + return_type = UnknownType, + parent, + doc, + ...args + }: GirOptions<{ + name: string; + parameters?: GirFunctionParameter[]; + output_parameters?: GirFunctionParameter[]; + return_type?: TypeExpression; + parent: GirBaseClass | GirEnum; + doc?: string | null; + }>) { + super(name, { ...args }); + + this.parameters = parameters.map(p => p.copy({ parent: this })); + this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); + this.return_type = return_type; + this.parent = parent; + this.doc = doc; + } + + asConstructor(): GirConstructor { + const { name, parameters } = this; + + if (this.parent instanceof GirBaseClass) { + // Always force constructors to have the correct return type. + return new GirConstructor({ + name, + parameters, + return_type: this.parent.getType(), + isIntrospectable: this.isIntrospectable + }); + } + + throw new Error( + `Attempted to convert GirClassFunction into GirConstructor from invalid parent: ${this.parent.name}` + ); + } + + asStaticClassFunction(parent: GirClass): any { + const { name, parameters, return_type, output_parameters } = this; + + return new GirStaticClassFunction({ + name, + parameters, + output_parameters, + return_type, + parent, + isIntrospectable: this.isIntrospectable + }); + } + + copy({ + parent = this.parent, + interfaceParent, + parameters, + outputParameters, + returnType + }: { + parent?: GirBaseClass | GirEnum; + interfaceParent?: GirBaseClass | GirEnum; + parameters?: GirFunctionParameter[]; + outputParameters?: GirFunctionParameter[]; + returnType?: TypeExpression; + } = {}): GirClassFunction { + let constr = GirClassFunction; + + if (this instanceof GirVirtualClassFunction) { + constr = GirVirtualClassFunction; + } else if (this instanceof GirStaticClassFunction) { + constr = GirStaticClassFunction; + } + + const fn = new constr({ + name: this.name, + parent, + output_parameters: outputParameters ?? this.output_parameters, + parameters: parameters ?? this.parameters, + return_type: returnType ?? this.return_type + }); + + fn.generics = [...this.generics]; + + if (interfaceParent) { + fn.interfaceParent = interfaceParent; + } + + return fn._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): GirClassFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + const fn = visitor.visitClassFunction?.(node); + + return fn ?? node; + } + + anyify(): this { + this._anyify = true; + + return this; + } + + shouldAnyify() { + return this._anyify; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirBaseClass | GirEnum, + m: FunctionElement | MethodElement + ): GirClassFunction { + const fn = GirFunction.fromXML(modName, ns, options, null, m); + + return fn.asClassFunction(parent); + } + + return(): TypeExpression { + return this.return_type; + } + + asString>(generator: T): ReturnType { + return generator.generateClassFunction(this); + } +} + +export class GirVirtualClassFunction extends GirClassFunction { + constructor({ + name, + parameters = [], + output_parameters = [], + return_type = UnknownType, + parent, + doc, + ...args + }: GirOptions<{ + name: string; + parameters: GirFunctionParameter[]; + output_parameters?: GirFunctionParameter[]; + return_type?: TypeExpression; + parent: GirBaseClass; + doc?: string | null; + }>) { + super({ + parent, + name: name.startsWith("vfunc_") ? name : `vfunc_${name}`, + parameters, + output_parameters, + return_type, + doc, + ...args + }); + } + + return(): TypeExpression { + return this.return_type; + } + + accept(visitor: GirVisitor): GirVirtualClassFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + return visitor.visitVirtualClassFunction?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirBaseClass, + m: VirtualMethodElement + ): GirVirtualClassFunction { + const fn = GirFunction.fromXML(modName, ns, options, parent, m); + + return fn.asVirtualClassFunction(parent); + } + + asString>(generator: T): ReturnType { + return generator.generateVirtualClassFunction(this); + } +} + +export class GirStaticClassFunction extends GirClassFunction { + asString>(generator: T): ReturnType { + return generator.generateStaticClassFunction(this); + } + + accept(visitor: GirVisitor): GirStaticClassFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + return visitor.visitStaticClassFunction?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirBaseClass | GirEnum, + m: FunctionElement + ): GirStaticClassFunction { + const fn = GirFunction.fromXML(modName, ns, options, parent, m); + + return fn.asStaticClassFunction(parent); + } +} + +export class GirCallback extends GirFunction { + asFunctionType(): FunctionType { + return new FunctionType( + Object.fromEntries(this.parameters.map(p => [p.name, p.type] as const)), + this.return_type + ); + } + + copy({ + parameters, + returnType, + outputParameters + }: { + parent?: undefined; + parameters?: GirFunctionParameter[]; + outputParameters?: GirFunctionParameter[]; + returnType?: TypeExpression; + } = {}): GirCallback { + const cb = new GirCallback({ + name: this.name, + raw_name: this.raw_name, + return_type: returnType ?? this.return_type, + parameters: parameters ?? this.parameters, + output_parameters: outputParameters ?? this.output_parameters + })._copyBaseProperties(this); + + cb.generics = [...this.generics]; + + return cb; + } + + accept(visitor: GirVisitor): GirCallback { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + return visitor.visitCallback?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + _parent, + func: CallbackElement + ): GirCallback { + const cb = GirFunction.fromXML(modName, ns, options, null, func).asCallback(); + + if (func.$["glib:type-name"]) { + cb.resolve_names.push(func.$["glib:type-name"]); + + ns.registerResolveName(func.$["glib:type-name"], ns.name, cb.name); + } + + if (func.$["c:type"]) { + cb.resolve_names.push(func.$["c:type"]); + + ns.registerResolveName(func.$["c:type"], ns.name, cb.name); + } + + return cb; + } + + asString>(generator: T): ReturnType { + return generator.generateCallback(this); + } +} diff --git a/packages/lib/src/newlib/gir/generics.ts b/packages/lib/src/newlib/gir/generics.ts new file mode 100644 index 000000000..45b80a054 --- /dev/null +++ b/packages/lib/src/newlib/gir/generics.ts @@ -0,0 +1,68 @@ +const GenericNames = [ + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "U", + "V", + "W", + "X", + "Y", + "Z" +]; + +export function* getGenericNames(start: string = "A") { + let names = GenericNames.map(s => `${s}`); + let startIteration = Number.parseInt(start.slice(1) || "0"); + + let i = startIteration; + + names = names.map(s => (i == 0 ? s : `${s}${i}`)); + + let StartLetter = start[0]; + const position = GenericNames.indexOf(StartLetter); + + while (true) { + for (const name of names) { + if (i === startIteration && GenericNames.indexOf(name) >= position) { + yield name; + } + } + + names = names.map(s => `${s}${i}`); + + i++; + } + + // This will always be a string return. + return "ThisShouldNeverHappen"; +} + +export class GenericNameGenerator { + static new(): () => string { + const genericNames = getGenericNames(); + + return () => genericNames.next().value; + } + + static at(start: string): () => string { + const genericNames = getGenericNames(start); + + return () => genericNames.next().value; + } +} diff --git a/packages/lib/src/newlib/gir/namespace.ts b/packages/lib/src/newlib/gir/namespace.ts new file mode 100644 index 000000000..5341f05ff --- /dev/null +++ b/packages/lib/src/newlib/gir/namespace.ts @@ -0,0 +1,571 @@ +import { + + NullableType, + ObjectType, + BinaryType, + VoidType, + PromiseType, + BooleanType, + TupleType, + TypeIdentifier, + ClosureType +} from "../gir.js"; + +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { AliasElement, GirXML, InfoAttrs, Type } from "@gi.ts/parser"; +import { isPrimitiveType } from "./util.js"; + +import { GirClass, GirInterface, GirRecord, GirBaseClass } from "./class.js"; +import { GirFunction, GirCallback } from "./function.js"; +import { GirEnum, GirError } from "./enum.js"; +import { GirConst } from "./const.js"; +import { GirAlias } from "./alias.js"; + +import { LoadOptions } from "../types.js"; +import { GirNSRegistry } from "./registry.js"; +import { GirVisitor } from "../visitor.js"; + +export type GirNSMember = GirBaseClass | GirFunction | GirConst | GirEnum | GirAlias; + +export const isIntrospectable = (e: { $?: InfoAttrs }) => + !e || !e.$ || !e.$.introspectable || e.$.introspectable === "1"; +export const isDeprecated = (e: { $: InfoAttrs }) => e && e.$ && e.$.deprecated === "1"; +export const deprecatedVersion = (e: { $: InfoAttrs }) => e?.$?.["deprecated-version"]; +export const introducedVersion = (e: { $: InfoAttrs }) => e?.$?.version; + +export function promisifyNamespaceFunctions(namespace: GirNamespace) { + return namespace.members.forEach(node => { + if (!(node instanceof GirFunction)) return; + + if (node.parameters.length < 1) return; + + const last_param = node.parameters[node.parameters.length - 1]; + + if (!last_param) return; + + const last_param_unwrapped = last_param.type.unwrap(); + + if (!(last_param_unwrapped instanceof ClosureType)) return; + + const internal = last_param_unwrapped.type; + + if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { + let async_res = [ + ...Array.from(namespace.members.values()).filter((m): m is GirFunction => m instanceof GirFunction) + ].find( + m => m.name === `${node.name.replace(/_async$/, "")}_finish` || m.name === `${node.name}_finish` + ); + + if (async_res) { + const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); + const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); + const output_parameters = async_res.output_parameters; + + let async_return = new PromiseType(async_res.return()); + + if (output_parameters.length > 0) { + const raw_return = async_res.return(); + if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { + const [output_type, ...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(output_type, ...output_types)); + } else { + const [...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(raw_return, ...output_types)); + } + } + + namespace.members.set(node.name, [ + node.copy({ + parameters: async_parameters, + return_type: async_return + }), + node.copy({ + parameters: sync_parameters + }), + node.copy({ + return_type: new BinaryType(async_return, node.return()) + }) + ]); + } + } + }); +} + +export class GirNamespace { + readonly name: string; + readonly version: string; + readonly c_prefixes: string[]; + + private imports: Map = new Map(); + default_imports: Map = new Map(); + + private _members?: Map; + private _enum_constants?: Map; + private _resolve_names: Map = new Map(); + __dts__references?: string[]; + + package_version!: readonly [string, string] | readonly [string, string, string]; + parent!: GirNSRegistry; + + constructor(name: string, version: string, prefixes: string[]) { + this.name = name; + this.version = version; + this.c_prefixes = [...prefixes]; + this.package_version = ['0', '0']; + } + + registerResolveName(resolveName: string, namespace: string, name: string) { + this._resolve_names.set(resolveName, new TypeIdentifier(name, namespace)); + } + + get members(): Map { + if (!this._members) { + this._members = new Map(); + } + + return this._members; + } + + get enum_constants(): Map { + if (!this._enum_constants) { + this._enum_constants = new Map(); + } + + return this._enum_constants; + } + + accept(visitor: GirVisitor) { + for (const key of [...this.members.keys()]) { + const member = this.members.get(key); + + if (!member) continue; + + if (Array.isArray(member)) { + this.members.set( + key, + member.map(m => { + return m.accept(visitor); + }) + ); + } else { + this.members.set(key, member.accept(visitor)); + } + } + } + + getImportsForCPrefix(c_prefix: string): GirNamespace[] { + return this.parent.namespacesForPrefix(c_prefix); + } + + hasImport(name: string): boolean { + return this.default_imports.has(name) || this.imports.has(name); + } + + private _getImport(name: string): GirNamespace | null { + let version = this.default_imports.get(name) ?? this.imports.get(name); + + if (name === this.name) { + return this; + } + + // TODO: Clean this up, but essentially try to resolve import versions + // using transitive imports (e.g. use GtkSource to find the version of Gtk) + if (!version) { + const entries = [...this.default_imports.entries()].flatMap(([_name]) => { + const namespace = this._getImport(_name); + + return [...namespace?.default_imports.entries() ?? []] + }) + + version = Object.fromEntries(entries)[name]; + } + + if (!version) { + version = this.parent.assertDefaultVersionOf(name); + } + + const namespace = this.parent.namespace(name, version); + + if (namespace) { + if (!this.imports.has(namespace.name)) { + this.imports.set(namespace.name, namespace.version); + } + } + + return namespace; + } + + getInstalledImport(name: string): GirNamespace | null { + let version = this.default_imports.get(name) ?? this.imports.get(name); + + if (name === this.name) { + return this; + } + + if (!version) { + version = this.parent.defaultVersionOf(name) ?? undefined; + } + + if (!version) { + return null; + } + + const namespace = this.parent.namespace(name, version); + + if (namespace) { + if (!this.imports.has(namespace.name)) { + this.imports.set(namespace.name, namespace.version); + } + } + + return namespace; + } + + assertInstalledImport(name: string): GirNamespace { + let namespace = this._getImport(name); + + if (!namespace) { + throw new Error(`Failed to import ${name} in ${this.name}, not installed or accessible.`); + } + + return namespace; + } + + getImports(): [string, string][] { + return [...this.imports.entries()].sort(([[a], [b]]) => a.localeCompare(b)); + } + + addImport(ns_name: string) { + + this._getImport(ns_name); + } + + getMembers(name: string): GirBase[] { + const members = this.members.get(name); + + if (Array.isArray(members)) { + return [...members]; + } + return members ? [members] : []; + } + + getMemberWithoutOverrides(name: string) { + if (this.members.has(name)) { + const member = this.members.get(name); + + if (!Array.isArray(member)) { + return member; + } + + return null; + } + + const resolvedName = this._resolve_names.get(name); + if (resolvedName) { + const member = this.members.get(resolvedName.name); + + if (!Array.isArray(member)) { + return member; + } + } + + return null; + } + + assertClass(name: string): GirBaseClass { + const clazz = this.getClass(name); + + if (!clazz) { + throw new Error(`Class ${name} does not exist in namespace ${this.name}.`); + } + + return clazz; + } + + getClass(name: string): GirBaseClass | null { + const member = this.getMemberWithoutOverrides(name); + + if (member instanceof GirBaseClass) { + return member; + } + return null; + } + + getEnum(name: string): GirEnum | null { + const member = this.getMemberWithoutOverrides(name); + + if (member instanceof GirEnum) { + return member; + } + return null; + } + + getAlias(name: string): GirAlias | null { + const member = this.getMemberWithoutOverrides(name); + + if (member instanceof GirAlias) { + return member; + } + return null; + } + + hasSymbol(name: string) { + return this.members.has(name); + } + + resolveSymbolFromTypeName(name: string): string | null { + const resolvedName = this._resolve_names.get(name); + + if (!resolvedName) { + return null; + } + + const member = this.members.get(resolvedName.name); + if (member instanceof GirBase) { + return member.name; + } + + return null; + } + + findClassCallback(name: string): [string | null, string] { + const clazzes = Array.from(this.members.values()).filter( + (m): m is GirBaseClass => m instanceof GirBaseClass + ); + const res = clazzes + .map<[GirBaseClass, GirCallback | undefined]>(m => [ + m, + m.callbacks.find(c => c.name === name || c.resolve_names.includes(name)) + ]) + .find((r): r is [GirBaseClass, GirCallback] => r[1] != null); + + if (res) { + return [res[0].name, res[1].name]; + } else { + return [null, name]; + } + } + + /** + * This is an internal method to add TypeScript + * comments when overrides use parts of the TypeScript standard + * libraries that are newer than default. + */ + ___dts___addReference(reference: string) { + this.__dts__references ??= []; + this.__dts__references.push(reference); + } + + static fromXML(repo: GirXML, options: LoadOptions, registry: GirNSRegistry): GirNamespace { + const ns = repo.repository[0].namespace[0]; + + const modName = ns.$["name"]; + let version = ns.$["version"]; + + // Hardcode harfbuzz version for now... + if (modName === "HarfBuzz" && version === "0.0") { + version = "2.0"; + } + + if (!modName) { + throw new Error(`Invalid GIR file: no namespace name specified.`); + } + + if (!version) { + throw new Error(`Invalid GIR file: no version name specified.`); + } + + const c_prefix = ns.$?.["c:symbol-prefixes"]?.split(",") ?? []; + + if (options.verbose) { + console.debug(`Parsing ${modName}...`); + } + + const building = new GirNamespace(modName, version, c_prefix); + building.parent = registry; + // Set the namespace object here to prevent re-parsing the namespace if + // another namespace imports it. + registry.mapping.set(modName, version, building); + + const includes = repo.repository[0].include || []; + + includes + .map(i => [i.$.name, i.$.version] as const) + .forEach(([name, version]) => { + if (version) { + if (options.verbose) { + console.debug(`Adding dependency ${name} ${version}...`); + } + + building.default_imports.set(name, version); + } + }); + + const importConflicts = (el: GirConst | GirBaseClass | GirFunction) => { + return !building.hasImport(el.name); + }; + + if (ns.enumeration) { + // Get the requested enums + ns.enumeration + ?.map(enumeration => { + if (enumeration.$["glib:error-domain"]) { + return GirError.fromXML(modName, building, options, null, enumeration); + } else { + return GirEnum.fromXML(modName, building, options, null, enumeration); + } + }) + .forEach(c => building.members.set(c.name, c)); + } + + // Constants + if (ns.constant) { + ns.constant + ?.filter(isIntrospectable) + .map(constant => GirConst.fromXML(modName, building, options, null, constant)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + // Get the requested functions + if (ns.function) { + ns.function + ?.filter(isIntrospectable) + .map(func => GirFunction.fromXML(modName, building, options, null, func)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.callback) { + ns.callback + ?.filter(isIntrospectable) + .map(callback => GirCallback.fromXML(modName, building, options, null, callback)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns["glib:boxed"]) { + ns["glib:boxed"] + ?.filter(isIntrospectable) + .map(boxed => new GirAlias({ name: boxed.$["glib:name"], type: new NullableType(ObjectType) })) + .forEach(c => building.members.set(c.name, c)); + } + + + // Bitfield is a type of enum + if (ns.bitfield) { + ns.bitfield + ?.filter(isIntrospectable) + .map(field => GirEnum.fromXML(modName, building, options, building, field, true)) + .forEach(c => building.members.set(c.name, c)); + } + + // The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y) + // to the name of the enum (Button) to resolve references (Gtk.Button.Y) + Array.from(building.members.values()) + .filter((m): m is GirEnum => m instanceof GirEnum) + .forEach(m => { + m.members.forEach(member => { + building.enum_constants.set(member.c_identifier, [m.name, member.name] as const); + }); + }); + + // Get the requested classes + if (ns.class) { + ns.class + ?.filter(isIntrospectable) + .map(klass => GirClass.fromXML(modName, building, options, building, klass)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.record) { + ns.record + ?.filter(isIntrospectable) + .map(record => GirRecord.fromXML(modName, building, options, record)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.union) { + ns.union + ?.filter(isIntrospectable) + .map(union => GirRecord.fromXML(modName, building, options, union)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.interface) { + ns.interface + ?.map(inter => GirInterface.fromXML(modName, building, options, inter)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.alias) { + type NamedType = Type & { $: { name: string } }; + + ns.alias + ?.filter(isIntrospectable) + // Avoid attempting to alias non-introspectable symbols. + .map(b => { + b.type = b.type?.filter((t): t is NamedType => !!(t && t.$.name)) + .map(t => { + if ( + t.$.name && + !building.hasSymbol(t.$.name) && + !isPrimitiveType(t.$.name) && + !t.$.name.includes(".") + ) { + return { $: { name: "unknown", "c:type": "unknown" } } as Type; + } + + return t; + }); + + return b; + }) + .map(alias => GirAlias.fromXML(modName, building, options, null, alias)) + .filter((alias): alias is GirAlias => alias != null) + .forEach(c => building.members.set(c.name, c)); + } + + try { + let [major = null] = building.getMembers("MAJOR_VERSION"); + let [minor = null] = building.getMembers("MINOR_VERSION"); + let [micro = null] = building.getMembers("MICRO_VERSION"); + + if (!major) { + major = building.getMembers("VERSION_MAJOR")[0] ?? null; + } + + if (!minor) { + minor = building.getMembers("VERSION_MINOR")[0] ?? null; + } + + if (!micro) { + micro = building.getMembers("VERSION_MICRO")[0] ?? null; + } + + if (major instanceof GirConst && minor instanceof GirConst && major.value && minor.value) { + if (micro instanceof GirConst && micro.value) { + building.package_version = [major.value, minor.value, micro.value] as const; + } else { + building.package_version = [major.value, minor.value] as const; + } + } else { + const [major = "", minor = "0", micro] = building.version.split(".").filter(v => v != ""); + + if (micro) { + building.package_version = [major, minor, micro]; + } else { + building.package_version = [major, minor]; + } + } + } catch (error) { + console.error(`Failed to parse package version for ${building.name} with version ${building.version}`); + } + + return building; + } +} diff --git a/packages/lib/src/newlib/gir/nodes.ts b/packages/lib/src/newlib/gir/nodes.ts new file mode 100644 index 000000000..e83399465 --- /dev/null +++ b/packages/lib/src/newlib/gir/nodes.ts @@ -0,0 +1,19 @@ +export { GirAlias } from "./alias.js"; +export { GirClass, GirInterface, GirRecord, GirComplexRecord, GirBaseClass } from "./class.js"; +export { GirConst } from "./const.js"; +export { GirEnum, GirError, GirEnumMember } from "./enum.js"; +export { + GirFunction, + GirClassFunction, + GirCallback, + GirConstructor, + GirStaticClassFunction, + GirVirtualClassFunction, + GirFunctionParameter, + GirDirectAllocationConstructor, +} from "./function.js"; +export { GirNamespace, GirNSMember } from "./namespace.js"; +export { GirNSRegistry, GirNSLoader } from "./registry.js"; +export { GirField, GirProperty } from "./property.js"; +export { GirSignal, GirSignalType } from "./signal.js"; +export * as nodeUtils from "./util.js"; diff --git a/packages/lib/src/newlib/gir/property.ts b/packages/lib/src/newlib/gir/property.ts new file mode 100644 index 000000000..c17005f2b --- /dev/null +++ b/packages/lib/src/newlib/gir/property.ts @@ -0,0 +1,204 @@ +import { TypeExpression } from "../gir.js"; +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { FieldElement, PropertyElement } from "@gi.ts/parser"; + +import { getType, parseDoc, parseMetadata } from "./util.js"; +import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; +import { GirBaseClass } from "./class.js"; +import { GirEnum } from "./enum.js"; + +export class GirField extends GirBase { + type: TypeExpression; + + // TODO: Make these properties readonly + optional: boolean = false; + computed: boolean; + isStatic: boolean; + writable: boolean; + isNative: boolean = false; + + copy(options?: { parent?: GirBase; type?: TypeExpression; isStatic?: boolean }): GirField { + const { type, name, optional, computed, isStatic, writable } = this; + + return new GirField({ + name, + type: options?.type ?? type, + optional, + computed, + isStatic: options?.isStatic ?? isStatic, + writable + })._copyBaseProperties(this); + } + + constructor({ + name, + type, + computed = false, + optional = false, + isStatic = false, + writable = true, + ...args + }: GirOptions<{ + name: string; + type: TypeExpression; + computed?: boolean; + optional?: boolean; + isStatic?: boolean; + writable?: boolean; + }>) { + super(name, { ...args }); + + this.type = type; + this.computed = computed; + this.optional = optional; + this.isStatic = isStatic; + this.writable = writable; + } + + asString>(generator: T): ReturnType { + return generator.generateField(this); + } + + accept(visitor: GirVisitor): GirField { + const node = this.copy({ + type: visitor.visitType?.(this.type) ?? this.type + }); + + return visitor.visitField?.(node) ?? node; + } + + static fromXML( + namespace: string, + ns: GirNamespace, + _options: LoadOptions, + _parent, + field: FieldElement + ): GirField { + let name = field.$["name"]; + let _name = name.replace(/[-]/g, "_"); + const f = new GirField({ + name: _name, + type: getType(namespace, ns, field), + isPrivate: field.$.private === "1", + isIntrospectable: isIntrospectable(field) + }); + + return f; + } +} + +export class JSField extends GirField { + isNative = true; +} + +export class GirProperty extends GirBase { + type: TypeExpression; + + readonly writable: boolean = false; + readonly readable: boolean = true; + readonly constructOnly: boolean; + + parent: GirBaseClass | GirEnum; + + copy(options?: { name?: string; parent?: GirBaseClass | GirEnum; type?: TypeExpression }): GirProperty { + const { name, writable, readable, type, constructOnly, parent } = this; + + return new GirProperty({ + name: options?.name ?? name, + writable, + readable, + type: options?.type ?? type, + constructOnly, + parent: options?.parent ?? parent + })._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): GirProperty { + const node = this.copy({ + parent: this.parent, + type: visitor.visitType?.(this.type) ?? this.type + }); + + return visitor.visitProperty?.(node) ?? node; + } + + constructor({ + name, + type, + writable, + readable, + constructOnly, + parent, + ...args + }: GirOptions<{ + name: string; + type: TypeExpression; + writable: boolean; + readable: boolean; + constructOnly: boolean; + parent: GirBaseClass | GirEnum; + }>) { + super(name, { ...args }); + + this.type = type; + this.writable = writable; + this.readable = readable; + this.constructOnly = constructOnly; + this.parent = parent; + } + + asString>( + generator: T, + construct?: boolean + ): ReturnType { + return generator.generateProperty(this, construct); + } + + toCamelCase() { + const [part, ...parts] = this.name.split("_"); + + if (parts.length === 0) { + return this.copy({ + name: part, + parent: this.parent + }); + } + + const camelCase = `${part}${parts.map(s => `${s[0].toUpperCase()}${s.slice(1)}`).join("")}`; + + return this.copy({ + name: camelCase, + parent: this.parent + }); + } + + static fromXML( + namespace: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirBaseClass | GirEnum, + prop: PropertyElement + ): GirProperty { + let name = prop.$["name"]; + let _name = name.replace(/[-]/g, "_"); + const property = new GirProperty({ + name: _name, + writable: prop.$?.writable === "1", + readable: prop.$?.readable !== "0", + constructOnly: prop.$?.["construct-only"] === "1", + type: getType(namespace, ns, prop), + parent, + isIntrospectable: isIntrospectable(prop), + }); + + if (options.loadDocs) { + property.doc = parseDoc(prop); + property.metadata = parseMetadata(prop); + } + + return property; + } +} diff --git a/packages/lib/src/newlib/gir/registry.ts b/packages/lib/src/newlib/gir/registry.ts new file mode 100644 index 000000000..779446c2a --- /dev/null +++ b/packages/lib/src/newlib/gir/registry.ts @@ -0,0 +1,282 @@ +import { GirXML } from "@gi.ts/parser"; +import { DefaultFormatter } from "../formatters/default.js"; +import { Formatter } from "../formatters/formatter.js"; +import { JSONFormatter } from "../formatters/json.js"; +import { DtsGenerator } from "../generators/dts.js"; +import { JsonGenerator } from "../generators/json.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { generify } from "../generics/generify.js"; +import { inject } from "../injections/inject.js"; +import { GenerationOptions, LoadOptions, TransformOptions } from "../types.js"; +import { TwoKeyMap } from "../util.js"; +import { ClassVisitor } from "../validators/class.js"; +import { InterfaceVisitor } from "../validators/interface.js"; +import { GirVisitor } from "../visitor.js"; +import { GirNamespace } from "./namespace.js"; +import { DtsModuleGenerator } from "../generators/dts-modules.js"; +import { DtsInlineGenerator } from "../generators/dts-inline.js"; + +export interface GirNSLoader { + load(namespace: string, version: string): GirXML | null; + loadAll(namespace: string): GirXML[]; +} + +type GeneratorConstructor = { + new (namespace: GirNamespace, options: GenerationOptions, ...args: any[]): FormatGenerator; +}; + +export class GirNSRegistry { + mapping: TwoKeyMap = new TwoKeyMap(); + private formatters: Map = new Map(); + private generators: Map> = new Map(); + c_mapping: Map = new Map(); + transformations: GirVisitor[] = []; + loaders: [GirNSLoader, LoadOptions][] = []; + subtypes = new TwoKeyMap>(); + + constructor() { + this.formatters.set("json", new JSONFormatter()); + } + + registerTransformation(visitor: GirVisitor) { + this.transformations.push(visitor); + + // Apply transformations to already built namespaces. + this.mapping.forEach(n => { + n.accept(visitor); + }); + } + + registerFormatter(output: string, formatter: Formatter) { + this.formatters.set(output, formatter); + } + + getFormatter(output: string) { + return this.formatters.get(output) ?? new DefaultFormatter(); + } + + registerGenerator( + output: string, + generator: { new (namespace: GirNamespace, options: GenerationOptions): FormatGenerator } + ) { + this.generators.set(output, generator); + } + + getGenerator(output: "json"): { new (namespace: GirNamespace, options: GenerationOptions): JsonGenerator }; + getGenerator(output: "dts"): { new (namespace: GirNamespace, options: GenerationOptions): DtsGenerator }; + getGenerator(output: string): GeneratorConstructor | undefined; + getGenerator(output: string): GeneratorConstructor | undefined { + if (output === "dts") { + return DtsModuleGenerator; + } + + if (output === 'dts-inline') { + return DtsInlineGenerator; + } + + if (output === "json") { + return JsonGenerator; + } + + // Handle loading external generators... + if (!this.generators.has(output)) { + (() => { + let Generator = require(`@gi.ts/generator-${output}`); + + if (Generator) { + console.log(`Loading generator "@gi.ts/generator-${output}"...`); + this.generators.set(output, Generator); + return; + } + + Generator = require(`gi-ts-generator-${output}`); + + if (Generator) { + console.log(`Loading generator "gi-ts-generator-${output}"...`); + this.generators.set(output, Generator); + return; + } + + Generator = require(`${output}`); + + if (Generator) { + console.log(`Loading generator "${output}"...`); + this.generators.set(output, Generator); + return; + } + })(); + } + + return this.generators.get(output); + } + + private _transformNamespace(namespace: GirNamespace) { + this.transformations.forEach(t => { + namespace.accept(t); + }); + } + + namespace(name: string, version: string): GirNamespace | null { + const namespace = this.mapping.get(name, version); + + if (!namespace) { + return this._internalLoad(name, version); + } + + return namespace; + } + + namespacesForPrefix(c_prefix): GirNamespace[] { + return this.c_mapping.get(c_prefix) ?? []; + } + + transform(options: TransformOptions) { + const GLib = this.assertNamespace("GLib", "2.0"); + const Gio = this.assertNamespace("Gio", "2.0"); + const GObject = this.assertNamespace("GObject", "2.0"); + + // These follow the GLib version. + Gio.package_version = [...GLib.package_version]; + GObject.package_version = [...GLib.package_version]; + + const interfaceVisitor = new InterfaceVisitor(); + + this.registerTransformation(interfaceVisitor); + + const classVisitor = new ClassVisitor(); + + this.registerTransformation(classVisitor); + + console.log("Adding generics..."); + generify(this, options.inferGenerics); + + console.log("Injecting types..."); + inject(this); + } + + defaultVersionOf(name: string): string | null { + // GJS has a hard dependency on these versions. + if (name === "GLib" || name === "Gio" || name === "GObject") { + return "2.0"; + } + + const meta = this.mapping.getIfOnly(name); + + if (meta) { + return meta[0]; + } + + let ns = this._defaultVersionInternalLoad(name); + + if (ns) { + return ns.version; + } + + return null; + } + + assertDefaultVersionOf(name: string): string { + const version = this.defaultVersionOf(name); + + if (version) { + return version; + } + + // This mirrors GJS' and GI's default behavior. + // If we can't find a single version of an unspecified dependency, we throw an error. + throw new Error(`No single version found for unspecified dependency: ${name}.`); + } + + assertNamespace(name: string, version: string): GirNamespace { + let namespace = this.mapping.get(name, version) ?? null; + + if (!namespace) { + namespace = this._internalLoad(name, version); + } + + if (!namespace) { + throw new Error(`Namespace '${name}' not found.`); + } + + return namespace; + } + + load(gir: GirXML, options: LoadOptions): GirNamespace { + const namespace = GirNamespace.fromXML(gir, options, this); + + this.mapping.set(namespace.name, namespace.version, namespace); + + namespace.c_prefixes.forEach(c_prefix => { + let c_map = this.c_mapping.get(c_prefix) || []; + + c_map.push(namespace); + + this.c_mapping.set(c_prefix, c_map); + }); + + this._transformNamespace(namespace); + + return namespace; + } + + private _defaultVersionInternalLoad(name: string): GirNamespace | null { + const all = this.loaders + .map(([loader, options]) => { + try { + return [loader.loadAll(name), options] as const; + } catch (error) { + // TODO: Should we throw here? + console.error(error); + return null; + } + }) + .filter((a): a is [GirXML[], LoadOptions] => a != null); + + if (all.length === 0 || all.length > 1) { + return null; + } + + const [[xmls, options]] = all; + + if (xmls.length === 0 || xmls.length > 1) { + return null; + } + + const [xml] = xmls; + + const ns = this.load(xml, options); + + if (ns) { + this._transformNamespace(ns); + } + + return ns; + } + + private _internalLoad(name: string, version: string): GirNamespace | null { + for (const [loader, options] of this.loaders) { + try { + const xml = loader.load(name, version); + + if (xml) { + const ns = this.load(xml, options); + + if (ns) { + this._transformNamespace(ns); + } + + return ns; + } + } catch (error) { + // TODO: Should we throw here? + console.error(error); + } + } + + return null; + } + + registerLoader(loader: GirNSLoader, options: LoadOptions) { + this.loaders.push([loader, options]); + } +} diff --git a/packages/lib/src/newlib/gir/signal.ts b/packages/lib/src/newlib/gir/signal.ts new file mode 100644 index 000000000..52134f4c1 --- /dev/null +++ b/packages/lib/src/newlib/gir/signal.ts @@ -0,0 +1,237 @@ +import { + + VoidType, + UnknownType, + NativeType, + TypeExpression, + ThisType, + NumberType, + + NullableType, + ArrayType +} from "../gir.js"; +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { GirClass } from "./class.js"; +import { GirClassFunction, GirFunctionParameter, GirCallback } from "./function.js"; +import { SignalElement, Direction, CallableParamElement } from "@gi.ts/parser"; +import { getType, parseDoc, parseMetadata } from "./util.js"; +import { FormatGenerator } from "../generators/generator.js"; +import { LoadOptions } from "../types.js"; +import { GirVisitor } from "../visitor.js"; + +export enum GirSignalType { + CONNECT, + CONNECT_AFTER, + EMIT +} + +export class GirSignal extends GirBase { + parameters: GirFunctionParameter[]; + return_type: TypeExpression; + parent: GirClass; + + constructor({ + name, + parameters = [], + return_type = UnknownType, + parent, + ...args + }: GirOptions<{ + name: string; + parameters?: GirFunctionParameter[]; + return_type?: TypeExpression; + parent: GirClass; + }>) { + super(name, { ...args }); + + this.parameters = parameters.map(p => p.copy({ parent: this })); + this.return_type = return_type; + this.parent = parent; + } + + accept(visitor: GirVisitor): GirSignal { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + return visitor.visitSignal?.(node) ?? node; + } + + copy({ + parent = this.parent, + parameters, + returnType + }: { + parent?: GirClass; + parameters?: GirFunctionParameter[]; + returnType?: TypeExpression; + } = {}): GirSignal { + return new GirSignal({ + name: this.name, + parent, + parameters: parameters ?? this.parameters, + return_type: returnType ?? this.return_type + })._copyBaseProperties(this); + } + + static fromXML( + modName: string, + ns: GirNamespace, + options: LoadOptions, + parent: GirClass, + sig: SignalElement + ): GirSignal { + const signal = new GirSignal({ + name: sig.$.name, + parent, + isIntrospectable: isIntrospectable(sig) + }); + + if (sig.parameters && sig.parameters[0].parameter) { + signal.parameters.push( + ...sig.parameters[0].parameter + .filter((p): p is CallableParamElement & { $: { name: string } } => !!p.$.name) + .map(p => GirFunctionParameter.fromXML(modName, ns, options, signal, p)) + ); + } + + const length_params = [] as number[]; + + signal.parameters = signal.parameters + .map(p => { + const unwrapped_type = p.type.unwrap(); + + if (unwrapped_type instanceof ArrayType && unwrapped_type.length != null) { + length_params.push(unwrapped_type.length); + + return p; + } + + return p; + }) + .filter((_, i) => { + // We remove any length parameters. + return !length_params.includes(i); + }) + + .reverse() + .reduce( + ({ allowOptions, params }, p) => { + const { type, isOptional } = p; + + if (allowOptions) { + if (type instanceof NullableType) { + params.push(p.copy({ isOptional: true })); + } else if (!isOptional) { + params.push(p); + return { allowOptions: false, params }; + } else { + params.push(p); + } + } else { + if (isOptional) { + params.push(p.copy({ type: new NullableType(type), isOptional: false })); + } else { + params.push(p); + } + } + + return { allowOptions, params }; + }, + { + allowOptions: true, + params: [] as GirFunctionParameter[] + } + ) + .params.reverse() + .filter((p): p is GirFunctionParameter => p != null); + + signal.return_type = getType(modName, ns, sig["return-value"]?.[0]); + + if (options.loadDocs) { + signal.doc = parseDoc(sig); + signal.metadata = parseMetadata(sig); + } + + return signal; + } + + asEmit() { + const emit = this.copy(); + + const parent = this.parent; + + const prefix_signal = emit.parameters.some(p => { + return p.name === "signal"; + }); + + const parameters = [ + new GirFunctionParameter({ + name: prefix_signal ? "$signal" : "signal", + type: NativeType.of(`'${this.name}'`), + direction: Direction.In + }), + ...emit.parameters + ]; + + const return_type = VoidType; + + return new GirClassFunction({ + return_type, + parameters, + name: "emit", + parent + }); + } + + asConnect(after = false) { + const connect = this.copy(); + + const name = after ? "connect_after" : "connect"; + + const parent = this.parent; + const cb = new GirCallback({ + raw_name: "callback", + name: "callback", + output_parameters: [], + parameters: [ + new GirFunctionParameter({ name: "_source", type: ThisType, direction: Direction.In }), + ...connect.parameters.map(p => p.copy()) + ], + return_type: connect.return_type + }); + + const parameters = [ + new GirFunctionParameter({ + name: "signal", + type: NativeType.of(`'${this.name}'`), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "callback", + type: cb.asFunctionType(), + direction: Direction.In + }) + ]; + + const return_type = NumberType; + + return new GirClassFunction({ + return_type, + parameters, + name, + parent + }); + } + + asString>( + generator: T, + type?: GirSignalType + ): ReturnType { + return generator.generateSignal(this, type); + } +} diff --git a/packages/lib/src/newlib/gir/util.ts b/packages/lib/src/newlib/gir/util.ts new file mode 100644 index 000000000..7ec730c4d --- /dev/null +++ b/packages/lib/src/newlib/gir/util.ts @@ -0,0 +1,657 @@ +import { deprecatedVersion, GirNamespace, introducedVersion, isDeprecated } from "./namespace.js"; +import { + CallableParamElement, + Direction, + AliasElement, + DocElement, + InfoAttrs, + Type, + ConstantElement, + CallableReturn, + FieldElement +} from "@gi.ts/parser"; +import { + TypeIdentifier, + ThisType, + ArrayType, + ClosureType, + GTypeType, + BinaryType, + ObjectType, + NullableType, + TypeExpression, + StringType, + NumberType, + BooleanType, + Uint8ArrayType, + AnyType, + UnknownType, + NeverType, + VoidType, + GenerifiedTypeIdentifier, + GenericType, + + NativeType +} from "../gir.js"; +import {GirBase, GirOptions, GirMetadata} from './base.js'; +import { GirBaseClass } from "./class.js"; +import { TwoKeyMap } from "../util.js"; + +const reservedWords = [ + // For now, at least, the typescript compiler doesn't throw on numerical types like int, float, etc. + "abstract", + "arguments", + "await", + "boolean", + "break", + "byte", + "case", + "catch", + "char", + "class", + "const", + "continue", + "constructor", // This isn't technically reserved, but it's problematic. + "debugger", + "default", + "delete", + "do", + // "double", + "else", + "enum", + "eval", + "export", + "extends", + "false", + "final", + "finally", + // "float", + "for", + "function", + "goto", + "if", + "implements", + "import", + "in", + "instanceof", + // "int", + "interface", + "let", + // "long", + "native", + "new", + "null", + "package", + "private", + "protected", + "public", + "return", + "short", + "static", + "super", + "switch", + "synchronized", + "this", + "throw", + "throws", + "transient", + "true", + "try", + "typeof", + "var", + "void", + "volatile", + "while", + "with", + "yield" +]; + +export function getAliasType(modName: string, _ns: GirNamespace, parameter: AliasElement): TypeExpression { + let name = parameter.type?.[0].$["name"] || "unknown"; + + let nameParts = name.split(" "); + + if (nameParts.length === 1) { + name = nameParts[0]; + } else { + name = nameParts[1]; + } + + return parseTypeExpression(modName, name); +} + +/** + * This function determines whether a given type is a "pointer type"... + * + * Any type where the c:type ends with * + */ +function isPointerType(types: Type[] | undefined) { + const type = types?.[0]; + if (!type) return false; + + const ctype = type.$["c:type"]; + if (!ctype) return false; + + const typeName = type.$.name; + if (!typeName) return false; + + if (isPrimitiveType(typeName)) return false; + + return ctype.endsWith("*"); +} + +/* Decode the type */ +export function getType( + modName: string, + _ns: GirNamespace, + param?: ConstantElement | CallableReturn | FieldElement +): TypeExpression { + if (!param) return VoidType; + + let name = ""; + let arrayDepth: number | null = null; + let length: number | null = null; + let isPointer = false; + + let parameter = param as CallableParamElement; + if (parameter.array && parameter.array[0]) { + arrayDepth = 1; + + const [array] = parameter.array; + + if (array.$ && array.$.length != null) { + length = Number.parseInt(array.$.length, 10); + + if (Number.isNaN(length)) { + throw new Error(`Error parsing array length: ${array.$.length}`); + } + } + + if (array.type && array.type[0].$ && array.type[0].$["name"]) { + name = array.type[0].$["name"]; + } else if (array.array) { + let arr = array; + let depth = 1; + + while (Array.isArray(arr.array)) { + arr = arr.array[0]; + depth++; + } + + let possibleName = arr.type?.[0].$["name"]; + if (possibleName) { + name = possibleName; + } else { + name = "unknown"; + console.log( + `Failed to find array type in ${modName}: `, + JSON.stringify(parameter.$, null, 4), + "\nMarking as unknown!" + ); + } + arrayDepth = depth; + isPointer = isPointerType(array.type); + } else { + name = "unknown"; + } + } else if (parameter.type && parameter.type[0] && parameter.type[0].$) { + let possibleName = parameter.type[0].$["name"]; + if (possibleName) { + name = possibleName; + } else { + name = "unknown"; + console.log( + `Failed to find type in ${modName}: `, + JSON.stringify(parameter.$, null, 4), + "\nMarking as unknown!" + ); + } + isPointer = isPointerType(parameter.type); + } else if (parameter.varargs || (parameter.$ && parameter.$.name === "...")) { + arrayDepth = 1; + name = "any"; + } else { + name = "unknown"; + console.log( + `Unknown varargs type in ${modName}: `, + JSON.stringify(parameter.$, null, 4), + "\nMarking as unknown!" + ); + } + + let closure = null as null | number; + + if (parameter.$ && parameter.$.closure) { + closure = Number.parseInt(parameter.$.closure, 10); + + if (Number.isNaN(closure)) { + throw new Error(`Error parsing closure data position: ${parameter.$.closure}`); + } + } + + const nullable = parameter.$ && parameter.$["nullable"] === "1"; + const allowNone = parameter.$ && parameter.$["allow-none"] === "1"; + + let x = name.split(" "); + if (x.length === 1) { + name = x[0]; + } else { + name = x[1]; + } + + const baseType = parseTypeString(name); + + if (!baseType) { + throw new Error(`Un-parsable type: ${name}`); + } + + let variableType: TypeExpression = parseTypeExpression(modName, name); + + if (variableType instanceof TypeIdentifier) { + if (variableType.is("GLib", "List") || variableType.is("GLib", "SList")) { + const listType = parameter?.type?.[0].type?.[0]?.$.name; + + if (listType) { + name = listType; + variableType = parseTypeExpression(modName, name); + + arrayDepth = 1; + } + } else if (variableType.is("GLib", "HashTable")) { + const keyType = parameter?.type?.[0]?.type?.[0]?.$.name; + const valueType = parameter?.type?.[0]?.type?.[1]?.$.name; + + if (keyType && valueType) { + const key = parseTypeExpression(modName, keyType); + const value = parseTypeExpression(modName, valueType); + + variableType = new GenerifiedTypeIdentifier("HashTable", "GLib", [key, value]); + } + } + } + + if (arrayDepth != null) { + const primitiveArrayType = resolvePrimitiveArrayType(name, arrayDepth); + + if (primitiveArrayType) { + const [primitiveName, primitiveArrayDepth] = primitiveArrayType; + + variableType = ArrayType.new({ + type: primitiveName, + arrayDepth: primitiveArrayDepth, + length + }); + } else { + variableType = ArrayType.new({ type: variableType, arrayDepth, length }); + } + } else if (closure != null) { + variableType = ClosureType.new({ type: variableType, user_data: closure }); + } + + if ( + parameter.$ && + (parameter.$.direction === "inout" || parameter.$.direction === "out") && + (nullable || allowNone) && + !(variableType instanceof NativeType) + ) { + return new NullableType(variableType); + } + + if ((!parameter.$?.direction || parameter.$.direction === "in") && nullable) { + return new NullableType(variableType); + } + + variableType.isPointer = isPointer; + + return variableType; +} + +export const SanitizedIdentifiers = new Map(); + +export function sanitizeIdentifierName(namespace: string | null, name: string): string { + // This is a unique case where the name is "empty". + if (name === "") { + return `''`; + } + + let sanitized_name = name.replace(/[^A-z0-9_]/gi, "_"); + + if (reservedWords.includes(sanitized_name)) { + sanitized_name = `__${sanitized_name}`; + } + + if (sanitized_name.match(/^[^A-z_]/) != null) { + sanitized_name = `__${sanitized_name}`; + } + + if (namespace && sanitized_name !== name) { + SanitizedIdentifiers.set(`${namespace}.${name}`, `${namespace}.${sanitized_name}`); + } + + return sanitized_name; +} + +export function sanitizeMemberName(name: string): string { + // This is a unique case where the name is "empty". + if (name === "") { + return `''`; + } + + return name.replace(/[^A-z0-9_]/gi, "_"); +} + +export function isInvalid(name: string): boolean { + if (reservedWords.includes(name)) { + return true; + } + + const sanitized = sanitizeMemberName(name); + + if (sanitized.match(/^[^A-z_]/) != null) { + return true; + } + + return false; +} + +export function parseDoc(element: DocElement): string | null { + return element.doc?.[0]?._ ?? null; +} + +export function parseDeprecatedDoc(element: DocElement): string | null { + return element["doc-deprecated"]?.[0]?._ ?? null; +} + +export function parseMetadata(element: { $: InfoAttrs } & DocElement): GirMetadata | undefined { + const version = introducedVersion(element); + const deprecatedIn = deprecatedVersion(element); + const deprecated = isDeprecated(element); + const doc = parseDeprecatedDoc(element); + + if (!version && !deprecated && !deprecatedIn && !doc) { + return undefined; + } + + return { + ...(deprecated ? { deprecated } : {}), + ...(doc ? { deprecatedDoc: doc } : {}), + ...(deprecatedIn ? { deprecatedVersion: deprecatedIn } : {}), + ...(version ? { introducedVersion: version } : {}) + }; +} + +export function parseTypeString(type: string): { namespace: string | null; name: string } { + if (type.includes(".")) { + const parts = type.split("."); + + if (parts.length > 2) { + throw new Error(`Invalid type string ${type} passed.`); + } + + const [namespace, name] = parts; + + return { name, namespace }; + } else { + return { name: type, namespace: null }; + } +} + +export function parseTypeIdentifier(modName: string, type: string): TypeIdentifier { + const baseType = parseTypeString(type); + + if (baseType.namespace) { + return new TypeIdentifier(baseType.name, baseType.namespace); + } else { + return new TypeIdentifier(baseType.name, modName); + } +} + +export function parseTypeExpression(modName: string, type: string): TypeExpression { + const baseType = parseTypeString(type); + + if (baseType.namespace) { + return new TypeIdentifier(baseType.name, baseType.namespace); + } else { + const primitiveType = resolvePrimitiveType(baseType.name); + + if (primitiveType !== null) { + return primitiveType; + } else { + return new TypeIdentifier(baseType.name, modName); + } + } +} + +export function resolvePrimitiveArrayType(name: string, arrayDepth: number): [TypeExpression, number] | null { + if (arrayDepth > 0) { + switch (name) { + case "gint8": + case "guint8": + return [Uint8ArrayType, arrayDepth - 1]; + } + } + + const resolvedName = resolvePrimitiveType(name); + + if (resolvedName) { + return [resolvedName, arrayDepth]; + } else { + return null; + } +} + +export function isPrimitiveType(name: string): boolean { + return resolvePrimitiveType(name) !== null; +} + +export function resolvePrimitiveType(name: string): TypeExpression | null { + switch (name) { + case "": + console.error("Resolving '' to any on " + name); + return AnyType; + case "filename": + return StringType; + // Pass this through + case "GType": + return GTypeType; + case "utf8": + return StringType; + case "void": // Support TS "void" + case "none": + return VoidType; + // TODO Some libraries are bad and don't use g-prefixed numerical types + case "uint32": + case "int32": + case "double": + // Most libraries will use these though: + case "gshort": + case "guint32": + case "guint16": + case "gint16": + case "gunichar": + case "gint8": + case "gint32": + case "gushort": + case "gfloat": + case "gchar": + case "guint": + case "glong": + case "gulong": + case "gint": + case "guint8": + case "guint64": + case "gint64": + case "gdouble": + case "gssize": + case "gsize": + case "long": + return NumberType; + case "gboolean": + return BooleanType; + case "gpointer": // This is typically used in callbacks to pass data, so we'll allow anything. + return AnyType; + case "object": + return ObjectType; + case "va_list": + return AnyType; + case "guintptr": // You can't use pointers in GJS! (at least that I'm aware of) + return NeverType; + case "never": // Support TS "never" + return NeverType; + case "unknown": // Support TS "unknown" + return UnknownType; + case "any": // Support TS "any" + return AnyType; + case "this": // Support TS "this" + return ThisType; + case "number": // Support TS "number" + return NumberType; + case "string": // Support TS "string" + return StringType; + case "boolean": // Support TS "boolean" + return BooleanType; + case "object": // Support TS "object" + return ObjectType; + } + + return null; +} + +export function resolveDirectedType(type: TypeExpression, direction: Direction): TypeExpression | null { + if (type instanceof ArrayType) { + if ( + (direction === Direction.In || direction === Direction.Inout) && + type.type.equals(Uint8ArrayType) && + type.arrayDepth === 0 + ) { + return new BinaryType(type, StringType); + } + } else if (type instanceof TypeIdentifier) { + if ((direction === Direction.In || direction === Direction.Inout) && type.is("GLib", "Bytes")) { + return new BinaryType(type, Uint8ArrayType); + } else if (type.is("GObject", "Value")) { + if (direction === Direction.In || direction === Direction.Inout) { + return new BinaryType(type, AnyType); + } else { + // GJS converts GObject.Value out parameters to their unboxed type, which we don't know, + // so type as `unknown` + return UnknownType; + } + } else if (type.is("GLib", "HashTable")) { + if (direction === Direction.In) { + return new BinaryType(new NativeType("{ [key: string]: any }"), type); + } else { + return type; + } + } + } + + return null; +} + +/** + * Resolves a class identifier. + * + * If the identifier is a class type it is returned, + * otherwise `null`. + * + * @param namespace + * @param type + */ +export function resolveTypeIdentifier(namespace: GirNamespace, type: TypeIdentifier): GirBaseClass | null { + const ns = type.namespace; + const name = type.name; + + const resolved_ns = namespace.assertInstalledImport(ns); + + const pclass = resolved_ns.getClass(name); + if (pclass) { + return pclass; + } else { + return null; + } +} + +/** + * + * @param a + * @param b + */ +function isTypeConflict(a: TypeExpression, b: TypeExpression) { + return !a.equals(b) || !b.equals(a); +} + +/** + * Checks if a given type expression in the context of a given this type + * is a subtype (compatible with) of another type expression in the context + * of a parent type. + * + * @param namespace + * @param thisType + * @param parentThisType + * @param potentialSubtype + * @param parentType + */ +export function isSubtypeOf( + namespace: GirNamespace, + thisType: TypeIdentifier, + parentThisType: TypeIdentifier, + potentialSubtype: TypeExpression, + parentType: TypeExpression +) { + if (!isTypeConflict(potentialSubtype, parentType)) { + return true; + } + + const unwrappedSubtype = potentialSubtype.unwrap(); + let unwrappedParent = parentType.unwrap(); + + if ( + (potentialSubtype.equals(ThisType) && unwrappedParent.equals(thisType)) || + (parentType.equals(ThisType) && unwrappedSubtype.equals(parentThisType)) + ) { + return true; + } + + if (unwrappedParent instanceof GenericType && unwrappedParent.identifier !== "T") { + // Technically there could be a conflicting generic, but most generic types should specify a replacement for type checking. + // "T" denotes a local function generic in the current implementation, those can't be ignored. + if (!unwrappedParent.replacedType) { + return true; + } + + // Use the generic replaced type as a stand-in. + unwrappedParent = unwrappedParent.replacedType; + } + + if (!(unwrappedSubtype instanceof TypeIdentifier) || !(unwrappedParent instanceof TypeIdentifier)) { + return false; + } + + const resolutions = + namespace.parent.subtypes.get(unwrappedSubtype.name, unwrappedSubtype.namespace) ?? + new TwoKeyMap(); + const resolution = resolutions.get(unwrappedParent.name, unwrappedParent.namespace); + + if (typeof resolution === "boolean") { + return resolution; + } + + const resolved = resolveTypeIdentifier(namespace, unwrappedSubtype); + + if (!resolved) { + return false; + } + let x = resolved.resolveParents(); + + // This checks that the two types have the same form, regardless of identifier (e.g. A | null and B | null) + const isStructurallySubtype = potentialSubtype.rewrap(AnyType).equals(parentType.rewrap(AnyType)); + + const isSubtype = isStructurallySubtype && x.node.someParent(t => t.getType().equals(unwrappedParent)); + + resolutions.set(unwrappedParent.name, unwrappedParent.namespace, isSubtype); + + namespace.parent.subtypes.set(unwrappedSubtype.name, unwrappedSubtype.namespace, resolutions); + + return isSubtype; +} diff --git a/packages/lib/src/newlib/injections/gio.ts b/packages/lib/src/newlib/injections/gio.ts new file mode 100644 index 000000000..bc4adca02 --- /dev/null +++ b/packages/lib/src/newlib/injections/gio.ts @@ -0,0 +1,438 @@ +import { GirNamespace } from "../gir/namespace.js"; +import { + GirClassFunction, + GirConstructor, + GirFunction, + GirFunctionParameter, + GirStaticClassFunction +} from "../gir/function.js"; +import { + StringType, + NativeType, + FunctionType, + GenerifiedType, + GenericType, + AnyFunctionType, + ArrayType, + AnyType, + VoidType, + GenerifiedTypeIdentifier, + Generic +} from "../gir.js"; +import { Direction } from "@gi.ts/parser"; +import { GirField, JSField } from "../gir/property.js"; +import { GirClass, GirInterface } from "../gir/class.js"; + +export default { + namespace: "Gio", + version: "2.0", + modifier(namespace: GirNamespace) { + // For IterableIterator... + namespace.___dts___addReference(`/// `); + + { + const DBusNodeInfo = namespace.assertClass("DBusNodeInfo"); + + DBusNodeInfo.constructors.push( + new GirConstructor({ + name: "new_for_xml", + parameters: [ + new GirFunctionParameter({ + name: "info", + type: StringType, + direction: Direction.In + }) + ], + return_type: DBusNodeInfo.getType() + }) + ); + } + + { + const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); + + DBusInterfaceInfo.constructors.push( + new GirConstructor({ + name: "new_for_xml", + parameters: [ + new GirFunctionParameter({ + name: "info", + type: StringType, + direction: Direction.In + }) + ], + return_type: DBusInterfaceInfo.getType() + }) + ); + } + + { + const ListStore = namespace.assertClass("ListStore"); + + ListStore.fields.push( + new GirField({ + name: "Symbol.iterator", + computed: true, + type: new FunctionType( + {}, + new GenerifiedType(new NativeType("IterableIterator"), new GenericType("A")) + ) + }) + ); + } + + { + const SettingsSchema = namespace.assertClass("SettingsSchema"); + + SettingsSchema.fields.push( + new JSField({ + name: "_realGetKey", + type: new NativeType("typeof SettingsSchema.prototype.get_key") + }) + ); + } + + { + const Settings = namespace.assertClass("Settings"); + + Settings.fields.push( + new JSField({ + name: "_realInit", + type: AnyFunctionType + }), + new JSField({ + name: "_realMethods", + type: new NativeType("typeof Settings.prototype") + }), + new JSField({ + name: "_keys", + type: new ArrayType(StringType) + }), + new JSField({ + name: "_children", + type: new ArrayType(StringType) + }) + ); + } + { + const DBusProxy = namespace.assertClass("DBusProxy"); + + // This is not ideal, but DBusProxy's define functions and properties on the prototype. + DBusProxy.indexSignature = "[key: string]: any;"; + + DBusProxy.members.push( + new GirStaticClassFunction({ + name: "makeProxyWrapper", + parent: DBusProxy, + parameters: [ + new GirFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: Direction.In + }) + ], + return_type: AnyType + }), + new GirClassFunction({ + name: "connectSignal", + parent: DBusProxy, + parameters: [ + new GirFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: Direction.In + }) + ], + return_type: AnyType + }), + new GirClassFunction({ + name: "disconnectSignal", + parent: DBusProxy, + parameters: [ + new GirFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: Direction.In + }) + ], + return_type: AnyType + }) + ); + } + + { + const [bus_get] = namespace.getMembers("bus_get"); + const [bus_get_finish] = namespace.getMembers("bus_get_finish"); + const [bus_get_sync] = namespace.getMembers("bus_get_sync"); + const [bus_own_name] = namespace.getMembers("bus_own_name"); + const [bus_own_name_on_connection] = namespace.getMembers("bus_own_name_on_connection"); + const [bus_unown_name] = namespace.getMembers("bus_unown_name"); + const [bus_watch_name] = namespace.getMembers("bus_watch_name"); + const [bus_unwatch_name] = namespace.getMembers("bus_unwatch_name"); + const [bus_watch_name_on_connection] = namespace.getMembers("bus_watch_name_on_connection"); + + if ( + !( + bus_get instanceof GirFunction && + bus_get_finish instanceof GirFunction && + bus_get_sync instanceof GirFunction && + bus_own_name instanceof GirFunction && + bus_own_name_on_connection instanceof GirFunction && + bus_unown_name instanceof GirFunction && + bus_watch_name instanceof GirFunction && + bus_unwatch_name instanceof GirFunction && + bus_watch_name_on_connection instanceof GirFunction + ) + ) { + throw new Error(`Invalid dbus functions found in Gio!`); + } + + const DBus = new GirInterface({ + name: "DBus", + namespace + }); + + DBus.members.push( + ...[ + bus_get, + bus_get_finish, + bus_get_sync, + bus_own_name, + bus_own_name_on_connection, + bus_unown_name, + bus_watch_name, + bus_unwatch_name, + bus_watch_name_on_connection + ] + .map(fn => fn.asStaticClassFunction(DBus)) + .map(fn => { + const member = fn.copy(); + + member.name = member.name.substring(4); + + return member; + }) + ); + + const DBusConnection = namespace.assertClass("DBusConnection"); + + const call = DBusConnection.members.find(m => m.name === "call"); + const callFinish = DBusConnection.members.find(m => m.name === "call_finish"); + + if (!call || !callFinish) { + throw new Error(`Missing call or call_finish in Gio.DBusConnection.`); + } + + // Add generic + const call_generic = new Generic(new GenericType("T"), AnyType, undefined, StringType); + call.generics.push(call_generic); + callFinish.generics.push(call_generic); + + const replacement = call.copy({ + parameters: call.parameters.map(p => { + if (p.name === "reply_type") { + // Generify the parameter + return p.copy({ + type: p.type.rewrap(new GenerifiedTypeIdentifier("VariantType", "GLib", [new GenericType("T")])) + }); + } + + return p; + }) + }); + + const finishReplacement = callFinish.copy({ + returnType: callFinish + .return() + .rewrap(new GenerifiedTypeIdentifier("Variant", "GLib", [new GenericType("T")])) + }); + + DBusConnection.members.splice(DBusConnection.members.indexOf(call), 1, replacement); + DBusConnection.members.splice(DBusConnection.members.indexOf(callFinish), 1, finishReplacement); + + DBusConnection.members.push( + new GirClassFunction({ + name: "watch_name", + parameters: bus_watch_name_on_connection.parameters.slice(1), + return_type: bus_watch_name_on_connection.return_type, + parent: DBusConnection + }), + new GirClassFunction({ + name: "unwatch_name", + parameters: bus_unwatch_name.parameters.slice(), + return_type: bus_unwatch_name.return_type, + parent: DBusConnection + }), + new GirClassFunction({ + name: "own_name", + parameters: bus_own_name_on_connection.parameters.slice(1), + return_type: bus_own_name_on_connection.return_type, + parent: DBusConnection + }), + new GirClassFunction({ + name: "unown_name", + parameters: bus_unown_name.parameters.slice(), + return_type: bus_unown_name.return_type, + parent: DBusConnection + }) + ); + + DBus.fields.push( + new JSField({ + isStatic: true, + name: "session", + type: DBusConnection.getType(), + writable: false + }), + new JSField({ + isStatic: true, + name: "system", + type: DBusConnection.getType(), + writable: false + }) + ); + + namespace.members.set("DBus", DBus); + } + + // From GJS Documentation: + // + // `Gio.DBusExportedObject.wrapJSObject(Gio.DbusInterfaceInfo, jsObj)` + + // Takes `jsObj`, an object instance implementing the interface described by `Gio.DbusInterfaceInfo`, and returns an implementation object with these methods: + + // * `export(busConnection, objectPath)` + // * `unexport()` + // * `flush()` + // * `emit_signal(name, variant)` + // * `emit_property_changed(name, variant)` + + { + const Variant = namespace.assertInstalledImport("GLib").assertClass("Variant"); + const DBusConnection = namespace.assertClass("DBusConnection"); + const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); + const DBusExportedObject = new GirClass("DBusExportedObject", namespace); + + DBusExportedObject.members.push( + new GirStaticClassFunction({ + name: "wrapJSObject", + parent: DBusExportedObject, + parameters: [ + new GirFunctionParameter({ + name: "info", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "obj", + type: AnyType, + direction: Direction.In + }) + ], + return_type: DBusExportedObject.getType() + }), + new GirClassFunction({ + name: "get_info", + parent: DBusExportedObject, + parameters: [], + return_type: DBusInterfaceInfo.getType() + }), + new GirClassFunction({ + name: "get_connection", + parent: DBusExportedObject, + parameters: [], + return_type: DBusConnection.getType() + }), + new GirClassFunction({ + name: "get_object_path", + parent: DBusExportedObject, + parameters: [], + return_type: StringType + }), + new GirClassFunction({ + name: "unexport_from_connection", + parent: DBusExportedObject, + parameters: [ + new GirFunctionParameter({ + name: "connection", + type: DBusConnection.getType(), + direction: Direction.In + }) + ], + return_type: VoidType + }), + // export(busConnection, objectPath) + new GirClassFunction({ + name: "export", + parent: DBusExportedObject, + parameters: [ + new GirFunctionParameter({ + name: "busConnection", + type: DBusConnection.getType(), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "objectPath", + type: StringType, + direction: Direction.In + }) + ], + return_type: VoidType + }), + // unexport() + new GirClassFunction({ + name: "unexport", + parent: DBusExportedObject, + return_type: VoidType + }), + // flush() + new GirClassFunction({ + name: "flush", + parent: DBusExportedObject, + return_type: VoidType + }), + // emit_signal(name, variant) + new GirClassFunction({ + name: "emit_signal", + parent: DBusExportedObject, + parameters: [ + new GirFunctionParameter({ + name: "name", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "variant", + type: Variant.getType(), + direction: Direction.In + }) + ], + return_type: VoidType + }), + // emit_property_changed(name, variant) + new GirClassFunction({ + name: "emit_property_changed", + parent: DBusExportedObject, + parameters: [ + new GirFunctionParameter({ + name: "name", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "variant", + type: Variant.getType(), + direction: Direction.In + }) + ], + return_type: VoidType + }) + ); + + namespace.members.set("DBusExportedObject", DBusExportedObject); + } + } +}; diff --git a/packages/lib/src/newlib/injections/glib.ts b/packages/lib/src/newlib/injections/glib.ts new file mode 100644 index 000000000..0549ad2b5 --- /dev/null +++ b/packages/lib/src/newlib/injections/glib.ts @@ -0,0 +1,238 @@ +import { GirNamespace } from "../gir/namespace.js"; +import { + GirConstructor, + GirFunctionParameter, + GirClassFunction, + GirFunction, + GirDirectAllocationConstructor +} from "../gir/function.js"; +import { + NativeType, + AnyType, + BooleanType, + Uint8ArrayType, + StringType, + UnknownType, + GenericType, + TypeIdentifier, + BinaryType +} from "../gir.js"; +import { Direction } from "@gi.ts/parser"; +import { GirNSRegistry } from "../gir/registry.js"; +import { GirRecord } from "../gir/class.js"; + +export default { + namespace: "GLib", + version: "2.0", + modifier(namespace: GirNamespace, registry: GirNSRegistry) { + // export function log_structured(logDomain, logLevel, stringFields); + + namespace.members.set( + "log_structured", + new GirFunction({ + name: "log_structured", + raw_name: "log_structured", + parameters: [ + new GirFunctionParameter({ + name: "logDomain", + type: AnyType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "logLevel", + type: AnyType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "stringFields", + type: AnyType, + direction: Direction.In + }) + ], + return_type: AnyType + }) + ); + + // export function strstrip(str: string): string; + + namespace.members.set( + "strstrip", + new GirFunction({ + name: "strstrip", + raw_name: "strstrip", + parameters: [ + new GirFunctionParameter({ + name: "str", + type: StringType, + direction: Direction.In + }) + ], + return_type: StringType + }) + ); + + // GLib.Error + + { + const Error = namespace.assertClass("Error"); + + const fixQuark = (c: T): T => { + return c.copy({ + parameters: c.parameters.map(p => { + if (p.type instanceof TypeIdentifier && p.type.is("GLib", "Quark")) { + return p.copy({ + type: new BinaryType(new NativeType("({ new(...args: any[] ): Error })"), p.type) + }); + } + + return p; + }) + }) as T; + }; + + if (Error.mainConstructor && !(Error.mainConstructor instanceof GirDirectAllocationConstructor)) + Error.mainConstructor = fixQuark(Error.mainConstructor); + + Error.constructors = Error.constructors.map(c => fixQuark(c)); + Error.members = Error.members.map(m => fixQuark(m)); + } + + { + const HashTable = namespace.assertClass("HashTable") as GirRecord; + + HashTable.indexSignature = `[key: string]: B;`; + } + + // GLib.Variant + + { + const Variant = namespace.assertClass("Variant"); + const VariantType = namespace.assertClass("VariantType"); + + Variant.addGeneric({ + default: new NativeType(`any`), + constraint: StringType + }); + + VariantType.addGeneric({ + default: new NativeType(`any`), + constraint: StringType + }); + + const VariantParams = [ + new GirFunctionParameter({ + name: "sig", + type: new GenericType("A"), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "value", + type: AnyType, + direction: Direction.In + }) + ]; + const VariantConstructor = new GirConstructor({ + name: "new", + parameters: VariantParams.map(vp => vp.copy()), + return_type: Variant.getType() + }); + + Variant.mainConstructor = VariantConstructor.copy(); + + Variant.constructors.unshift( + // static new: (sig: any, value: any) => Variant; + VariantConstructor.copy(), + // static _new_internal: (sig: any, value: any) => any;, + new GirConstructor({ + name: "_new_internal", + parameters: VariantParams.map(vp => vp.copy()), + return_type: AnyType + }) + ); + + Variant.members.push( + // unpack(): T; + new GirClassFunction({ + name: "unpack", + return_type: UnknownType, + parent: Variant + }), + // deepUnpack(): T; + new GirClassFunction({ + name: "deepUnpack", + return_type: UnknownType, + parent: Variant + }), + // deep_unpack: any; + new GirClassFunction({ + name: "deep_unpack", + return_type: UnknownType, + parent: Variant + }), + // recursiveUnpack: () => any; + new GirClassFunction({ + name: "recursiveUnpack", + return_type: AnyType, + parent: Variant + }), + // _init(sig: any, value: any): Variant; + new GirClassFunction({ + name: "_init", + return_type: Variant.getType(), + parent: Variant, + parameters: VariantParams.map(vp => vp.copy()) + }) + ); + } + + // GLib.VariantDict + + { + const VariantDict = namespace.assertClass("VariantDict"); + + VariantDict.members.push( + // lookup(key: any, variantType?: any, deep?: any): any; + new GirClassFunction({ + name: "lookup", + return_type: AnyType, + parent: VariantDict, + parameters: [ + new GirFunctionParameter({ + name: "key", + direction: Direction.In, + type: AnyType + }), + new GirFunctionParameter({ + name: "variantType", + direction: Direction.In, + type: AnyType, + isOptional: true + }), + new GirFunctionParameter({ + name: "deep", + direction: Direction.In, + type: BooleanType, + isOptional: true + }) + ] + }) + ); + } + + // GLib.Bytes + + { + const Bytes = namespace.assertClass("Bytes"); + + Bytes.members.push( + // toArray(): Uint8Array; + new GirClassFunction({ + name: "toArray", + return_type: Uint8ArrayType, + parent: Bytes, + parameters: [] + }) + ); + } + } +}; diff --git a/packages/lib/src/newlib/injections/gobject.ts b/packages/lib/src/newlib/injections/gobject.ts new file mode 100644 index 000000000..d8577a5a5 --- /dev/null +++ b/packages/lib/src/newlib/injections/gobject.ts @@ -0,0 +1,568 @@ +import { GirNamespace } from "../gir/namespace.js"; +import { GirFunctionParameter, GirClassFunction, GirFunction, GirStaticClassFunction } from "../gir/function.js"; +import { + NativeType, + AnyType, + StringType, + BinaryType, + VoidType, + NumberType, + TypeIdentifier, + ObjectType, + NullableType, + TupleType, + UnknownType, + AnyFunctionType, + Generic, + GenericType, + TypeExpression, + BooleanType, + GenerifiedTypeIdentifier +} from "../gir.js"; +import { Direction } from "@gi.ts/parser"; +import { GirField } from "../gir/property.js"; +import { GirAlias } from "../gir/alias.js"; +import { GirInterface } from "../gir/class.js"; +import { GirNSRegistry } from "../gir/registry.js"; + +function typeParam(name: string, type: TypeExpression) { + return new GirFunctionParameter({ + name, + direction: Direction.In, + type: type + }); +} + +function anyParam(name: string) { + return typeParam(name, AnyType); +} + +export default { + namespace: "GObject", + version: "2.0", + modifier(namespace: GirNamespace, _registry: GirNSRegistry) { + { + const SignalMatch = new GirInterface({ + name: "SignalMatch", + namespace, + fields: [ + new GirField({ + name: "signalId", + type: StringType, + isStatic: false, + writable: true + }), + new GirField({ + name: "detail", + type: StringType, + isStatic: false, + writable: true + }), + new GirField({ + name: "func", + type: AnyFunctionType, + isStatic: false, + writable: true + }) + ] + }); + + // TODO: Devise a better way to represent pure TypeScript types. + SignalMatch.noParent = true; + + namespace.members.set("SignalMatch", SignalMatch); + + const GType = new GirAlias({ + name: "GType", + type: new NativeType("any") + }); + namespace.members.set("GType", GType); + + // We don't want to emit TypeScript-specific GType + // hacks, but we still need the alias so the type + // can resolve. + GType.noEmit(); + + const ParamSpec = namespace.assertClass("ParamSpec"); + const ParamFlags = namespace.getEnum("ParamFlags"); + + function generateParamSpec( + name: string, + returnType: TypeExpression = ParamSpec.getType(), + minMax = false, + type: string | null = null, + defaultValue = false, + defaultValueType: TypeExpression = AnyType, + addGeneric = false + ) { + const fn = new GirStaticClassFunction({ + name, + parameters: [ + typeParam("name", StringType), + typeParam("nick", StringType), + typeParam("blurb", StringType), + typeParam("flags", new BinaryType(ParamFlags?.getType() ?? AnyType, NumberType)), + ...(minMax ? [typeParam("minimum", NumberType), typeParam("maximum", NumberType)] : []), + ...(type + ? !addGeneric + ? [anyParam(`${type}Type`)] + : [ + new GirFunctionParameter({ + name: `${type}Type`, + direction: Direction.In, + type: new NativeType("GType | { $gtype: GType }") + }) + ] + : []), + ...(defaultValue ? [typeParam("defaultValue", defaultValueType)] : []) + ], + parent: ParamSpec, + return_type: returnType + }); + + if (addGeneric) { + fn.generics.push(new Generic(new GenericType("T"))); + } + + return fn; + } + + ParamSpec.fields.push( + new GirField({ + name: "override", + isStatic: true, + type: AnyType, + writable: true + }) + ); + + // Get rid of the ParamSpec subtypes. + namespace.assertClass("ParamSpecBoolean").noEmit(); + namespace.assertClass("ParamSpecBoxed").noEmit(); + namespace.assertClass("ParamSpecChar").noEmit(); + namespace.assertClass("ParamSpecDouble").noEmit(); + namespace.assertClass("ParamSpecEnum").noEmit(); + namespace.assertClass("ParamSpecFlags").noEmit(); + namespace.assertClass("ParamSpecFloat").noEmit(); + namespace.assertClass("ParamSpecInt").noEmit(); + namespace.assertClass("ParamSpecInt64").noEmit(); + namespace.assertClass("ParamSpecLong").noEmit(); + namespace.assertClass("ParamSpecObject").noEmit(); + namespace.assertClass("ParamSpecParam").noEmit(); + namespace.assertClass("ParamSpecString").noEmit(); + namespace.assertClass("ParamSpecUChar").noEmit(); + namespace.assertClass("ParamSpecUnichar").noEmit(); + namespace.assertClass("ParamSpecValueArray").noEmit(); + namespace.assertClass("ParamSpecVariant").noEmit(); + namespace.assertClass("ParamSpecUInt").noEmit(); + namespace.assertClass("ParamSpecUInt64").noEmit(); + namespace.assertClass("ParamSpecULong").noEmit(); + namespace.assertClass("ParamSpecGType").noEmit(); + namespace.assertClass("ParamSpecOverride").noEmit(); + namespace.assertClass("ParamSpecPointer").noEmit(); + + // The primary "type" + ParamSpec.addGeneric({ + default: UnknownType + }); + + const object = new GirStaticClassFunction({ + name: "object", + parameters: [ + anyParam("name"), + anyParam("nick"), + anyParam("blurb"), + anyParam("flags"), + new GirFunctionParameter({ + name: `objectType`, + direction: Direction.In, + type: new NativeType("GType | { $gtype: GType }") + }) + ], + parent: ParamSpec, + return_type: new NativeType("ParamSpec") + }); + + object.generics.push(new Generic(new GenericType("T"))); + + function ParamSpecWithGenerics(type: TypeExpression) { + return new GenerifiedTypeIdentifier("ParamSpec", "GObject", [type]); + } + + ParamSpec.members.push( + // "char": "static char(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("char", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "uchar": "static uchar(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any):ParamSpec;", + generateParamSpec("uchar", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "int": "static int(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("int", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "uint": "static uint(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("uint", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "long": "static long(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("long", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "ulong": "static ulong(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("ulong", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "int64": "static int64(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("int64", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "uint64": "static uint64(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("uint64", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "float": "static float(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("float", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "boolean": "static boolean(name: any, nick: any, blurb: any, flags: any, defaultValue: any): ParamSpec;", + generateParamSpec("boolean", ParamSpecWithGenerics(BooleanType), false, null, true, BooleanType), + // "flags": "static flags(name: any, nick: any, blurb: any, flags: any, flagsType: any, defaultValue: any): ParamSpec;", + generateParamSpec("flags", ParamSpecWithGenerics(NumberType), false, "flags", true), + // "enum": "static enum(name: any, nick: any, blurb: any, flags: any, enumType: any, defaultValue: any): ParamSpec;", + generateParamSpec( + "enum", + ParamSpecWithGenerics(new NativeType("T")), + false, + "enum", + true, + undefined, + true + ), + // "double": "static double(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("double", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "string": "static string(name: any, nick: any, blurb: any, flags: any, defaultValue: any): ParamSpec;", + generateParamSpec("string", ParamSpecWithGenerics(StringType), false, null, true, StringType), + // "boxed": "static boxed(name: any, nick: any, blurb: any, flags: any, boxedType: any): ParamSpec;", + generateParamSpec( + "boxed", + ParamSpecWithGenerics(new NativeType("T")), + false, + "boxed", + false, + undefined, + true + ), + // "object": "static object(name: any, nick: any, blurb: any, flags: any, objectType: any): ParamSpec;", + object, + // "param": "static param(name: any, nick: any, blurb: any, flags: any, paramType: any): ParamSpec;", + generateParamSpec("param", ParamSpec.getType(), false, "param", false) + ); + } + + { + namespace.members.delete("Closure"); + + namespace.members.set( + "Closure", + new GirAlias({ + name: "Closure", + type: NativeType.of("(...args: P[]) => R"), + generics: [ + { + name: "R", + type: AnyType + }, + { + name: "P", + type: AnyType + } + ] + }) + ); + } + + { + const Object = namespace.assertClass("Object"); + + const get_property = Object.members.findIndex(m => m.name === "get_property"); + const set_property = Object.members.findIndex(m => m.name === "set_property"); + + Object.members[get_property] = new GirClassFunction({ + name: "get_property", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "property_name", + type: StringType, + direction: Direction.In + }) + ], + return_type: AnyType + }); + + Object.members[set_property] = new GirClassFunction({ + name: "set_property", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "property_name", + type: StringType, + direction: Direction.In + }), + new GirFunctionParameter({ + name: "value", + type: AnyType, + direction: Direction.In + }) + ], + return_type: VoidType + }); + + Object.members.push( + new GirStaticClassFunction({ + name: "_classInit", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "klass", + type: AnyType, + direction: Direction.In + }) + ], + return_type: AnyType + }), + new GirClassFunction({ + name: "disconnect", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: NumberType, + direction: Direction.In + }) + ], + return_type: VoidType + }), + // TODO: Add per-class set type checking. + new GirClassFunction({ + name: "set", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "properties", + type: new NativeType("{ [key: string]: any }"), + direction: Direction.In + }) + ], + return_type: VoidType + }), + new GirClassFunction({ + name: "block_signal_handler", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: NumberType, + direction: Direction.In + }) + ], + return_type: AnyType + }), + new GirClassFunction({ + name: "unblock_signal_handler", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "id", + type: NumberType, + direction: Direction.In + }) + ], + return_type: AnyType + }), + new GirClassFunction({ + name: "stop_emission_by_name", + parent: Object, + parameters: [ + new GirFunctionParameter({ + name: "detailedName", + type: StringType, + direction: Direction.In + }) + ], + return_type: AnyType + }) + ); + + function replaceFunction(name: string, ...functions: GirFunction[]) { + namespace.members.delete(name); + + namespace.members.set(name, functions); + } + + // export function signal_handlers_block_by_func(instance: Object, func: Function); + + replaceFunction( + "signal_handlers_block_by_func", + new GirFunction({ + name: "signal_handlers_block_by_func", + raw_name: "signal_handlers_block_by_func", + parameters: [ + new GirFunctionParameter({ + name: "instance", + type: Object.getType(), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "func", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: VoidType + }) + ); + + // export function signal_handlers_unblock_by_func (instance: Object, func: Function); + + replaceFunction( + "signal_handlers_unblock_by_func", + new GirFunction({ + name: "signal_handlers_unblock_by_func", + raw_name: "signal_handlers_unblock_by_func", + parameters: [ + new GirFunctionParameter({ + name: "instance", + type: Object.getType(), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "func", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: VoidType + }) + ); + + // export function signal_handlers_disconnect_by_func(instance: Object, func: Function); + + replaceFunction( + "signal_handlers_disconnect_by_func", + new GirFunction({ + name: "signal_handlers_disconnect_by_func", + raw_name: "signal_handlers_disconnect_by_func", + parameters: [ + new GirFunctionParameter({ + name: "instance", + type: Object.getType(), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "func", + type: AnyFunctionType, + direction: Direction.In + }) + ], + return_type: VoidType + }) + ); + + // signal_handler_find + + const args = new GirFunctionParameter({ + name: "args", + direction: Direction.In, + isVarArgs: true, + type: new BinaryType( + new TupleType(Object.getType(), NativeType.of("SignalMatch")), + new TupleType( + Object.getType(), + new TypeIdentifier("SignalMatchType", "GObject"), + NumberType, + new TypeIdentifier("Quark", "GLib"), + new NullableType(new TypeIdentifier("Closure", "GObject")), + new NullableType(ObjectType), + new NullableType(ObjectType) + ) + ) + }); + + const modifiedArgs = [ + new GirFunctionParameter({ + name: "instance", + direction: Direction.In, + + type: Object.getType() + }), + new GirFunctionParameter({ + name: "match", + direction: Direction.In, + type: NativeType.of("SignalMatch") + }) + ]; + + const originalArgs = [ + new GirFunctionParameter({ + name: "instance", + direction: Direction.In, + + type: Object.getType() + }), + new GirFunctionParameter({ + name: "match", + direction: Direction.In, + type: new TypeIdentifier("SignalMatchType", "GObject") + }), + new GirFunctionParameter({ + name: "signal_id", + direction: Direction.In, + type: NumberType + }), + new GirFunctionParameter({ + name: "detail", + type: new TypeIdentifier("Quark", "GLib"), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "closure", + type: new NullableType(new TypeIdentifier("Closure", "GObject")), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "func", + type: new NullableType(ObjectType), + direction: Direction.In + }), + new GirFunctionParameter({ + name: "object", + type: new NullableType(ObjectType), + direction: Direction.In + }) + ]; + + function originalFunc(name: string) { + return new GirFunction({ + name, + raw_name: name, + return_type: NumberType, + parameters: originalArgs.map(a => a.copy()) + }); + } + + function func(name: string) { + replaceFunction( + name, + // [name](...args: [Object, SignalMatch] | [Object, SignalMatchType, number, GLib.Quark, Closure | null, object | null, object | null]): number; + new GirFunction({ + name, + raw_name: name, + return_type: NumberType, + parameters: [args] + }), + // export function [name](instance: Object, match: SignalMatch): number; + new GirFunction({ + name, + raw_name: name, + return_type: NumberType, + parameters: modifiedArgs.map(a => a.copy()) + }), + // export function [name](instance: Object, mask: SignalMatchType, signal_id: number, detail: GLib.Quark, closure: Closure | null, func: object | null, data: object | null): number + originalFunc(name), + // export function [`_real_${name}`](instance: Object, mask: SignalMatchType, signal_id: number, detail: GLib.Quark, closure: Closure | null, func: object | null, data: object | null): number + originalFunc(`_real_${name}`) + ); + } + + func("signal_handler_find"); + func("signal_handler_block_matched"); + func("signal_handler_block_disconnect_matched"); + func("signal_handler_block_unblock_matched"); + } + } +}; diff --git a/packages/lib/src/newlib/injections/inject.ts b/packages/lib/src/newlib/injections/inject.ts new file mode 100644 index 000000000..ffc397f82 --- /dev/null +++ b/packages/lib/src/newlib/injections/inject.ts @@ -0,0 +1,24 @@ +import glib from "./glib.js"; +import gobject from "./gobject.js"; +import gio from "./gio.js"; + +import { GirNamespace } from "../gir/namespace.js"; +import { GirNSRegistry } from "../gir/registry.js"; + +export type NamespaceInjection = (namespace: GirNamespace, registry: GirNSRegistry) => void; + +function injectDefinitions(registry: GirNSRegistry) { + return (definition: { namespace: string; version: string; modifier: NamespaceInjection }) => { + const ns = registry.assertNamespace(definition.namespace, definition.version); + + definition.modifier(ns, registry); + }; +} + +export function inject(registry: GirNSRegistry) { + const $ = injectDefinitions(registry); + + $(glib); + $(gobject); + $(gio); +} diff --git a/packages/lib/src/newlib/lib.ts b/packages/lib/src/newlib/lib.ts new file mode 100644 index 000000000..42f727cbe --- /dev/null +++ b/packages/lib/src/newlib/lib.ts @@ -0,0 +1,83 @@ +import { GirNSRegistry } from "./gir/registry.js"; +import { SanitizedIdentifiers } from "./gir/util.js"; + +import { GenerationOptions, Metadata } from "./types.js"; + +export * as dts from "./generators/dts-modules.js"; + +export * as json from "./generators/json.js"; + +export * from "./generators/index.js"; + +export * from "./types.js"; + +export * from "./gir.js"; +export * from "./gir/nodes.js"; + +export { GirNSRegistry } from "./gir/registry.js"; +export { Formatter } from "./formatters/formatter.js"; + +export function getSanitizedIdentifiers(): ReadonlyMap { + return SanitizedIdentifiers; +} + +export function createRegistry(): GirNSRegistry { + return new GirNSRegistry(); +} + +export interface GeneratedModule { + meta: Metadata; + formattedOutput: string; +} + +export async function generateModule( + options: GenerationOptions, + registry: GirNSRegistry, + name: string, + version: string +): Promise { + const ns = registry.namespace(name, version); + + if (ns) { + const Generator = registry.getGenerator(options.format); + + if (!Generator) { + throw new Error(`Invalid output format selected: ${options.format}.`); + } + + const generator = new Generator(ns, options); + + let generated: string | null = null; + + try { + generated = await generator.stringifyNamespace(ns); + } catch (error) { + console.error(`Failed to generate ${ns.name} ${ns.version}...`); + + if (options.verbose) { + console.error(error); + } + } + + if (!generated) { + return null; + } + + const meta: Metadata = { + name: ns.name, + api_version: ns.version, + package_version: ns.package_version.join("."), + imports: Object.fromEntries(ns.getImports()) + }; + + const formatter = registry.getFormatter(options.format); + const formatted = !options.noPrettyPrint ? formatter.format(generated) : generated; + + return { + formattedOutput: formatted, + meta + }; + } + + return null; +} diff --git a/packages/lib/src/newlib/types.ts b/packages/lib/src/newlib/types.ts new file mode 100644 index 000000000..1f6afa1dd --- /dev/null +++ b/packages/lib/src/newlib/types.ts @@ -0,0 +1,47 @@ +export type PropertyCase = "both" | "camel" | "underscore"; +export type Format = "dts" | "json" | string; + +export interface Options { + verbose: boolean; +} + +export interface LoadOptions extends Options { + loadDocs: boolean; + propertyCase: PropertyCase; +} + +export interface TransformOptions extends Options { + inferGenerics: boolean; +} + +export type OutputFormat = 'file' | 'folder'; + +export interface GenerationOptions extends Options { + [key: string]: boolean | string | number | undefined; + outputFormat?: OutputFormat | string; + outputPath?: string; + promisify: boolean; + withDocs: boolean; + format: Format; + versionedOutput: boolean; + versionedImports: boolean; + /** + * A format for versioned imports + * + * @example + * "{namespace}{version}{version-slug}" + */ + versionFormat?: string; + importPrefix: string; + emitMetadata: boolean; + noAdvancedVariants: boolean; + noPrettyPrint: boolean; + noInitTypes: boolean; +} + +export interface Metadata { + name: string; + package_version: string; + api_version: string; + imports: { [lib: string]: string }; +} diff --git a/packages/lib/src/newlib/util.ts b/packages/lib/src/newlib/util.ts new file mode 100644 index 000000000..3be2035a9 --- /dev/null +++ b/packages/lib/src/newlib/util.ts @@ -0,0 +1,84 @@ +/** + * A simple two-key map. + */ +export class TwoKeyMap { + private baseMap = new Map>(); + + forEach(op: (v: V) => void) { + this.baseMap.forEach(map => { + map.forEach(v => { + op(v); + }); + }); + } + + has(key1: K1, key2: K2): boolean { + const obj = this.baseMap.get(key1); + + if (!obj) { + return false; + } + + return obj.has(key2); + } + + getIfOnly(key1: K1): readonly [K2, V] | undefined { + const obj = this.baseMap.get(key1); + + if (!obj) { + return undefined; + } + + if (obj.size === 1) { + const [k2] = obj.keys(); + const v = obj.get(k2); + + if (!v) { + return undefined; + } + + return [k2, v] as const; + } + + return undefined; + } + + get(key1: K1, key2: K2): V | undefined { + const obj = this.baseMap.get(key1); + + if (!obj) { + return undefined; + } + + return obj.get(key2); + } + + set(key1: K1, key2: K2, value: V): void { + let obj = this.baseMap.get(key1); + + if (!obj) { + obj = new Map(); + + this.baseMap.set(key1, obj); + } + + obj.set(key2, value); + } +} + +/** + * If the predicate returns a value other than undefined, + * that value is returned. It combines the .find() and + * .map() APIs for convenience. + * + * @param arr + * @param predicate + */ +export function findMap(arr: T[], predicate: (p: T) => K | undefined): K | undefined { + for (const a of arr) { + const val = predicate(a); + if (val !== undefined) return val; + } + + return undefined; +} diff --git a/packages/lib/src/newlib/validators/class.ts b/packages/lib/src/newlib/validators/class.ts new file mode 100644 index 000000000..1a5e8b27c --- /dev/null +++ b/packages/lib/src/newlib/validators/class.ts @@ -0,0 +1,258 @@ +import { FormatGenerator } from "../generators/index.js"; +import { AnyType, ArrayType, GirBase, NativeType, TypeIdentifier } from "../gir.js"; +import { GirBaseClass, GirClass, GirInterface, GirRecord } from "../gir/class.js"; +import { GirEnum, GirError } from "../gir/enum.js"; +import { GirDirectAllocationConstructor } from "../gir/function.js"; +import { GirClassFunction, GirConstructor, GirStaticClassFunction } from "../gir/nodes.js"; +import { resolveTypeIdentifier } from "../gir/util.js"; +import { GirVisitor } from "../visitor.js"; + +const filterIntrospectableClassMembers = (node: T): T => { + node.fields = node.fields.filter(field => field.isIntrospectable); + node.props = node.props.filter(prop => prop.isIntrospectable); + node.callbacks = node.callbacks.filter(prop => prop.isIntrospectable); + node.constructors = node.constructors.filter(prop => prop.isIntrospectable); + node.members = node.members.filter(prop => prop.isIntrospectable); + + return node; +}; + +const PROTECTED_FIELD_NAMES = ["parent_instance", "parent", "parent_class", "object_class"]; + +const filterProtectedFields = (node: T): T => { + const set = new Set(PROTECTED_FIELD_NAMES); + + node.fields = node.fields.filter(f => { + return !set.has(f.name); + }); + + return node; +}; + +const filterConflictingNamedClassMembers = (node: T): T => { + // Props shadow members + node.members = node.members.filter(m => { + return !node.props.some(prop => prop.name === m.name && !(m instanceof GirStaticClassFunction)); + }); + + // Props and members shadow fields + node.fields = node.fields.filter( + f => + !node.members.some(n => n.name === f.name && !(n instanceof GirStaticClassFunction)) && + !node.props.some(n => n.name === f.name) + ); + + return node; +}; + +/** + * Subtypes of ParamSpec are not supported (e.g. a subtype of ParamSpecString). + * + * First, we transform the node to use ParamSpec as a parent and then flag it + * to not emit. + * + * If a generator doesn't follow the emit() standard, the parent type will at least + * be valid. + * + * @param node + * @returns + */ +const fixParamSpecSubtypes = (node: T): T => { + if (node.parent?.namespace === "GObject" && node.parent.name.startsWith("ParamSpec")) { + // We don't assert this import because we don't want to force libraries + // to unnecessarily import GObject. + node.parent = new TypeIdentifier("ParamSpec", "GObject"); + + node.noEmit(); + } + + return node; +}; + +/** + * Checks if a class implements a GObject.Object-based interface + * If the class is missing a direct parent we inject GObject.Object + * as a stand-in considering it already indirectly inherits + * from it. + * + * @param node + */ +const fixMissingParent = (node: T): T => { + const { namespace } = node; + + if (node.parent == null) { + const isGObject = node.someParent(p => p.getType().is("GObject", "Object")); + + if (isGObject) { + node.parent = namespace.assertInstalledImport("GObject").assertClass("Object").getType(); + } + } + + return node; +}; + +/** + * Fields cannot be array types, error types, + * or class-like types in GJS. This strips + * fields which have these "complex" types. + * + * @param node + */ +const removeComplexFields = (node: T): T => { + const { namespace } = node; + + node.fields = node.fields.filter(f => { + let type = f.type.deepUnwrap(); + + if (type instanceof NativeType) { + return true; + } + + if (type instanceof TypeIdentifier) { + // Find the type for the identifier + const classNode = resolveTypeIdentifier(namespace, type); + + // Don't allow private or disguised fields + if (classNode && classNode.isPrivate) { + return false; + } + + // Only allow fields pointing to simple structs. + if (classNode && classNode instanceof GirRecord && !classNode.isSimple()) { + return false; + } + + const en = namespace.assertInstalledImport(type.namespace).getEnum(type.name); + + if (!(en instanceof GirError)) { + return true; + } + + return false; + } + + return true; + }); + + return node; +}; + +const removePrivateFields = (node: T): T => { + node.fields = node.fields.filter(f => { + return !f.isPrivate && !f.name.startsWith("_"); + }); + + return node; +}; + +/** + * Boxed types have a specific order of preference for + * which constructor will be used... + * + * 1. Zero Args Constructor + * 2. Direct Allocation (if the type is simple) + * 3. The new() constructor + * 4. The first constructor + * + * @param node + */ +const resolveMainConstructor = (node: GirRecord): GirRecord => { + const newConstructor = node.constructors.find(c => c.name === "new"); + const zeroArgsConstructor = node.constructors.find(c => c.parameters.length === 0); + const firstConstructor = node.constructors?.[0]; + + if (node.isForeign()) { + node.mainConstructor = null; + + return node; + } + + if (zeroArgsConstructor || node.isSimpleWithoutPointers()) { + node.mainConstructor = + new GirDirectAllocationConstructor(node.fields); + + return node; + } + + const resolvedConstructor = newConstructor ?? firstConstructor; + if (resolvedConstructor) { + node.mainConstructor = resolvedConstructor.copy(); + } + + if (node.isSimple()) { + node.mainConstructor = new GirDirectAllocationConstructor(node.fields); + + return node; + } + + return node; +}; + +const mergeStaticDefinitions = (node: GirClass): GirClass => { + if (!node.staticDefinition) { + return node; + } + + const { namespace } = node; + const staticDefinition = namespace.getClass(node.staticDefinition); + + if (!(staticDefinition instanceof GirRecord)) { + return node; + } + + const staticMethods = staticDefinition.members + .filter(m => m instanceof GirClassFunction) + .map(m => m.asStaticClassFunction(node)); + + for (const staticMethod of staticMethods) { + if ( + !node.members.some( + member => member.name === staticMethod.name && member instanceof GirStaticClassFunction + ) + ) { + node.members.push(staticMethod); + } + } + + return node; +}; + +function chainVisitors(node: T, ...args: ((node: T) => T)[]) { + let currentNode = node; + + for (const visitor of args) { + currentNode = visitor(currentNode); + } + + return currentNode; +} + +export class ClassVisitor extends GirVisitor { + visitClass = (node: GirClass) => + chainVisitors( + node, + fixMissingParent, + fixParamSpecSubtypes, + removeComplexFields, + removePrivateFields, + mergeStaticDefinitions, + filterConflictingNamedClassMembers, + filterIntrospectableClassMembers, + filterProtectedFields + ); + + visitInterface = (node: GirInterface) => chainVisitors(node, filterIntrospectableClassMembers); + + visitRecord = (node: GirRecord) => + chainVisitors( + node, + fixMissingParent, + fixParamSpecSubtypes, + resolveMainConstructor, + removeComplexFields, + removePrivateFields, + filterConflictingNamedClassMembers, + filterIntrospectableClassMembers, + filterProtectedFields + ); +} diff --git a/packages/lib/src/newlib/validators/interface.ts b/packages/lib/src/newlib/validators/interface.ts new file mode 100644 index 000000000..685b5fcc1 --- /dev/null +++ b/packages/lib/src/newlib/validators/interface.ts @@ -0,0 +1,20 @@ +import { GirInterface } from "../gir/class.js"; +import { GirVisitor } from "../visitor.js"; + +export class InterfaceVisitor extends GirVisitor { + visitInterface = (node: GirInterface): GirInterface => { + // If an interface does not list a prerequisite type, we fill it with GObject.Object + if (!node.noParent && node.parent == null) { + const gobject = node.namespace.assertInstalledImport("GObject"); + const GObject = gobject.assertClass("Object"); + + if (!GObject) { + throw new Error(`GObject.Object could not be found while generating ${node.namespace.name}.${node.name}`); + } + + node.parent = GObject.getType(); + } + + return node; + } +} \ No newline at end of file diff --git a/packages/lib/src/newlib/visitor.ts b/packages/lib/src/newlib/visitor.ts new file mode 100644 index 000000000..026d8879e --- /dev/null +++ b/packages/lib/src/newlib/visitor.ts @@ -0,0 +1,47 @@ +import { TypeExpression } from "./gir.js"; +import { GirAlias } from "./gir/alias.js"; +import { GirRecord, GirInterface, GirClass } from "./gir/class.js"; +import { GirConst } from "./gir/const.js"; +import { GirEnumMember, GirError, GirEnum } from "./gir/enum.js"; +import { + GirCallback, + GirConstructor, + GirFunctionParameter, + GirFunction, + GirClassFunction, + GirStaticClassFunction, + GirVirtualClassFunction, + GirDirectAllocationConstructor +} from "./gir/function.js"; +import { GirNamespace } from "./gir/namespace.js"; +import { GirProperty, GirField } from "./gir/property.js"; +import { GirSignal, GirSignalType } from "./gir/signal.js"; + +export abstract class GirVisitor { + visitType?: (node: TypeExpression) => TypeExpression; + visitCallback?: (node: GirCallback) => GirCallback; + visitAlias?: (node: GirAlias) => GirAlias; + visitConstructor?: (node: GirConstructor) => GirConstructor; + visitDirectAllocationConstructor?: (node: GirDirectAllocationConstructor) => GirDirectAllocationConstructor; + visitConstructorFunction?: (node: GirConstructor) => GirConstructor; + visitRecord?: (node: GirRecord) => GirRecord; + visitInterface?: (node: GirInterface) => GirInterface; + visitEnumMember?: (node: GirEnumMember) => GirEnumMember; + visitError?: (node: GirError) => GirError; + visitEnum?: (node: GirEnum) => GirEnum; + visitConst?: (node: GirConst) => GirConst; + visitClass?: (node: GirClass) => GirClass; + visitParameter?: (node: GirFunctionParameter) => GirFunctionParameter; + visitProperty?: (node: GirProperty) => GirProperty; + visitField?: (node: GirField) => GirField; + visitSignal?: (node: GirSignal, type?: GirSignalType) => GirSignal; + visitFunction?: (node: GirFunction) => GirFunction; + visitClassFunction?: (node: GirClassFunction) => GirClassFunction; + visitStaticClassFunction?: (node: GirStaticClassFunction) => GirStaticClassFunction; + visitVirtualClassFunction?: (node: GirVirtualClassFunction) => GirVirtualClassFunction; + visitNamespace?: (node: GirNamespace) => GirNamespace; +} + +export function visit(namespace: GirNamespace, visitor: GirVisitor) { + namespace.accept(visitor); +} From 4bd8b8495be0d452bdc67bb6f86e092b34103fd0 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 11:55:50 -0700 Subject: [PATCH 08/53] Add @gi.ts/lib to imports and types of ts-for-gir temp: actual lib updates --- packages/lib/src/gir-module.ts | 124 -------- .../lib/src/newlib/generators/dts-inline.ts | 8 +- .../lib/src/newlib/generators/dts-modules.ts | 8 +- packages/lib/src/newlib/generators/dts.ts | 126 ++++---- packages/lib/src/newlib/generators/dts/gio.ts | 4 +- .../lib/src/newlib/generators/dts/glib.ts | 4 +- .../lib/src/newlib/generators/dts/gobject.ts | 14 +- .../lib/src/newlib/generators/generator.ts | 62 ++-- packages/lib/src/newlib/generators/json.ts | 176 +++++------ packages/lib/src/newlib/generics/clutter.ts | 4 +- packages/lib/src/newlib/generics/generify.ts | 10 +- packages/lib/src/newlib/generics/gio.ts | 4 +- packages/lib/src/newlib/generics/glib.ts | 4 +- packages/lib/src/newlib/generics/meta.ts | 4 +- packages/lib/src/newlib/generics/st.ts | 4 +- packages/lib/src/newlib/generics/visitor.ts | 50 +-- packages/lib/src/newlib/gir.ts | 80 +++-- packages/lib/src/newlib/gir/alias.ts | 24 +- packages/lib/src/newlib/gir/base.ts | 24 +- packages/lib/src/newlib/gir/class.ts | 278 ++++++++--------- packages/lib/src/newlib/gir/const.ts | 22 +- packages/lib/src/newlib/gir/enum.ts | 58 ++-- packages/lib/src/newlib/gir/function.ts | 288 +++++++++--------- packages/lib/src/newlib/gir/namespace.ts | 108 +++---- packages/lib/src/newlib/gir/nodes.ts | 32 +- packages/lib/src/newlib/gir/property.ts | 46 +-- packages/lib/src/newlib/gir/registry.ts | 38 +-- packages/lib/src/newlib/gir/signal.ts | 76 +++-- packages/lib/src/newlib/gir/util.ts | 54 ++-- packages/lib/src/newlib/injections/gio.ts | 106 +++---- packages/lib/src/newlib/injections/glib.ts | 60 ++-- packages/lib/src/newlib/injections/gobject.ts | 114 +++---- packages/lib/src/newlib/injections/inject.ts | 10 +- packages/lib/src/newlib/lib.ts | 10 +- packages/lib/src/newlib/validators/class.ts | 42 ++- packages/lib/src/newlib/visitor.ts | 66 ++-- packages/lib/src/transformation.ts | 3 - 37 files changed, 1007 insertions(+), 1138 deletions(-) diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index 13d05688d..b44651dae 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -780,130 +780,6 @@ export class GirModule { return { returnTypes, outArrayLengthIndex, retTypeIsVoid } } - private arrayLengthIndexLookup(girVar: GirCallableParamElement): number { - if (!girVar.array) return -1 - - const arr: GirArrayType = girVar.array[0] - if (!arr.$) return -1 - - if (arr.$.length) { - return parseInt(arr.$.length) - } - - return -1 - } - - private closureDataIndexLookup(girVar: GirCallableParamElement): number { - if (!girVar.$.closure) return -1 - - return parseInt(girVar.$.closure) - } - - private destroyDataIndexLookup(girVar: GirCallableParamElement): number { - if (!girVar.$.destroy) return -1 - - return parseInt(girVar.$.destroy) - } - - private processParams( - params: GirCallableParamElement[], - skip: GirCallableParamElement[], - getIndex: (param: GirCallableParamElement) => number, - ): void { - for (const param of params) { - const index = getIndex(param) - if (index < 0) continue - if (index >= params.length) continue - skip.push(params[index]) - } - } - - /** - * Checks if the parameter is nullable (which results in ` | null`). - * - * @param girVar girVar to test - */ - private typeIsNullable( - girVar: - | GirCallableParamElement - | GirCallableReturn - | GirAliasElement - | GirFieldElement - | GirConstantElement - | GirPropertyElement, - girTypeName: GirTypeName, - ): boolean { - const a = (girVar as GirCallableParamElement).$ - - if (!a) return false - - const type: GirType | undefined = girVar.type?.[0] - const cType = type?.$?.['c:type'] - - // Ignore depreciated `allow-none` if one of the new implementation `optional` or `nullable` is set - if (a.optional || a.nullable) { - return girBool(a.nullable) - } - - if (girTypeName === 'constant') { - return false // constants are never nullable - } - - // UTF-8 string pointers can be null, e.g. `gchar*`, see https://github.com/gjsify/ts-for-gir/issues/108 - if (type?.$?.name === 'utf8' && !cType?.startsWith('const ') && cType?.endsWith('*')) { - return true - } - - // If the default value is NULL, handle this as nullable - if (a['default-value'] === 'NULL') { - return true - } - - return girBool(a.nullable) || girBool(a['allow-none']) || girBool(a['null-ok']) - } - - /** - * Checks if the parameter is optional (which results in `foo?: bar`). - * @param girVar girVar to test - */ - private typeIsOptional( - girVar: - | GirCallableParamElement - | GirCallableReturn - | GirAliasElement - | GirFieldElement - | GirConstantElement - | GirPropertyElement, - girTypeName: GirTypeName, - ): boolean { - const a = (girVar as GirCallableParamElement).$ - if (!a) return false - - // Ignore depreciated `allow-none` if one of the new implementation `optional` or `nullable` is set - if (a.optional || a.nullable) { - return girBool(a.optional) - } - - if (girTypeName === 'constant') { - return false // constants are never optional - } - - return girBool(a.optional) || girBool(a['allow-none']) || girBool(a['null-ok']) - } - - /** - * Checks if the property is readonly. - * @param girCallback - */ - private typeIsReadonly(girProp: GirPropertyElement | GirFieldElement): boolean { - const cType = girProp.type?.[0].$?.['c:type'] - return ( - !girBool(girProp.$.writable) || - girBool((girProp as GirPropertyElement).$['construct-only']) || - (cType ? cType.startsWith('const ') : false) // c type is const and therefore readonly, isn't? - ) - } - private setParameterTsData( girParam: GirCallableParamElement, girParams: GirCallableParamElement[], diff --git a/packages/lib/src/newlib/generators/dts-inline.ts b/packages/lib/src/newlib/generators/dts-inline.ts index 273125192..7d674cf35 100644 --- a/packages/lib/src/newlib/generators/dts-inline.ts +++ b/packages/lib/src/newlib/generators/dts-inline.ts @@ -1,4 +1,4 @@ -import { GirNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; +import { IntrospectedNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; import { GirBase } from "../gir.js"; import { GenerationOptions } from "../types.js"; @@ -9,11 +9,11 @@ import { override as overrideGio } from "./dts/gio.js"; import { DtsGenerator } from "./dts.js"; export class DtsInlineGenerator extends DtsGenerator { - constructor(namespace: GirNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { super(namespace, options); } - async generateNamespace(node: GirNamespace): Promise { + async generateNamespace(node: IntrospectedNamespace): Promise { const { namespace, options } = this; if (options.verbose) { @@ -81,7 +81,7 @@ export class DtsInlineGenerator extends DtsGenerator { } } - async stringifyNamespace(node: GirNamespace): Promise { + async stringifyNamespace(node: IntrospectedNamespace): Promise { return this.generateNamespace(node); } } diff --git a/packages/lib/src/newlib/generators/dts-modules.ts b/packages/lib/src/newlib/generators/dts-modules.ts index 7557034a4..7a6696295 100644 --- a/packages/lib/src/newlib/generators/dts-modules.ts +++ b/packages/lib/src/newlib/generators/dts-modules.ts @@ -1,4 +1,4 @@ -import { GirNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; +import { IntrospectedNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; import { GirBase } from "../gir.js"; @@ -10,12 +10,12 @@ import { override as overrideGio } from "./dts/gio.js"; import { DtsGenerator, versionImportFormat } from "./dts.js"; export class DtsModuleGenerator extends DtsGenerator { - constructor(namespace: GirNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { super(namespace, options); } - async generateNamespace(node: GirNamespace): Promise { + async generateNamespace(node: IntrospectedNamespace): Promise { const { namespace, options } = this; if (options.verbose) { @@ -133,7 +133,7 @@ export const __version__: string; } } - async stringifyNamespace(node: GirNamespace): Promise { + async stringifyNamespace(node: IntrospectedNamespace): Promise { return this.generateNamespace(node); } } diff --git a/packages/lib/src/newlib/generators/dts.ts b/packages/lib/src/newlib/generators/dts.ts index 18b6f8010..56e6e2be4 100644 --- a/packages/lib/src/newlib/generators/dts.ts +++ b/packages/lib/src/newlib/generators/dts.ts @@ -1,22 +1,22 @@ import { FormatGenerator } from "./generator.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; import { - GirBaseClass, + IntrospectedBaseClass, GirRecord, GirInterface, - GirClass, + IntrospectedClass, filterConflicts, filterFunctionConflict, FilterBehavior, promisifyFunctions } from "../gir/class.js"; -import { GirConst } from "../gir/const.js"; -import { GirEnum, GirError, GirEnumMember } from "../gir/enum.js"; -import { GirProperty, GirField } from "../gir/property.js"; -import { GirSignal, GirSignalType } from "../gir/signal.js"; -import { GirFunction, GirConstructor, GirFunctionParameter, GirCallback, GirDirectAllocationConstructor } from "../gir/function.js"; -import { GirClassFunction, GirStaticClassFunction, GirVirtualClassFunction } from "../gir/function.js"; +import { IntrospectedConstant } from "../gir/const.js"; +import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; +import { GirProperty, Field } from "../gir/property.js"; +import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; +import { IntrospectedFunction, IntrospectedConstructor, IntrospectedFunctionParameter, IntrospectedCallback, IntrospectedDirectAllocationConstructor } from "../gir/function.js"; +import { IntrospectedClassFunction, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction } from "../gir/function.js"; import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js"; import { TypeExpression, @@ -33,8 +33,8 @@ import { BinaryType, GirBase } from "../gir.js"; -import { Direction } from "@gi.ts/parser"; -import { GirAlias } from "../gir/alias.js"; +import { GirDirection } from "@gi.ts/parser"; +import { IntrospectedAlias } from "../gir/alias.js"; import { GenerationOptions } from "../types.js"; export function versionImportFormat(versionFormat: string, namespace: string, version: string) { @@ -45,11 +45,11 @@ export function versionImportFormat(versionFormat: string, namespace: string, ve } export abstract class DtsGenerator extends FormatGenerator { - constructor(namespace: GirNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { super(namespace, options); } - protected generateParameters(parameters: GirFunctionParameter[]): string { + protected generateParameters(parameters: IntrospectedFunctionParameter[]): string { return parameters .map(p => { return p.asString(this); @@ -87,7 +87,7 @@ export abstract class DtsGenerator extends FormatGenerator { return ""; } - generateCallbackType(node: GirCallback): [string, string] { + generateCallbackType(node: IntrospectedCallback): [string, string] { const { namespace, options } = this; const Parameters = this.generateParameters(node.parameters); @@ -103,15 +103,15 @@ export abstract class DtsGenerator extends FormatGenerator { return [``, `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`]; } - generateCallback(node: GirCallback): string { + generateCallback(node: IntrospectedCallback): string { return `${this.docString(node)}export type ${node.name}${this.generateCallbackType(node).join(" = ")};`; } - generateReturn(return_type: TypeExpression, output_parameters: GirFunctionParameter[]) { + generateReturn(return_type: TypeExpression, output_parameters: IntrospectedFunctionParameter[]) { const { namespace, options } = this; let resolved_return_type = - resolveDirectedType(return_type, Direction.Out)?.resolve(namespace, options) ?? + resolveDirectedType(return_type, GirDirection.Out)?.resolve(namespace, options) ?? return_type.resolve(namespace, options); const type = resolved_return_type.rootPrint(namespace, options); @@ -123,7 +123,7 @@ export abstract class DtsGenerator extends FormatGenerator { ...output_parameters .map(op => { return ( - resolveDirectedType(op.type, Direction.Out)?.resolve(namespace, options) ?? + resolveDirectedType(op.type, GirDirection.Out)?.resolve(namespace, options) ?? op.type.resolve(namespace, options) ); }) @@ -139,7 +139,7 @@ export abstract class DtsGenerator extends FormatGenerator { return type; } - generateEnum(node: GirEnum): string { + generateEnum(node: IntrospectedEnum): string { const { namespace } = this; const isInvalidEnum = Array.from(node.members.keys()).some( @@ -165,7 +165,7 @@ ${this.docString(node)}export enum ${node.name} { }`; } - generateError(node: GirError): string { + generateError(node: IntrospectedError): string { const { namespace } = this; const clazz = node.asClass(); @@ -178,13 +178,13 @@ ${this.docString(node)}export enum ${node.name} { clazz.parent = GLibError.getType(); // Manually construct a GLib.Error constructor. - clazz.mainConstructor = new GirConstructor({ + clazz.mainConstructor = new IntrospectedConstructor({ name: "new", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "options", type: NativeType.of("{ message: string, code: number}"), - direction: Direction.In + direction: GirDirection.In }) ], return_type: clazz.getType() @@ -193,13 +193,13 @@ ${this.docString(node)}export enum ${node.name} { return clazz.asString(this); } - generateConst(node: GirConst): string { + generateConst(node: IntrospectedConstant): string { const { namespace, options } = this; return `${this.docString(node)}export const ${node.name}: ${node.type.resolve(namespace, options).print(namespace, options)};`; } - protected implements(node: GirClass) { + protected implements(node: IntrospectedClass) { const { namespace, options } = this; const interfaces = node.interfaces.map(i => { @@ -226,7 +226,7 @@ ${this.docString(node)}export enum ${node.name} { return ""; } - protected extends(node: GirBaseClass) { + protected extends(node: IntrospectedBaseClass) { const { namespace: ns, options } = this; if (node.parent) { const ResolvedType = node.parent.resolveIdentifier(ns, options); @@ -265,7 +265,7 @@ ${this.docString(node)}export enum ${node.name} { const filteredFunctions = filterFunctionConflict(node.namespace, node, node.members, []); const functions = options.promisify ? promisifyFunctions(filteredFunctions) : filteredFunctions; - const staticFunctions = functions.filter(f => f instanceof GirStaticClassFunction); + const staticFunctions = functions.filter(f => f instanceof IntrospectedStaticClassFunction); const staticFields = node.fields .filter(f => f.isStatic) .map(f => @@ -274,7 +274,7 @@ ${this.docString(node)}export enum ${node.name} { }) ); - const nonStaticFunctions = functions.filter(f => !(f instanceof GirStaticClassFunction)); + const nonStaticFunctions = functions.filter(f => !(f instanceof IntrospectedStaticClassFunction)); const nonStaticFields = node.fields.filter(f => !f.isStatic); const hasNamespace = isGObject || staticFunctions.length > 0 || node.callbacks.length > 0; @@ -300,7 +300,7 @@ ${this.docString(node)}export enum ${node.name} { ${staticFields.length > 0 ? staticFields.map(sf => sf.asString(this)).join(`\n`) : ""} ${ staticFunctions.length > 0 - ? staticFunctions.map(sf => GirClassFunction.prototype.asString.call(sf, this)).join(`\n`) + ? staticFunctions.map(sf => IntrospectedClassFunction.prototype.asString.call(sf, this)).join(`\n`) : "" } }` @@ -394,7 +394,7 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSi }`; } - generateClass(node: GirClass): string { + generateClass(node: IntrospectedClass): string { const { options, namespace } = this; const name = node.name; @@ -468,62 +468,62 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSi // TODO Move these to a cleaner place. - const Connect = new GirClassFunction({ + const Connect = new IntrospectedClassFunction({ name: "connect", parent: node, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: StringType, - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "callback", type: AnyFunctionType, - direction: Direction.In + direction: GirDirection.In }) ], return_type: NumberType }); - const ConnectAfter = new GirClassFunction({ + const ConnectAfter = new IntrospectedClassFunction({ name: "connect_after", parent: node, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: StringType, - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "callback", type: AnyFunctionType, - direction: Direction.In + direction: GirDirection.In }) ], return_type: NumberType }); - const Emit = new GirClassFunction({ + const Emit = new IntrospectedClassFunction({ name: "emit", parent: node, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: StringType, - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "args", isVarArgs: true, type: new ArrayType(AnyType), - direction: Direction.In + direction: GirDirection.In }) ], return_type: VoidType }); - let default_signals = [] as GirClassFunction[]; + let default_signals = [] as IntrospectedClassFunction[]; let hasConnect, hasConnectAfter, hasEmit; if (node.signals.length > 0) { @@ -555,9 +555,9 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSi .map(s => { const methods = [] as string[]; - if (!hasConnect) methods.push(s.asString(this, GirSignalType.CONNECT)); - if (!hasConnectAfter) methods.push(s.asString(this, GirSignalType.CONNECT_AFTER)); - if (!hasEmit) methods.push(s.asString(this, GirSignalType.EMIT)); + if (!hasConnect) methods.push(s.asString(this, IntrospectedSignalType.CONNECT)); + if (!hasConnectAfter) methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER)); + if (!hasEmit) methods.push(s.asString(this, IntrospectedSignalType.EMIT)); return methods; }) @@ -626,7 +626,7 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSi }`; } - generateField(node: GirField): string { + generateField(node: Field): string { const { namespace, options } = this; const { name, computed } = node; const invalid = isInvalid(name); @@ -725,13 +725,13 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSi } } - generateSignal(node: GirSignal, type: GirSignalType = GirSignalType.CONNECT): string { + generateSignal(node: IntrospectedSignal, type: IntrospectedSignalType = IntrospectedSignalType.CONNECT): string { switch (type) { - case GirSignalType.CONNECT: + case IntrospectedSignalType.CONNECT: return node.asConnect(false).asString(this); - case GirSignalType.CONNECT_AFTER: + case IntrospectedSignalType.CONNECT_AFTER: return node.asConnect(true).asString(this); - case GirSignalType.EMIT: + case IntrospectedSignalType.EMIT: return node.asEmit().asString(this); } } @@ -745,7 +745,7 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSi } } - generateParameter(node: GirFunctionParameter): string { + generateParameter(node: IntrospectedFunctionParameter): string { const { namespace, options } = this; let type: string = @@ -775,7 +775,7 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() */\n` : '' } - generateFunction(node: GirFunction): string { + generateFunction(node: IntrospectedFunction): string { const { namespace } = this; // Register our identifier with the sanitized identifiers. // We avoid doing this in fromXML because other class-level function classes @@ -788,7 +788,7 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() return `${this.docString(node)}export function ${node.name}${Generics}(${Parameters}): ${ReturnType};`; } - generateConstructorFunction(node: GirConstructor): string { + generateConstructorFunction(node: IntrospectedConstructor): string { const { namespace, options } = this; const Parameters = this.generateParameters(node.parameters); @@ -802,13 +802,13 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() .rootPrint(namespace, options)};`; } - generateConstructor(node: GirConstructor): string { + generateConstructor(node: IntrospectedConstructor): string { const Parameters = this.generateParameters(node.parameters); return `constructor(${Parameters});`; } - generateDirectAllocationConstructor(node: GirDirectAllocationConstructor): string { + generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string { const ConstructorFields = node.fields.map(field => field.asString(this)).join(`\n`); return ` @@ -817,7 +817,7 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() }>);`; } - generateClassFunction(node: GirClassFunction): string { + generateClassFunction(node: IntrospectedClassFunction): string { const invalid = isInvalid(node.name); let parameters = node.parameters; @@ -841,7 +841,7 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() }${Generics}(${Parameters}): ${ReturnType};`; } - generateStaticClassFunction(node: GirStaticClassFunction): string { + generateStaticClassFunction(node: IntrospectedStaticClassFunction): string { const Generics = this.generateGenerics(node.generics); let ReturnType = this.generateReturn(node.return(), node.output_parameters); @@ -852,7 +852,7 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() )}): ${ReturnType};`; } - generateAlias(node: GirAlias): string { + generateAlias(node: IntrospectedAlias): string { const { namespace, options } = this; const Type = node.type.resolve(namespace, options).print(namespace, options); const GenericBase = node.generics @@ -869,7 +869,7 @@ ${node.doc.split('\n').map(line => ` * ${line.trim() return `${this.docString(node)}export type ${node.name}${Generic} = ${Type};`; } - generateVirtualClassFunction(node: GirVirtualClassFunction): string { + generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): string { return this.generateClassFunction(node); } } diff --git a/packages/lib/src/newlib/generators/dts/gio.ts b/packages/lib/src/newlib/generators/dts/gio.ts index 9d8222712..8e962a6ed 100644 --- a/packages/lib/src/newlib/generators/dts/gio.ts +++ b/packages/lib/src/newlib/generators/dts/gio.ts @@ -1,6 +1,6 @@ -import { GirNamespace } from "../../gir/namespace.js"; +import { IntrospectedNamespace } from "../../gir/namespace.js"; -export function override(_node: GirNamespace) { +export function override(_node: IntrospectedNamespace) { return ` export function _promisify(klass: any, function_name: string, finish_function_name: string): void; export interface _LocalFilePrototype extends FilePrototype {} diff --git a/packages/lib/src/newlib/generators/dts/glib.ts b/packages/lib/src/newlib/generators/dts/glib.ts index eb8026ec5..b083358ef 100644 --- a/packages/lib/src/newlib/generators/dts/glib.ts +++ b/packages/lib/src/newlib/generators/dts/glib.ts @@ -1,6 +1,6 @@ -import { GirNamespace } from "../../gir/namespace.js"; +import { IntrospectedNamespace } from "../../gir/namespace.js"; -export function override(node: GirNamespace) { +export function override(node: IntrospectedNamespace) { // We provide manually written versions of these types below. node.assertClass("Variant").noEmit(); node.assertClass("VariantType").noEmit(); diff --git a/packages/lib/src/newlib/generators/dts/gobject.ts b/packages/lib/src/newlib/generators/dts/gobject.ts index 205b168c0..2306bebc7 100644 --- a/packages/lib/src/newlib/generators/dts/gobject.ts +++ b/packages/lib/src/newlib/generators/dts/gobject.ts @@ -1,20 +1,20 @@ -import { Direction } from "@gi.ts/parser"; +import { GirDirection } from "@gi.ts/parser"; import { NativeType, NeverType } from "../../gir.js"; -import { GirClassFunction, GirFunctionParameter } from "../../gir/function.js"; -import { GirNamespace } from "../../gir/namespace.js"; +import { IntrospectedClassFunction, IntrospectedFunctionParameter } from "../../gir/function.js"; +import { IntrospectedNamespace } from "../../gir/namespace.js"; -export function override(node: GirNamespace) { +export function override(node: IntrospectedNamespace) { const ParamSpec = node.assertClass("ParamSpec"); // We only inject __type__ for .d.ts files. - const type_function = new GirClassFunction({ + const type_function = new IntrospectedClassFunction({ name: "__type__", parent: ParamSpec, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "arg", type: NeverType, - direction: Direction.In + direction: GirDirection.In }) ], return_type: new NativeType("A") diff --git a/packages/lib/src/newlib/generators/generator.ts b/packages/lib/src/newlib/generators/generator.ts index 5da95ebfc..7969c93d5 100644 --- a/packages/lib/src/newlib/generators/generator.ts +++ b/packages/lib/src/newlib/generators/generator.ts @@ -1,14 +1,14 @@ -import { GirNamespace } from "../gir/namespace.js"; -import { GirClass, GirRecord, GirInterface } from "../gir/class.js"; -import { GirConst } from "../gir/const.js"; -import { GirEnum, GirError, GirEnumMember } from "../gir/enum.js"; -import { GirProperty, GirField } from "../gir/property.js"; -import { GirSignal, GirSignalType } from "../gir/signal.js"; -import { GirFunction, GirFunctionParameter, GirConstructor, GirCallback, GirDirectAllocationConstructor } from "../gir/function.js"; -import { GirClassFunction } from "../gir/function.js"; -import { GirStaticClassFunction } from "../gir/function.js"; -import { GirVirtualClassFunction } from "../gir/function.js"; -import { GirAlias } from "../gir/alias.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { IntrospectedClass, GirRecord, GirInterface } from "../gir/class.js"; +import { IntrospectedConstant } from "../gir/const.js"; +import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; +import { GirProperty, Field } from "../gir/property.js"; +import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; +import { IntrospectedFunction, IntrospectedFunctionParameter, IntrospectedConstructor, IntrospectedCallback, IntrospectedDirectAllocationConstructor } from "../gir/function.js"; +import { IntrospectedClassFunction } from "../gir/function.js"; +import { IntrospectedStaticClassFunction } from "../gir/function.js"; +import { IntrospectedVirtualClassFunction } from "../gir/function.js"; +import { IntrospectedAlias } from "../gir/alias.js"; import { TypeExpression } from "../gir.js"; import { GenerationOptions } from "../types.js"; @@ -18,35 +18,35 @@ export interface GenericDescriptor { } export abstract class FormatGenerator { - protected namespace: GirNamespace; + protected namespace: IntrospectedNamespace; protected options: GenerationOptions; - constructor(namespace: GirNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { this.namespace = namespace; this.options = options; } - abstract generateNamespace(node: GirNamespace): Promise; - abstract stringifyNamespace(node: GirNamespace): Promise; + abstract generateNamespace(node: IntrospectedNamespace): Promise; + abstract stringifyNamespace(node: IntrospectedNamespace): Promise; - abstract generateCallback(node: GirCallback): T; - abstract generateAlias(node: GirAlias): T; - abstract generateConstructor(node: GirConstructor): T; - abstract generateDirectAllocationConstructor(node: GirDirectAllocationConstructor): T; - abstract generateConstructorFunction(node: GirConstructor): T; + abstract generateCallback(node: IntrospectedCallback): T; + abstract generateAlias(node: IntrospectedAlias): T; + abstract generateConstructor(node: IntrospectedConstructor): T; + abstract generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): T; + abstract generateConstructorFunction(node: IntrospectedConstructor): T; abstract generateRecord(node: GirRecord): T; abstract generateInterface(node: GirInterface): T; abstract generateEnumMember(node: GirEnumMember): T; - abstract generateError(node: GirError): T; - abstract generateEnum(node: GirEnum): T; - abstract generateConst(node: GirConst): T; - abstract generateClass(node: GirClass): T; - abstract generateParameter(node: GirFunctionParameter): T; + abstract generateError(node: IntrospectedError): T; + abstract generateEnum(node: IntrospectedEnum): T; + abstract generateConst(node: IntrospectedConstant): T; + abstract generateClass(node: IntrospectedClass): T; + abstract generateParameter(node: IntrospectedFunctionParameter): T; abstract generateProperty(node: GirProperty, construct?: boolean): T; - abstract generateField(node: GirField): T; - abstract generateSignal(node: GirSignal, type?: GirSignalType): T; - abstract generateFunction(node: GirFunction): T; - abstract generateClassFunction(node: GirClassFunction): T; - abstract generateStaticClassFunction(node: GirStaticClassFunction): T; - abstract generateVirtualClassFunction(node: GirVirtualClassFunction): T; + abstract generateField(node: Field): T; + abstract generateSignal(node: IntrospectedSignal, type?: IntrospectedSignalType): T; + abstract generateFunction(node: IntrospectedFunction): T; + abstract generateClassFunction(node: IntrospectedClassFunction): T; + abstract generateStaticClassFunction(node: IntrospectedStaticClassFunction): T; + abstract generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): T; } diff --git a/packages/lib/src/newlib/generators/json.ts b/packages/lib/src/newlib/generators/json.ts index 21ea40403..381268317 100644 --- a/packages/lib/src/newlib/generators/json.ts +++ b/packages/lib/src/newlib/generators/json.ts @@ -1,19 +1,19 @@ import { FormatGenerator } from "./generator.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; -import { GirBaseClass, GirRecord, GirInterface, GirClass } from "../gir/class.js"; -import { GirConst } from "../gir/const.js"; -import { GirEnum, GirError, GirEnumMember } from "../gir/enum.js"; -import { GirProperty, GirField } from "../gir/property.js"; -import { GirSignal, GirSignalType } from "../gir/signal.js"; +import { IntrospectedBaseClass, GirRecord, GirInterface, IntrospectedClass } from "../gir/class.js"; +import { IntrospectedConstant } from "../gir/const.js"; +import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; +import { GirProperty, Field } from "../gir/property.js"; +import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; import { - GirFunction, - GirConstructor, - GirFunctionParameter, - GirCallback, - GirDirectAllocationConstructor + IntrospectedFunction, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedCallback, + IntrospectedDirectAllocationConstructor } from "../gir/function.js"; -import { GirClassFunction, GirStaticClassFunction, GirVirtualClassFunction } from "../gir/function.js"; +import { IntrospectedClassFunction, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction } from "../gir/function.js"; import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js"; import { TypeExpression, @@ -33,8 +33,8 @@ import { TypeConflict, GirMetadata } from "../gir.js"; -import { Direction } from "@gi.ts/parser"; -import { GirAlias } from "../gir/alias.js"; +import { GirDirection } from "@gi.ts/parser"; +import { IntrospectedAlias } from "../gir/alias.js"; import { GenerationOptions } from "../types.js"; export const enum NodeKind { @@ -319,7 +319,7 @@ export interface NamespaceJson extends Json { } export class JsonGenerator extends FormatGenerator { - constructor(namespace: GirNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { super(namespace, options); } @@ -332,7 +332,7 @@ export class JsonGenerator extends FormatGenerator { private generateDoc(doc: string): string { const { namespace } = this; - function resolveClass(ns: GirNamespace, className: string): readonly [GirBase | null, boolean] { + function resolveClass(ns: IntrospectedNamespace, className: string): readonly [GirBase | null, boolean] { let classes = ns.getMembers(className); let plural = false; @@ -412,7 +412,7 @@ export class JsonGenerator extends FormatGenerator { let [clazz, plural] = resolveClass(ns, className); - if (clazz instanceof GirBaseClass || clazz instanceof GirEnum) { + if (clazz instanceof IntrospectedBaseClass || clazz instanceof IntrospectedEnum) { const r = `#${plural ? "{" : ""}${ns.name}.${clazz.name}${punc ? `${punc}${modified_name}` : ""}${ plural ? "}s" : "" }`; @@ -479,7 +479,7 @@ export class JsonGenerator extends FormatGenerator { if (functionNamespace) { const [member = null] = functionNamespace.getMembers(functionName.toLowerCase()); - if (member instanceof GirFunction) { + if (member instanceof IntrospectedFunction) { return `${functionNamespace.name}.${member.name}`; } @@ -487,7 +487,7 @@ export class JsonGenerator extends FormatGenerator { } else if (constNamespace) { const [member = null] = constNamespace.getMembers(functionName.toUpperCase()); - if (member instanceof GirConst) { + if (member instanceof IntrospectedConstant) { return `${constNamespace.name}.${member.name}`; } @@ -500,7 +500,7 @@ export class JsonGenerator extends FormatGenerator { const [klass = null] = enumNamespace.getMembers(enumName); - if (klass instanceof GirEnum) { + if (klass instanceof IntrospectedEnum) { return `${enumNamespace.name}.${klass.name}.${memberName.toUpperCase()}`; } } @@ -531,7 +531,7 @@ export class JsonGenerator extends FormatGenerator { { className: "" as string, selectedClassName: "" as string, - resolvedNamespace: null as GirNamespace | null, + resolvedNamespace: null as IntrospectedNamespace | null, selectedIndex: -1 } ); @@ -542,7 +542,7 @@ export class JsonGenerator extends FormatGenerator { let [klass] = resolveClass(resolvedNamespace, selectedClassName); - if (klass instanceof GirBaseClass || klass instanceof GirEnum) { + if (klass instanceof IntrospectedBaseClass || klass instanceof IntrospectedEnum) { return `${resolvedNamespace.name}.${klass.name}.${ upper ? functionName.toUpperCase() : functionName }`; @@ -597,7 +597,7 @@ export class JsonGenerator extends FormatGenerator { return { ...metadata } as MetadataJson; } - private generateParameters(parameters: GirFunctionParameter[]): ParameterJson[] { + private generateParameters(parameters: IntrospectedFunctionParameter[]): ParameterJson[] { const { namespace, options } = this; return parameters.map(p => ({ @@ -612,11 +612,11 @@ export class JsonGenerator extends FormatGenerator { })); } - generateCallbackType(node: GirCallback): [Json, Json] { + generateCallbackType(node: IntrospectedCallback): [Json, Json] { return [{}, {}]; } - generateCallback(node: GirCallback): CallbackJson { + generateCallback(node: IntrospectedCallback): CallbackJson { const { namespace, options } = this; const parameters = this.generateParameters(node.parameters); @@ -633,7 +633,7 @@ export class JsonGenerator extends FormatGenerator { generateReturn( return_type: TypeExpression, - output_parameters: GirFunctionParameter[] + output_parameters: IntrospectedFunctionParameter[] ): TypeJson | TypeJson[] { const { namespace, options } = this; const type = return_type.resolve(namespace, options); @@ -651,7 +651,7 @@ export class JsonGenerator extends FormatGenerator { return generateType(type); } - generateEnum(node: GirEnum): EnumJson { + generateEnum(node: IntrospectedEnum): EnumJson { return { kind: NodeKind.enum, name: node.name, @@ -660,7 +660,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateError(node: GirError): ErrorJson { + generateError(node: IntrospectedError): ErrorJson { const { namespace } = this; const clazz = node.asClass(); @@ -673,13 +673,13 @@ export class JsonGenerator extends FormatGenerator { clazz.parent = GLibError.getType(); // Manually construct a GLib.Error constructor. - clazz.mainConstructor = new GirConstructor({ + clazz.mainConstructor = new IntrospectedConstructor({ name: "new", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "options", type: NativeType.of("{ message: string, code: number}"), - direction: Direction.In + direction: GirDirection.In }) ], return_type: clazz.getType() @@ -709,7 +709,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateConst(node: GirConst): ConstJson { + generateConst(node: IntrospectedConstant): ConstJson { const { namespace, options } = this; return { @@ -720,7 +720,7 @@ export class JsonGenerator extends FormatGenerator { }; } - private implements(node: GirClass): TypeIdentifier[] { + private implements(node: IntrospectedClass): TypeIdentifier[] { const { namespace, options } = this; if (node.interfaces.length > 0) { @@ -732,7 +732,7 @@ export class JsonGenerator extends FormatGenerator { return []; } - private extends(node: GirBaseClass): TypeIdentifier | null { + private extends(node: IntrospectedBaseClass): TypeIdentifier | null { const { namespace: ns, options } = this; if (node.parent) { @@ -771,13 +771,13 @@ export class JsonGenerator extends FormatGenerator { const Properties = node.props.map(v => v && v.asString(this)); const Methods = node.members - .filter(m => !(m instanceof GirStaticClassFunction) && !(m instanceof GirVirtualClassFunction)) + .filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction)) .map(v => v && v.asString(this)); const StaticMethods = node.members - .filter((m): m is GirStaticClassFunction => m instanceof GirStaticClassFunction) + .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) .map(v => v && v.asString(this)); const VirtualMethods = node.members - .filter((m): m is GirVirtualClassFunction => m instanceof GirVirtualClassFunction) + .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) .map(v => v && v.asString(this)); return { @@ -805,13 +805,13 @@ export class JsonGenerator extends FormatGenerator { const Constructors = node.constructors.map(v => v && this.generateConstructorFunction(v)); const Methods = node.members - .filter(m => !(m instanceof GirStaticClassFunction) && !(m instanceof GirVirtualClassFunction)) + .filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction)) .map(v => v && v.asString(this)); const StaticMethods = node.members - .filter((m): m is GirStaticClassFunction => m instanceof GirStaticClassFunction) + .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) .map(v => v && v.asString(this)); const VirtualMethods = node.members - .filter((m): m is GirVirtualClassFunction => m instanceof GirVirtualClassFunction) + .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) .map(v => v && v.asString(this)); const Callbacks = node.callbacks.map(c => c && c.asString(this)); @@ -834,7 +834,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateClass(node: GirClass): ClassJson { + generateClass(node: IntrospectedClass): ClassJson { const Extends = this.extends(node); const Implements = this.implements(node); @@ -871,73 +871,73 @@ export class JsonGenerator extends FormatGenerator { const Constructors = node.constructors.map(v => this.generateConstructorFunction(v)); const Methods = node.members - .filter(m => !(m instanceof GirStaticClassFunction) && !(m instanceof GirVirtualClassFunction)) + .filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction)) .map(v => v && v.asString(this)); const StaticMethods = node.members - .filter((m): m is GirStaticClassFunction => m instanceof GirStaticClassFunction) + .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) .map(v => v && v.asString(this)); const VirtualMethods = node.members - .filter((m): m is GirVirtualClassFunction => m instanceof GirVirtualClassFunction) + .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) .map(v => v && v.asString(this)); // TODO Move these to a cleaner place. - const Connect = new GirClassFunction({ + const Connect = new IntrospectedClassFunction({ name: "connect", parent: node, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: StringType, - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "callback", type: AnyFunctionType, - direction: Direction.In + direction: GirDirection.In }) ], return_type: NumberType }); - const ConnectAfter = new GirClassFunction({ + const ConnectAfter = new IntrospectedClassFunction({ name: "connect_after", parent: node, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: StringType, - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "callback", type: AnyFunctionType, - direction: Direction.In + direction: GirDirection.In }) ], return_type: NumberType }); - const Emit = new GirClassFunction({ + const Emit = new IntrospectedClassFunction({ name: "emit", parent: node, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: StringType, - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "args", isVarArgs: true, type: new ArrayType(AnyType), - direction: Direction.In + direction: GirDirection.In }) ], return_type: VoidType }); - let default_signals = [] as GirClassFunction[]; + let default_signals = [] as IntrospectedClassFunction[]; let hasConnect, hasConnectAfter, hasEmit; if (node.signals.length > 0) { @@ -966,9 +966,9 @@ export class JsonGenerator extends FormatGenerator { .map(s => { const methods = [] as Json[]; - if (!hasConnect) methods.push(s.asString(this, GirSignalType.CONNECT)); - if (!hasConnectAfter) methods.push(s.asString(this, GirSignalType.CONNECT_AFTER)); - if (!hasEmit) methods.push(s.asString(this, GirSignalType.EMIT)); + if (!hasConnect) methods.push(s.asString(this, IntrospectedSignalType.CONNECT)); + if (!hasConnectAfter) methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER)); + if (!hasEmit) methods.push(s.asString(this, IntrospectedSignalType.EMIT)); return methods; }) @@ -996,7 +996,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateField(node: GirField): FieldJson { + generateField(node: Field): FieldJson { const { namespace, options } = this; const { name, computed } = node; const invalid = isInvalid(name); @@ -1037,13 +1037,13 @@ export class JsonGenerator extends FormatGenerator { }; } - generateSignal(node: GirSignal, type: GirSignalType = GirSignalType.CONNECT): MethodJson { + generateSignal(node: IntrospectedSignal, type: IntrospectedSignalType = IntrospectedSignalType.CONNECT): MethodJson { switch (type) { - case GirSignalType.CONNECT: + case IntrospectedSignalType.CONNECT: return node.asConnect(false).asString(this); - case GirSignalType.CONNECT_AFTER: + case IntrospectedSignalType.CONNECT_AFTER: return node.asConnect(true).asString(this); - case GirSignalType.EMIT: + case IntrospectedSignalType.EMIT: return node.asEmit().asString(this); } } @@ -1074,7 +1074,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateParameter(node: GirFunctionParameter): ParameterJson { + generateParameter(node: IntrospectedFunctionParameter): ParameterJson { const { namespace, options } = this; let type = generateType( @@ -1092,7 +1092,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateFunction(node: GirFunction): FunctionJson { + generateFunction(node: IntrospectedFunction): FunctionJson { const { namespace } = this; // Register our identifier with the sanitized identifiers. // We avoid doing this in fromXML because other class-level function classes @@ -1111,7 +1111,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateConstructorFunction(node: GirConstructor): MethodJson { + generateConstructorFunction(node: IntrospectedConstructor): MethodJson { const { namespace, options } = this; const Parameters = this.generateParameters(node.parameters); @@ -1126,7 +1126,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateConstructor(node: GirConstructor): ConstructorJson { + generateConstructor(node: IntrospectedConstructor): ConstructorJson { return { name: node.name, kind: NodeKind.constructor, @@ -1135,16 +1135,16 @@ export class JsonGenerator extends FormatGenerator { }; } - generateDirectAllocationConstructor(node: GirDirectAllocationConstructor): ConstructorJson { + generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): ConstructorJson { return { name: node.name, kind: NodeKind.constructor, parameters: this.generateParameters( node.fields.map( field => - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: field.name, - direction: Direction.In, + direction: GirDirection.In, type: field.type, isOptional: true }) @@ -1154,7 +1154,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateClassFunction(node: GirClassFunction): MethodJson { + generateClassFunction(node: IntrospectedClassFunction): MethodJson { let parameters = node.parameters.map(p => this.generateParameter(p)); let output_parameters = node.output_parameters; let return_type = node.return(); @@ -1170,7 +1170,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateStaticClassFunction(node: GirStaticClassFunction): StaticMethodJson { + generateStaticClassFunction(node: IntrospectedStaticClassFunction): StaticMethodJson { let parameters = node.parameters.map(p => this.generateParameter(p)); let output_parameters = node.output_parameters; let return_type = node.return(); @@ -1186,7 +1186,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateAlias(node: GirAlias): AliasJson { + generateAlias(node: IntrospectedAlias): AliasJson { const { namespace, options } = this; const type = node.type.resolve(namespace, options); @@ -1200,14 +1200,14 @@ export class JsonGenerator extends FormatGenerator { }; } - generateVirtualClassFunction(node: GirVirtualClassFunction): VirtualMethodJson { + generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): VirtualMethodJson { return { ...this.generateClassFunction(node), kind: NodeKind.virtualClassFunction }; } - async generateNamespace(node: GirNamespace): Promise { + async generateNamespace(node: IntrospectedNamespace): Promise { function shouldGenerate(node: GirBase) { return node.emit; } @@ -1218,22 +1218,22 @@ export class JsonGenerator extends FormatGenerator { .flatMap(m => m) .filter(shouldGenerate); - const classes = members.filter((m): m is GirClass => m instanceof GirClass).map(m => m.asString(this)); + const classes = members.filter((m): m is IntrospectedClass => m instanceof IntrospectedClass).map(m => m.asString(this)); const interfaces = members .filter((m): m is GirInterface => m instanceof GirInterface) .map(m => m.asString(this)); const records = members.filter((m): m is GirRecord => m instanceof GirRecord).map(m => m.asString(this)); - const constants = members.filter((m): m is GirConst => m instanceof GirConst).map(m => m.asString(this)); + const constants = members.filter((m): m is IntrospectedConstant => m instanceof IntrospectedConstant).map(m => m.asString(this)); const callbacks = members - .filter((m): m is GirCallback => m instanceof GirCallback) + .filter((m): m is IntrospectedCallback => m instanceof IntrospectedCallback) .map(m => m.asString(this)); // Functions can have overrides. const functions = [ ...members - .filter((m): m is GirFunction => !(m instanceof GirCallback) && m instanceof GirFunction) + .filter((m): m is IntrospectedFunction => !(m instanceof IntrospectedCallback) && m instanceof IntrospectedFunction) .reduce((prev, next) => { if (!prev.has(next.name)) prev.set(next.name, next.asString(this)); @@ -1241,12 +1241,12 @@ export class JsonGenerator extends FormatGenerator { }, new Map()) .values() ]; - const errors = members.filter((m): m is GirError => m instanceof GirError).map(m => m.asString(this)); + const errors = members.filter((m): m is IntrospectedError => m instanceof IntrospectedError).map(m => m.asString(this)); const enums = members - .filter((m): m is GirEnum => !(m instanceof GirError) && m instanceof GirEnum) + .filter((m): m is IntrospectedEnum => !(m instanceof IntrospectedError) && m instanceof IntrospectedEnum) .map(m => m.asString(this)); - const alias = members.filter((m): m is GirAlias => m instanceof GirAlias).map(m => m.asString(this)); + const alias = members.filter((m): m is IntrospectedAlias => m instanceof IntrospectedAlias).map(m => m.asString(this)); // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. const imports = node.getImports(); @@ -1268,7 +1268,7 @@ export class JsonGenerator extends FormatGenerator { }; } - async stringifyNamespace(node: GirNamespace): Promise { + async stringifyNamespace(node: IntrospectedNamespace): Promise { const { namespace, options } = this; if (options.verbose) { diff --git a/packages/lib/src/newlib/generics/clutter.ts b/packages/lib/src/newlib/generics/clutter.ts index fdd862969..7456099fb 100644 --- a/packages/lib/src/newlib/generics/clutter.ts +++ b/packages/lib/src/newlib/generics/clutter.ts @@ -1,9 +1,9 @@ import { GenericType } from "../gir.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; export default { namespace: "Clutter", - modifier: (namespace: GirNamespace, inferGenerics: boolean) => { + modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { if (!inferGenerics) { return; } diff --git a/packages/lib/src/newlib/generics/generify.ts b/packages/lib/src/newlib/generics/generify.ts index 6f735c1dd..1dd9a0f70 100644 --- a/packages/lib/src/newlib/generics/generify.ts +++ b/packages/lib/src/newlib/generics/generify.ts @@ -4,13 +4,13 @@ import clutter from "./clutter.js"; import st from "./st.js"; import meta from "./meta.js"; -import { GirNamespace } from "../gir/namespace.js"; -import { GirNSRegistry } from "../gir/registry.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { NSRegistry } from "../gir/registry.js"; import { GenericVisitor } from "./visitor.js"; -type NamespaceModifier = (namespace: GirNamespace, inferGenerics: boolean) => void; +type NamespaceModifier = (namespace: IntrospectedNamespace, inferGenerics: boolean) => void; -function generifyDefinitions(registry: GirNSRegistry, inferGenerics: boolean, required: boolean = true) { +function generifyDefinitions(registry: NSRegistry, inferGenerics: boolean, required: boolean = true) { return (definition: { namespace: string; version?: string; modifier: NamespaceModifier }) => { const version = definition?.version ?? registry.defaultVersionOf(definition.namespace); @@ -29,7 +29,7 @@ function generifyDefinitions(registry: GirNSRegistry, inferGenerics: boolean, re }; } -export function generify(registry: GirNSRegistry, inferGenerics: boolean) { +export function generify(registry: NSRegistry, inferGenerics: boolean) { const $ = generifyDefinitions(registry, inferGenerics); $(gio); diff --git a/packages/lib/src/newlib/generics/gio.ts b/packages/lib/src/newlib/generics/gio.ts index 4bf21ff48..839d3f474 100644 --- a/packages/lib/src/newlib/generics/gio.ts +++ b/packages/lib/src/newlib/generics/gio.ts @@ -1,10 +1,10 @@ import { AnyType, Generic, GenericType, GenerifiedTypeIdentifier, StringType, TypeIdentifier } from "../gir.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; export default { namespace: "Gio", version: "2.0", - modifier: (namespace: GirNamespace) => { + modifier: (namespace: IntrospectedNamespace) => { const AsyncInitable = namespace.getClass("AsyncInitable"); if (!AsyncInitable) { diff --git a/packages/lib/src/newlib/generics/glib.ts b/packages/lib/src/newlib/generics/glib.ts index a5d69c80b..cabd05e0c 100644 --- a/packages/lib/src/newlib/generics/glib.ts +++ b/packages/lib/src/newlib/generics/glib.ts @@ -1,10 +1,10 @@ import { AnyType, StringType } from "../gir.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; export default { namespace: "GLib", version: "2.0", - modifier: (namespace: GirNamespace) => { + modifier: (namespace: IntrospectedNamespace) => { const HashTable = namespace.getClass("HashTable"); if (!HashTable) { diff --git a/packages/lib/src/newlib/generics/meta.ts b/packages/lib/src/newlib/generics/meta.ts index 8826f9e78..b6bd4b2cf 100644 --- a/packages/lib/src/newlib/generics/meta.ts +++ b/packages/lib/src/newlib/generics/meta.ts @@ -1,9 +1,9 @@ import { GenerifiedTypeIdentifier } from "../gir.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; export default { namespace: "Meta", - modifier: (namespace: GirNamespace, inferGenerics: boolean) => { + modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { if (!inferGenerics) { return; } diff --git a/packages/lib/src/newlib/generics/st.ts b/packages/lib/src/newlib/generics/st.ts index 6c5f659ae..8e435bcdd 100644 --- a/packages/lib/src/newlib/generics/st.ts +++ b/packages/lib/src/newlib/generics/st.ts @@ -1,10 +1,10 @@ import { GenericType, GenerifiedTypeIdentifier } from "../gir.js"; -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; export default { namespace: "St", version: "1.0", - modifier: (namespace: GirNamespace, inferGenerics: boolean) => { + modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { if (!inferGenerics) { return; } diff --git a/packages/lib/src/newlib/generics/visitor.ts b/packages/lib/src/newlib/generics/visitor.ts index aaacc915b..33b2c9121 100644 --- a/packages/lib/src/newlib/generics/visitor.ts +++ b/packages/lib/src/newlib/generics/visitor.ts @@ -6,32 +6,32 @@ import { GenerifiedTypeIdentifier, ThisType } from "../gir.js"; -import { GirClass, GirBaseClass, GirInterface } from "../gir/class.js"; +import { IntrospectedClass, IntrospectedBaseClass, GirInterface } from "../gir/class.js"; import { - GirCallback, - GirFunctionParameter, - GirFunction, - GirClassFunction, - GirStaticClassFunction, - GirVirtualClassFunction + IntrospectedCallback, + IntrospectedFunctionParameter, + IntrospectedFunction, + IntrospectedClassFunction, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction } from "../gir/function.js"; import { GenericNameGenerator } from "../gir/generics.js"; -import { GirNSRegistry } from "../gir/registry.js"; +import { NSRegistry } from "../gir/registry.js"; import { resolveTypeIdentifier } from "../gir/util.js"; import { GirVisitor } from "../visitor.js"; export class GenericVisitor extends GirVisitor { - registry: GirNSRegistry; + registry: NSRegistry; inferGenerics: boolean; - constructor(registry: GirNSRegistry, inferGenerics: boolean) { + constructor(registry: NSRegistry, inferGenerics: boolean) { super(); this.registry = registry; this.inferGenerics = inferGenerics; } - visitCallback = (node: GirCallback) => { + visitCallback = (node: IntrospectedCallback) => { if (!this.inferGenerics) { return node; } @@ -74,7 +74,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitClass = (node: GirClass) => { + visitClass = (node: IntrospectedClass) => { return this.visitBaseClass(node); }; @@ -82,7 +82,7 @@ export class GenericVisitor extends GirVisitor { return this.visitBaseClass(node); }; - visitBaseClass = (_node: T): T => { + visitBaseClass = (_node: T): T => { const node = _node.copy() as T; const { namespace } = _node; @@ -90,10 +90,10 @@ export class GenericVisitor extends GirVisitor { const resolvedParent = node.parent ? resolveTypeIdentifier(namespace, node.parent) : null; let derivatives = node.generics.filter(generic => generic.parent != null); - if (node instanceof GirClass) { + if (node instanceof IntrospectedClass) { const resolvedInterfaces = node.interfaces .map(i => resolveTypeIdentifier(namespace, i)) - .filter((c): c is GirBaseClass => c != null); + .filter((c): c is IntrospectedBaseClass => c != null); node.interfaces = node.interfaces.map(iface => { const generic = derivatives.filter(d => d.parent?.is(iface.namespace, iface.name)); @@ -217,7 +217,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitParameter = (node: GirFunctionParameter) => { + visitParameter = (node: IntrospectedFunctionParameter) => { const { inferGenerics } = this; const member = node.parent; @@ -229,7 +229,7 @@ export class GenericVisitor extends GirVisitor { const internal = unwrapped.type.unwrap(); if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { - if (member instanceof GirFunction && member.parameters.length >= 2) { + if (member instanceof IntrospectedFunction && member.parameters.length >= 2) { const generified = node.copy({ type: node.type.rewrap( new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parameters[0].type]) @@ -237,7 +237,7 @@ export class GenericVisitor extends GirVisitor { }); return generified; - } else if (member instanceof GirStaticClassFunction) { + } else if (member instanceof IntrospectedStaticClassFunction) { const generified = node.copy({ type: node.type.rewrap( new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parent.getType()]) @@ -245,7 +245,7 @@ export class GenericVisitor extends GirVisitor { }); return generified; - } else if (member instanceof GirClassFunction) { + } else if (member instanceof IntrospectedClassFunction) { const generified = node.copy({ type: node.type.rewrap( new GenerifiedTypeIdentifier(internal.name, internal.namespace, [ThisType]) @@ -260,7 +260,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitFunction = (node: GirFunction) => { + visitFunction = (node: IntrospectedFunction) => { if (!this.inferGenerics) { return node; } @@ -283,7 +283,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - private generifyStandaloneClassFunction = (node: GirClassFunction) => { + private generifyStandaloneClassFunction = (node: IntrospectedClassFunction) => { const unwrapped = node.return().unwrap(); if (node.parent.getType().is("GObject", "Object")) { @@ -305,7 +305,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitStaticClassFunction = (node: GirStaticClassFunction) => { + visitStaticClassFunction = (node: IntrospectedStaticClassFunction) => { if (this.inferGenerics) { return this.generifyStandaloneClassFunction(node); } @@ -313,8 +313,8 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitClassFunction = (node: GirClassFunction) => { - if (node.parent instanceof GirBaseClass) { + visitClassFunction = (node: IntrospectedClassFunction) => { + if (node.parent instanceof IntrospectedBaseClass) { const clazz = node.parent; if (clazz.generics.length > 0) { @@ -362,7 +362,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitVirtualClassFunction = (node: GirVirtualClassFunction) => { + visitVirtualClassFunction = (node: IntrospectedVirtualClassFunction) => { return this.visitClassFunction(node); }; } diff --git a/packages/lib/src/newlib/gir.ts b/packages/lib/src/newlib/gir.ts index 1ce06cb22..2b25e05f8 100644 --- a/packages/lib/src/newlib/gir.ts +++ b/packages/lib/src/newlib/gir.ts @@ -1,11 +1,9 @@ -import { GirNamespace } from "./gir/namespace.js"; -import { GirProperty, GirField } from "./gir/property.js"; -import { FormatGenerator } from "./generators/generator.js"; -import { GenerationOptions, LoadOptions } from "./types.js"; +import { IntrospectedNamespace } from "./gir/namespace.js"; +import { GirProperty, Field } from "./gir/property.js"; +import { GenerationOptions } from "./types.js"; import { sanitizeIdentifierName } from "./gir/util.js"; -import { GirVisitor } from "./visitor.js"; -export {GirBase, GirOptions, GirMetadata} from './gir/base.js'; +export {IntrospectedBase as GirBase, Options as GirOptions, Metadata as GirMetadata} from './gir/base.js'; export abstract class TypeExpression { isPointer = false; @@ -18,10 +16,10 @@ export abstract class TypeExpression { } abstract rewrap(type: TypeExpression): TypeExpression; - abstract resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression; + abstract resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression; - abstract print(namespace: GirNamespace, options: GenerationOptions): string; - rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + abstract print(namespace: IntrospectedNamespace, options: GenerationOptions): string; + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { return this.print(namespace, options); } } @@ -52,7 +50,7 @@ export class TypeIdentifier extends TypeExpression { return type; } - protected _resolve(namespace: GirNamespace, options: GenerationOptions): TypeIdentifier | null { + protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { const type = this; let name: string = sanitizeIdentifierName(null, type.name); let ns_name = type.namespace; @@ -121,11 +119,11 @@ export class TypeIdentifier extends TypeExpression { return null; } - resolveIdentifier(namespace: GirNamespace, options: GenerationOptions): TypeIdentifier | null { + resolveIdentifier(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { return this._resolve(namespace, options); } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { const resolved = this._resolve(namespace, options); // Generally if we can't resolve a type it is not introspectable, @@ -137,7 +135,7 @@ export class TypeIdentifier extends TypeExpression { return new TypeIdentifier(name, namespace); } - print(namespace: GirNamespace, _options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, _options: GenerationOptions): string { if (namespace.name === this.namespace) { return `${this.name}`; } else { @@ -154,7 +152,7 @@ export class GenerifiedTypeIdentifier extends TypeIdentifier { this.generics = generics; } - print(namespace: GirNamespace, _options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, _options: GenerationOptions): string { const Generics = this.generics.map(generic => generic.print(namespace, _options)).join(", "); if (namespace.name === this.namespace) { @@ -164,7 +162,7 @@ export class GenerifiedTypeIdentifier extends TypeIdentifier { } } - _resolve(namespace: GirNamespace, options: GenerationOptions): TypeIdentifier | null { + _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { const iden = super._resolve(namespace, options); if (iden) { @@ -188,11 +186,11 @@ export class NativeType extends TypeExpression { return type; } - resolve(_namespace: GirNamespace, _options: GenerationOptions): TypeExpression { + resolve(_namespace: IntrospectedNamespace, _options: GenerationOptions): TypeExpression { return this; } - print(_namespace: GirNamespace, options: GenerationOptions) { + print(_namespace: IntrospectedNamespace, options: GenerationOptions) { return this.expression(options); } @@ -229,17 +227,17 @@ export class OrType extends TypeExpression { return this; } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { const [type, ...types] = this.types; return new OrType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); } - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { return `(${this.types.map(t => t.print(namespace, options)).join(" | ")})`; } - rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { return `${this.types.map(t => t.print(namespace, options)).join(" | ")}`; } @@ -253,15 +251,15 @@ export class OrType extends TypeExpression { } export class TupleType extends OrType { - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { return `[${this.types.map(t => t.print(namespace, options)).join(", ")}]`; } - rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { return this.print(namespace, options); } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { const [type, ...types] = this.types; return new TupleType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); @@ -285,7 +283,7 @@ export class BinaryType extends OrType { return this; } - resolve(namespace: GirNamespace, options: GenerationOptions) { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { return new BinaryType(this.a.resolve(namespace, options), this.b.resolve(namespace, options)); } @@ -337,7 +335,7 @@ export class FunctionType extends TypeExpression { return this; } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { return new FunctionType( Object.fromEntries( Object.entries(this.parameterTypes).map(([k, p]) => { @@ -348,7 +346,7 @@ export class FunctionType extends TypeExpression { ); } - rootPrint(namespace: GirNamespace, options: GenerationOptions): string { + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { const Parameters = Object.entries(this.parameterTypes) .map(([k, v]) => { return `${k}: ${v.rootPrint(namespace, options)}`; @@ -358,7 +356,7 @@ export class FunctionType extends TypeExpression { return `(${Parameters}) => ${this.returnType.print(namespace, options)}`; } - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { return `(${this.rootPrint(namespace, options)})`; } } @@ -420,7 +418,7 @@ export class GenerifiedType extends TypeExpression { this.generic = generic; } - resolve(namespace: GirNamespace, options: GenerationOptions) { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { return new GenerifiedType( this.type.resolve(namespace, options), this.generic.resolve(namespace, options) @@ -431,11 +429,11 @@ export class GenerifiedType extends TypeExpression { return this.type; } - rootPrint(namespace: GirNamespace, options: GenerationOptions) { + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions) { return `${this.type.print(namespace, options)}<${this.generic.print(namespace, options)}>`; } - print(namespace: GirNamespace, options: GenerationOptions) { + print(namespace: IntrospectedNamespace, options: GenerationOptions) { return `${this.type.print(namespace, options)}<${this.generic.print(namespace, options)}>`; } @@ -478,11 +476,11 @@ export class GenericType extends TypeExpression { return type; } - resolve(_namespace: GirNamespace, _options: GenerationOptions): GenericType { + resolve(_namespace: IntrospectedNamespace, _options: GenerationOptions): GenericType { return this; } - print(_namespace: GirNamespace, _options: GenerationOptions): string { + print(_namespace: IntrospectedNamespace, _options: GenerationOptions): string { return `${this.identifier}`; } } @@ -525,11 +523,11 @@ export class PromiseType extends TypeExpression { return new PromiseType(this.type.rewrap(type)); } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { return new PromiseType(this.type.resolve(namespace, options)); } - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { // TODO: Optimize this check. if (!namespace.hasSymbol("Promise")) { return `Promise<${this.type.print(namespace, options)}>`; @@ -593,7 +591,7 @@ export class TypeConflict extends TypeExpression { return true; } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { throw new Error( `Type conflict was not resolved for ${this.type .resolve(namespace, options) @@ -601,7 +599,7 @@ export class TypeConflict extends TypeExpression { ); } - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { throw new Error( `Type conflict was not resolved for ${this.type .resolve(namespace, options) @@ -644,7 +642,7 @@ export class ClosureType extends TypeExpression { return this; } - resolve(namespace: GirNamespace, options: GenerationOptions) { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { const { user_data, type } = this; return ClosureType.new({ @@ -653,7 +651,7 @@ export class ClosureType extends TypeExpression { }); } - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { return this.type.print(namespace, options); } @@ -701,7 +699,7 @@ export class ArrayType extends TypeExpression { return false; } - resolve(namespace: GirNamespace, options: GenerationOptions): TypeExpression { + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { const { type, arrayDepth, length } = this; return ArrayType.new({ type: type.resolve(namespace, options), @@ -710,7 +708,7 @@ export class ArrayType extends TypeExpression { }); } - print(namespace: GirNamespace, options: GenerationOptions): string { + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { const depth = this.arrayDepth; let typeSuffix: string = ""; @@ -755,4 +753,4 @@ export const VoidType = new NativeType("void"); export const UnknownType = new NativeType("unknown"); export const AnyFunctionType = new NativeType("(...args: any[]) => any"); -export type GirClassField = GirProperty | GirField; +export type GirClassField = GirProperty | Field; diff --git a/packages/lib/src/newlib/gir/alias.ts b/packages/lib/src/newlib/gir/alias.ts index 4a8a6008b..1dc9da106 100644 --- a/packages/lib/src/newlib/gir/alias.ts +++ b/packages/lib/src/newlib/gir/alias.ts @@ -1,14 +1,14 @@ import { TypeExpression } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; +import {IntrospectedBase as IntrospectedBase, Options} from './base.js'; -import { AliasElement } from "@gi.ts/parser"; -import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { GirAliasElement } from "../../index.js"; +import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { sanitizeIdentifierName, getAliasType, parseDoc, parseMetadata } from "./util.js"; import { FormatGenerator, GenericDescriptor } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export class GirAlias extends GirBase { +export class IntrospectedAlias extends IntrospectedBase { readonly type: TypeExpression; readonly generics: GenericDescriptor[]; @@ -17,7 +17,7 @@ export class GirAlias extends GirBase { type, generics = [], ...args - }: GirOptions<{ + }: Options<{ name: string; type: TypeExpression; generics?: GenericDescriptor[]; @@ -28,7 +28,7 @@ export class GirAlias extends GirBase { this.generics = generics; } - accept(visitor: GirVisitor): GirAlias { + accept(visitor: GirVisitor): IntrospectedAlias { const node = this.copy({ type: visitor.visitType?.(this.type) }); @@ -36,10 +36,10 @@ export class GirAlias extends GirBase { return visitor.visitAlias?.(node) ?? node; } - copy(options?: { parent?: undefined; type?: TypeExpression }): GirAlias { + copy(options?: { parent?: undefined; type?: TypeExpression }): IntrospectedAlias { const { name, type } = this; - return new GirAlias({ name, type: options?.type ?? type })._copyBaseProperties(this); + return new IntrospectedAlias({ name, type: options?.type ?? type })._copyBaseProperties(this); } asString>(generator: T): ReturnType { @@ -48,17 +48,17 @@ export class GirAlias extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, _parent, - m: AliasElement - ): GirAlias | null { + m: GirAliasElement + ): IntrospectedAlias | null { if (!m.$.name) { console.error(`Alias in ${modName} lacks name.`); return null; } - const alias = new GirAlias({ + const alias = new IntrospectedAlias({ name: sanitizeIdentifierName(ns.name, m.$.name), type: getAliasType(modName, ns, m), isIntrospectable: isIntrospectable(m) diff --git a/packages/lib/src/newlib/gir/base.ts b/packages/lib/src/newlib/gir/base.ts index 18ac7d437..f3a1b9dcd 100644 --- a/packages/lib/src/newlib/gir/base.ts +++ b/packages/lib/src/newlib/gir/base.ts @@ -1,26 +1,26 @@ import { FormatGenerator } from "../generators/index.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -import { GirNamespace } from "./nodes.js"; +import { IntrospectedNamespace } from "./namespace.js"; -export interface GirMetadata { +export interface Metadata { deprecated?: boolean; deprecatedVersion?: string; deprecatedDoc?: string; introducedVersion?: string; } - export interface GirBaseOptions { + export interface BaseOptions { isPrivate?: boolean; isIntrospectable?: boolean; } - export type GirOptions = GirBaseOptions & T; + export type Options = BaseOptions & T; - export abstract class GirBase { + export abstract class IntrospectedBase { name: string; doc?: string | null; - metadata?: GirMetadata; + metadata?: Metadata; deprecated?: boolean; resolve_names: string[] = []; private _emit = true; @@ -28,7 +28,7 @@ export interface GirMetadata { private _isPrivate: boolean; private _isIntrospectable: boolean; - constructor(name: string, options: GirBaseOptions = {}) { + constructor(name: string, options: BaseOptions = {}) { this.name = name; this._isPrivate = options.isPrivate ?? false; @@ -83,17 +83,17 @@ export interface GirMetadata { return this; } - abstract copy(options?: { parent?: GirBase }): GirBase; + abstract copy(options?: { parent?: IntrospectedBase }): IntrospectedBase; - abstract accept(visitor: GirVisitor): GirBase; + abstract accept(visitor: GirVisitor): IntrospectedBase; static fromXML( _modName: string, - _ns: GirNamespace, + _ns: IntrospectedNamespace, _options: LoadOptions, - _parent: GirBase | null, + _parent: IntrospectedBase | null, _gir: object - ): GirBase | null { + ): IntrospectedBase | null { throw new Error("GirBase cannot be instantiated"); } diff --git a/packages/lib/src/newlib/gir/class.ts b/packages/lib/src/newlib/gir/class.ts index 1d8df724f..9d35c0df0 100644 --- a/packages/lib/src/newlib/gir/class.ts +++ b/packages/lib/src/newlib/gir/class.ts @@ -19,21 +19,21 @@ import { TypeConflict } from "../gir.js"; import { TypeExpression } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; +import {IntrospectedBase} from './base.js'; -import { InterfaceElement, ClassElement, RecordElement, Direction, UnionElement } from "@gi.ts/parser"; +import { GirInterfaceElement, GirClassElement, GirRecordElement, GirDirection, GirUnionElement } from "../../index.js"; import { - GirClassFunction, - GirVirtualClassFunction, - GirStaticClassFunction, - GirCallback, - GirFunction, - GirConstructor, - GirFunctionParameter, - GirDirectAllocationConstructor + IntrospectedClassFunction, + IntrospectedVirtualClassFunction, + IntrospectedStaticClassFunction, + IntrospectedCallback, + IntrospectedFunction, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedDirectAllocationConstructor } from "./function.js"; -import { GirProperty, GirField } from "./property.js"; -import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { GirProperty, Field } from "./property.js"; +import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { sanitizeIdentifierName, parseTypeIdentifier, @@ -42,7 +42,7 @@ import { parseDoc, parseMetadata } from "./util.js"; -import { GirSignal } from "./signal.js"; +import { IntrospectedSignal } from "./signal.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; @@ -54,9 +54,9 @@ export enum FilterBehavior { PRESERVE } -export function filterConflicts( - ns: GirNamespace, - c: GirBaseClass, +export function filterConflicts( + ns: IntrospectedNamespace, + c: IntrospectedBaseClass, elements: T[], behavior = FilterBehavior.PRESERVE ): T[] { @@ -72,7 +72,7 @@ export function filterConflicts( } if ( - next instanceof GirField && + next instanceof Field && !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) ) { return ConflictType.FIELD_NAME_CONFLICT; @@ -87,7 +87,7 @@ export function filterConflicts( ? c.findParentMap(resolved_parent => { return findMap([...resolved_parent.props], p => { if (p.name && p.name == next.name) { - if (next instanceof GirField) { + if (next instanceof Field) { return ConflictType.PROPERTY_ACCESSOR_CONFLICT; } @@ -113,7 +113,7 @@ export function filterConflicts( findMap([...resolved_parent.constructors, ...resolved_parent.members], p => { if (p.name && p.name == next.name) { if ( - !(next instanceof GirClassFunction) || + !(next instanceof IntrospectedClassFunction) || isConflictingFunction(ns, thisType, next, resolved_parent.getType(), p) ) { return ConflictType.FUNCTION_NAME_CONFLICT; @@ -127,7 +127,7 @@ export function filterConflicts( const conflict = field_conflicts || prop_conflicts || function_conflicts; if (conflict) { if (behavior === FilterBehavior.PRESERVE) { - if (next instanceof GirField || next instanceof GirProperty) { + if (next instanceof Field || next instanceof GirProperty) { prev.push( next.copy({ type: new TypeConflict(next.type, conflict) @@ -146,13 +146,13 @@ export function filterConflicts( } function isConflictingFunction( - namespace: GirNamespace, + namespace: IntrospectedNamespace, childThis: TypeIdentifier, - child: GirFunction | GirClassFunction | GirConstructor, + child: IntrospectedFunction | IntrospectedClassFunction | IntrospectedConstructor, parentThis: TypeIdentifier, - parent: GirClassFunction | GirFunction | GirConstructor + parent: IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor ) { - if (child instanceof GirConstructor && parent instanceof GirConstructor) { + if (child instanceof IntrospectedConstructor && parent instanceof IntrospectedConstructor) { return ( child.parameters.length > parent.parameters.length || !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || @@ -160,7 +160,7 @@ function isConflictingFunction( (p, i) => !isSubtypeOf(namespace, childThis, parentThis, p.type, parent.parameters[i].type) ) ); - } else if (child instanceof GirConstructor || parent instanceof GirConstructor) { + } else if (child instanceof IntrospectedConstructor || parent instanceof IntrospectedConstructor) { return true; } @@ -184,8 +184,8 @@ function isConflictingFunction( } export function filterFunctionConflict< - T extends GirStaticClassFunction | GirVirtualClassFunction | GirClassFunction | GirConstructor ->(ns: GirNamespace, base: GirBaseClass, elements: T[], conflict_ids: string[]) { + T extends IntrospectedStaticClassFunction | IntrospectedVirtualClassFunction | IntrospectedClassFunction | IntrospectedConstructor +>(ns: IntrospectedNamespace, base: IntrospectedBaseClass, elements: T[], conflict_ids: string[]) { const nextType = base.getType(); return elements .filter(m => m.name) @@ -221,11 +221,11 @@ export function filterFunctionConflict< } if (conflicts) { - let never: GirConstructor | GirFunction | GirStaticClassFunction | GirVirtualClassFunction; + let never: IntrospectedConstructor | IntrospectedFunction | IntrospectedStaticClassFunction | IntrospectedVirtualClassFunction; - const never_param = new GirFunctionParameter({ + const never_param = new IntrospectedFunctionParameter({ name: "args", - direction: Direction.In, + direction: GirDirection.In, isVarArgs: true, type: new ArrayType(NeverType) }); @@ -236,14 +236,14 @@ export function filterFunctionConflict< return_type: AnyType }; - if (next instanceof GirConstructor) { - never = new GirConstructor(neverOptions); - } else if (next instanceof GirStaticClassFunction) { - never = new GirStaticClassFunction({ ...neverOptions, parent: next.parent }); - } else if (next instanceof GirVirtualClassFunction && next.parent instanceof GirClass) { - never = new GirVirtualClassFunction({ ...neverOptions, parent: next.parent }); - } else if (next instanceof GirClassFunction) { - never = new GirClassFunction({ ...neverOptions, parent: next.parent }); + if (next instanceof IntrospectedConstructor) { + never = new IntrospectedConstructor(neverOptions); + } else if (next instanceof IntrospectedStaticClassFunction) { + never = new IntrospectedStaticClassFunction({ ...neverOptions, parent: next.parent }); + } else if (next instanceof IntrospectedVirtualClassFunction && next.parent instanceof IntrospectedClass) { + never = new IntrospectedVirtualClassFunction({ ...neverOptions, parent: next.parent }); + } else if (next instanceof IntrospectedClassFunction) { + never = new IntrospectedClassFunction({ ...neverOptions, parent: next.parent }); } else { throw new Error(`Unknown function type ${Object.getPrototypeOf(next)?.name} encountered.`); } @@ -261,7 +261,7 @@ export function filterFunctionConflict< }, [] as T[]); } -export function promisifyFunctions(functions: GirClassFunction[]) { +export function promisifyFunctions(functions: IntrospectedClassFunction[]) { return functions .map(node => { if (node.parameters.length > 0) { @@ -276,16 +276,16 @@ export function promisifyFunctions(functions: GirClassFunction[]) { const parent = node.parent; const interfaceParent = node.interfaceParent; - if (parent instanceof GirBaseClass) { + if (parent instanceof IntrospectedBaseClass) { let async_res = ( - node instanceof GirStaticClassFunction + node instanceof IntrospectedStaticClassFunction ? [ ...parent.constructors, - ...parent.members.filter(m => m instanceof GirStaticClassFunction) + ...parent.members.filter(m => m instanceof IntrospectedStaticClassFunction) ] : [ ...(interfaceParent instanceof GirInterface ? [...interfaceParent.members] : []), - ...parent.members.filter(m => !(m instanceof GirStaticClassFunction)) + ...parent.members.filter(m => !(m instanceof IntrospectedStaticClassFunction)) ] ).find( m => @@ -297,7 +297,7 @@ export function promisifyFunctions(functions: GirClassFunction[]) { const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); const output_parameters = - async_res instanceof GirConstructor ? [] : async_res.output_parameters; + async_res instanceof IntrospectedConstructor ? [] : async_res.output_parameters; let async_return = new PromiseType(async_res.return()); @@ -347,17 +347,17 @@ export const enum ClassInjectionMember { export interface ClassDefinition { parent: TypeIdentifier; interfaces: TypeIdentifier[]; - mainConstructor: GirConstructor; - constructors: GirConstructor[]; - members: GirClassFunction[]; + mainConstructor: IntrospectedConstructor; + constructors: IntrospectedConstructor[]; + members: IntrospectedClassFunction[]; props: GirProperty[]; - fields: GirField[]; - callbacks: GirCallback[]; + fields: Field[]; + callbacks: IntrospectedCallback[]; } export interface ResolutionNode { identifier: TypeIdentifier; - node: GirBaseClass; + node: IntrospectedBaseClass; } export interface InterfaceResolution extends ResolutionNode, Iterable { @@ -368,7 +368,7 @@ export interface InterfaceResolution extends ResolutionNode, Iterable { extends(): ClassResolution | undefined; implements(): InterfaceResolution[]; - node: GirClass; + node: IntrospectedClass; } export interface RecordResolution extends ResolutionNode, Iterable { @@ -376,17 +376,17 @@ export interface RecordResolution extends ResolutionNode, Iterable ) { @@ -424,23 +424,23 @@ export abstract class GirBaseClass extends GirBase { this.callbacks = [...callbacks.map(c => c.copy())]; } - abstract accept(visitor: GirVisitor): GirBaseClass; + abstract accept(visitor: GirVisitor): IntrospectedBaseClass; abstract copy(options?: { parent?: undefined; - constructors?: GirConstructor[]; - members?: GirClassFunction[]; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; props?: GirProperty[]; - fields?: GirField[]; - callbacks?: GirCallback[]; - }): GirBaseClass; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; + }): IntrospectedBaseClass; getGenericName = GenericNameGenerator.new(); abstract resolveParents(): RecordResolution | InterfaceResolution | ClassResolution; - abstract someParent(predicate: (b: GirBaseClass) => boolean): boolean; - abstract findParent(predicate: (b: GirBaseClass) => boolean): GirBaseClass | undefined; - abstract findParentMap(predicate: (b: GirBaseClass) => K | undefined): K | undefined; + abstract someParent(predicate: (b: IntrospectedBaseClass) => boolean): boolean; + abstract findParent(predicate: (b: IntrospectedBaseClass) => boolean): IntrospectedBaseClass | undefined; + abstract findParentMap(predicate: (b: IntrospectedBaseClass) => K | undefined): K | undefined; addGeneric(definition: { deriveFrom?: TypeIdentifier; @@ -465,29 +465,29 @@ export abstract class GirBaseClass extends GirBase { static fromXML( _modName: string, - _ns: GirNamespace, + _ns: IntrospectedNamespace, _options: LoadOptions, _parent, - _klass: ClassElement | InterfaceElement | RecordElement - ): GirBaseClass { + _klass: GirClassElement | GirInterfaceElement | GirRecordElement + ): IntrospectedBaseClass { throw new Error("fromXML is not implemented on GirBaseClass"); } abstract asString(generator: FormatGenerator): T; } -export class GirClass extends GirBaseClass { - signals: GirSignal[] = []; +export class IntrospectedClass extends IntrospectedBaseClass { + signals: IntrospectedSignal[] = []; interfaces: TypeIdentifier[] = []; isAbstract: boolean = false; - mainConstructor: null | GirConstructor = null; + mainConstructor: null | IntrospectedConstructor = null; private _staticDefinition: string | null = null; - constructor(name: string, namespace: GirNamespace) { + constructor(name: string, namespace: IntrospectedNamespace) { super({ name, namespace }); } - accept(visitor: GirVisitor): GirClass { + accept(visitor: GirVisitor): IntrospectedClass { const node = this.copy({ signals: this.signals.map(s => s.accept(visitor)), constructors: this.constructors.map(c => c.accept(visitor)), @@ -499,15 +499,15 @@ export class GirClass extends GirBaseClass { return visitor.visitClass?.(node) ?? node; } - hasInstanceSymbol(s: GirBase): boolean { + hasInstanceSymbol(s: IntrospectedBase): boolean { return ( - this.members.some(p => s.name === p.name && !(p instanceof GirStaticClassFunction)) || + this.members.some(p => s.name === p.name && !(p instanceof IntrospectedStaticClassFunction)) || this.props.some(p => s.name === p.name) || this.fields.some(p => s.name === p.name) ); } - someParent(predicate: (p: GirClass | GirInterface) => boolean): boolean { + someParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): boolean { const resolution = this.resolveParents(); const parent = resolution.extends(); @@ -527,7 +527,7 @@ export class GirClass extends GirBaseClass { ); } - findParent(predicate: (p: GirClass | GirInterface) => boolean): GirClass | GirInterface | undefined { + findParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): IntrospectedClass | GirInterface | undefined { const resolution = this.resolveParents(); const parent = resolution.extends(); @@ -544,7 +544,7 @@ export class GirClass extends GirBaseClass { return interfaces.find(n => predicate(n)) || interfaces.find(n => n.findParent(predicate)); } - findParentMap(predicate: (p: GirClass | GirInterface) => K | undefined): K | undefined { + findParentMap(predicate: (p: IntrospectedClass | GirInterface) => K | undefined): K | undefined { const resolution = this.resolveParents(); const parent = resolution.extends(); @@ -567,7 +567,7 @@ export class GirClass extends GirBaseClass { return findMap(interfaces, i => i.findParentMap(predicate)); } - implementedProperties(potentialConflicts: GirBase[] = []) { + implementedProperties(potentialConflicts: IntrospectedBase[] = []) { const resolution = this.resolveParents(); const implemented_on_parent = [...(resolution.extends() ?? [])] .map(r => r.implements()) @@ -581,7 +581,7 @@ export class GirClass extends GirBaseClass { potentialConflicts.every(p => prop.name !== p.name); for (const implemented of resolution.implements()) { - if (implemented.node instanceof GirClass) continue; + if (implemented.node instanceof IntrospectedClass) continue; if (implemented_on_parent.some(p => p.equals(implemented.identifier))) continue; @@ -595,7 +595,7 @@ export class GirClass extends GirBaseClass { for (const implemented of resolution.implements()) { [...implemented].forEach(e => { - if (e.node instanceof GirClass) return; + if (e.node instanceof IntrospectedClass) return; if (implemented_on_parent.some(p => p.equals(e.identifier))) return; @@ -612,19 +612,19 @@ export class GirClass extends GirBaseClass { return [...properties.values()]; } - implementedMethods(potentialConflicts: GirBase[] = []) { + implementedMethods(potentialConflicts: IntrospectedBase[] = []) { const resolution = this.resolveParents(); const implemented_on_parent = [...(resolution.extends() ?? [])].map(r => r.implements()).flat(); - const methods = new Map(); + const methods = new Map(); - const validateMethod = (method: GirClassFunction) => - !(method instanceof GirStaticClassFunction) && + const validateMethod = (method: IntrospectedClassFunction) => + !(method instanceof IntrospectedStaticClassFunction) && !this.hasInstanceSymbol(method) && !methods.has(method.name) && potentialConflicts.every(m => method.name !== m.name); for (const implemented of resolution.implements()) { - if (implemented.node instanceof GirClass) continue; + if (implemented.node instanceof IntrospectedClass) continue; if ( implemented_on_parent.find(p => p.identifier.equals(implemented.identifier))?.node?.generics @@ -639,7 +639,7 @@ export class GirClass extends GirBaseClass { for (const implemented of resolution.implements()) { [...implemented].forEach(e => { - if (e.node instanceof GirClass) return; + if (e.node instanceof IntrospectedClass) return; if (implemented_on_parent.find(p => p.identifier.equals(e.identifier))?.node.generics.length === 0) return; @@ -653,7 +653,7 @@ export class GirClass extends GirBaseClass { return [...methods.values()].map(f => { const mapping = new Map(); - if (f.parent instanceof GirBaseClass) { + if (f.parent instanceof IntrospectedBaseClass) { const inter = this.interfaces.find(i => i.equals(f.parent.getType())); if (inter instanceof GenerifiedTypeIdentifier) { @@ -734,7 +734,7 @@ export class GirClass extends GirBaseClass { extends() { let parentType = parent; let resolved_parent = parentType && resolveTypeIdentifier(namespace, parentType); - if (resolved_parent instanceof GirClass) return resolved_parent.resolveParents(); + if (resolved_parent instanceof IntrospectedClass) return resolved_parent.resolveParents(); return undefined; }, node: this, @@ -745,14 +745,14 @@ export class GirClass extends GirBaseClass { copy( options: { parent?: undefined; - signals?: GirSignal[]; - constructors?: GirConstructor[]; - members?: GirClassFunction[]; + signals?: IntrospectedSignal[]; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; props?: GirProperty[]; - fields?: GirField[]; - callbacks?: GirCallback[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; } = {} - ): GirClass { + ): IntrospectedClass { const { name, namespace, @@ -770,7 +770,7 @@ export class GirClass extends GirBaseClass { _staticDefinition } = this; - const clazz = new GirClass(name, namespace); + const clazz = new IntrospectedClass(name, namespace); clazz._copyBaseProperties(this); @@ -802,18 +802,18 @@ export class GirClass extends GirBaseClass { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, _parent, - klass: ClassElement - ): GirClass { + klass: GirClassElement + ): IntrospectedClass { const name = sanitizeIdentifierName(ns.name, klass.$.name); if (options.verbose) { console.debug(` >> GirClass: Parsing definition ${klass.$.name} (${name})...`); } - const clazz = new GirClass(name, ns); + const clazz = new IntrospectedClass(name, ns); if (options.loadDocs) { clazz.doc = parseDoc(klass); @@ -860,14 +860,14 @@ export class GirClass extends GirBaseClass { if (Array.isArray(klass.constructor)) { clazz.constructors.push( ...klass.constructor.map(constructor => - GirConstructor.fromXML(modName, ns, options, clazz, constructor) + IntrospectedConstructor.fromXML(modName, ns, options, clazz, constructor) ) ); } if (klass["glib:signal"]) { clazz.signals.push( - ...klass["glib:signal"].map(signal => GirSignal.fromXML(modName, ns, options, clazz, signal)) + ...klass["glib:signal"].map(signal => IntrospectedSignal.fromXML(modName, ns, options, clazz, signal)) ); } @@ -900,7 +900,7 @@ export class GirClass extends GirBaseClass { // Instance Methods if (klass.method) { clazz.members.push( - ...klass.method.map(method => GirClassFunction.fromXML(modName, ns, options, clazz, method)) + ...klass.method.map(method => IntrospectedClassFunction.fromXML(modName, ns, options, clazz, method)) ); } @@ -909,7 +909,7 @@ export class GirClass extends GirBaseClass { klass.field .filter(field => !("callback" in field)) .forEach(field => { - const f = GirField.fromXML(modName, ns, options, null, field); + const f = Field.fromXML(modName, ns, options, null, field); clazz.fields.push(f); }); @@ -940,7 +940,7 @@ export class GirClass extends GirBaseClass { console.debug(`Adding callback ${callback.$.name} for ${modName}`); } - return GirCallback.fromXML(modName, ns, options, clazz, callback); + return IntrospectedCallback.fromXML(modName, ns, options, clazz, callback); }) ); } @@ -949,7 +949,7 @@ export class GirClass extends GirBaseClass { if (klass["virtual-method"]) { clazz.members.push( ...klass["virtual-method"].map(method => - GirVirtualClassFunction.fromXML(modName, ns, options, clazz, method) + IntrospectedVirtualClassFunction.fromXML(modName, ns, options, clazz, method) ) ); } @@ -957,7 +957,7 @@ export class GirClass extends GirBaseClass { // Static methods (functions) if (klass.function) { clazz.members.push( - ...klass.function.map(func => GirStaticClassFunction.fromXML(modName, ns, options, clazz, func)) + ...klass.function.map(func => IntrospectedStaticClassFunction.fromXML(modName, ns, options, clazz, func)) ); } } catch (e) { @@ -976,7 +976,7 @@ export class GirClass extends GirBaseClass { } } -export class GirRecord extends GirBaseClass { +export class GirRecord extends IntrospectedBaseClass { private _isForeign: boolean = false; private _structFor: TypeIdentifier | null = null; private _isSimple: boolean | null = null; @@ -1072,11 +1072,11 @@ export class GirRecord extends GirBaseClass { copy( options: { parent?: undefined; - constructors?: GirConstructor[]; - members?: GirClassFunction[]; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; props?: GirProperty[]; - fields?: GirField[]; - callbacks?: GirCallback[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; } = {} ): GirRecord { const { @@ -1115,7 +1115,7 @@ export class GirRecord extends GirBaseClass { return clazz; } - static foreign(name: string, namespace: GirNamespace): GirRecord { + static foreign(name: string, namespace: IntrospectedNamespace): GirRecord { const foreignRecord = new GirRecord({ name, namespace }); foreignRecord._isForeign = true; return foreignRecord; @@ -1123,9 +1123,9 @@ export class GirRecord extends GirBaseClass { static fromXML( modName: string, - namespace: GirNamespace, + namespace: IntrospectedNamespace, options: LoadOptions, - klass: RecordElement | UnionElement + klass: GirRecordElement | GirUnionElement ): GirRecord { if (!klass.$.name) { throw new Error(`Invalid GIR File: No name provided for union.`); @@ -1180,14 +1180,14 @@ export class GirRecord extends GirBaseClass { // Instance Methods if (klass.method) { clazz.members.push( - ...klass.method.map(method => GirClassFunction.fromXML(modName, namespace, options, clazz, method)) + ...klass.method.map(method => IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method)) ); } // Constructors if (Array.isArray(klass.constructor)) { klass.constructor.forEach(constructor => { - const c = GirConstructor.fromXML(modName, namespace, options, clazz, constructor); + const c = IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor); clazz.constructors.push(c); }); @@ -1197,7 +1197,7 @@ export class GirRecord extends GirBaseClass { if (klass.function) { clazz.members.push( ...klass.function.map(func => - GirStaticClassFunction.fromXML(modName, namespace, options, clazz, func) + IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func) ) ); } @@ -1211,7 +1211,7 @@ export class GirRecord extends GirBaseClass { clazz.fields.push( ...klass.field .filter(field => !("callback" in field)) - .map(field => GirField.fromXML(modName, namespace, options, null, field)) + .map(field => Field.fromXML(modName, namespace, options, null, field)) ); } } catch (e) { @@ -1370,19 +1370,19 @@ export class GirComplexRecord extends GirRecord { } } -export class GirInterface extends GirBaseClass { +export class GirInterface extends IntrospectedBaseClass { noParent = false; - mainConstructor: null | GirConstructor = null; + mainConstructor: null | IntrospectedConstructor = null; copy( options: { parent?: undefined; noParent?: boolean; - constructors?: GirConstructor[]; - members?: GirClassFunction[]; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; props?: GirProperty[]; - fields?: GirField[]; - callbacks?: GirCallback[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; } = {} ): GirInterface { const { @@ -1420,14 +1420,14 @@ export class GirInterface extends GirBaseClass { return clazz; } - someParent(predicate: (p: GirClass | GirInterface) => boolean): boolean { + someParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): boolean { const resolution = this.resolveParents(); const parent = resolution.extends(); return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); } - findParent(predicate: (p: GirClass | GirInterface) => boolean): GirInterface | GirClass | undefined { + findParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): GirInterface | IntrospectedClass | undefined { const resolution = this.resolveParents(); const parent = resolution.extends(); @@ -1443,7 +1443,7 @@ export class GirInterface extends GirBaseClass { return undefined; } - findParentMap(predicate: (p: GirClass | GirInterface) => K | undefined): K | undefined { + findParentMap(predicate: (p: IntrospectedClass | GirInterface) => K | undefined): K | undefined { const resolution = this.resolveParents(); const parent = resolution.extends(); @@ -1473,7 +1473,7 @@ export class GirInterface extends GirBaseClass { extends() { if (!parent) return undefined; const resolved = resolveTypeIdentifier(namespace, parent); - if (resolved && (resolved instanceof GirClass || resolved instanceof GirInterface)) + if (resolved && (resolved instanceof IntrospectedClass || resolved instanceof GirInterface)) return resolved.resolveParents(); return undefined; }, @@ -1496,9 +1496,9 @@ export class GirInterface extends GirBaseClass { static fromXML( modName: string, - namespace: GirNamespace, + namespace: IntrospectedNamespace, options: LoadOptions, - klass: InterfaceElement + klass: GirInterfaceElement ): GirInterface { const name = sanitizeIdentifierName(namespace.name, klass.$.name); @@ -1541,7 +1541,7 @@ export class GirInterface extends GirBaseClass { if (Array.isArray(klass.constructor)) { for (let constructor of klass.constructor) { - clazz.constructors.push(GirConstructor.fromXML(modName, namespace, options, clazz, constructor)); + clazz.constructors.push(IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor)); } } @@ -1575,7 +1575,7 @@ export class GirInterface extends GirBaseClass { // Instance Methods if (klass.method) { for (let method of klass.method) { - const m = GirClassFunction.fromXML(modName, namespace, options, clazz, method); + const m = IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method); clazz.members.push(m); } @@ -1584,7 +1584,7 @@ export class GirInterface extends GirBaseClass { // Virtual Methods if (klass["virtual-method"]) { for (let method of klass["virtual-method"]) { - clazz.members.push(GirVirtualClassFunction.fromXML(modName, namespace, options, clazz, method)); + clazz.members.push(IntrospectedVirtualClassFunction.fromXML(modName, namespace, options, clazz, method)); } } @@ -1595,14 +1595,14 @@ export class GirInterface extends GirBaseClass { console.debug(`Adding callback ${callback.$.name} for ${modName}`); } - clazz.callbacks.push(GirCallback.fromXML(modName, namespace, options, clazz, callback)); + clazz.callbacks.push(IntrospectedCallback.fromXML(modName, namespace, options, clazz, callback)); } } // Static methods (functions) if (klass.function) { for (let func of klass.function) { - clazz.members.push(GirStaticClassFunction.fromXML(modName, namespace, options, clazz, func)); + clazz.members.push(IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func)); } } } catch (e) { diff --git a/packages/lib/src/newlib/gir/const.ts b/packages/lib/src/newlib/gir/const.ts index bf4c55735..3143da872 100644 --- a/packages/lib/src/newlib/gir/const.ts +++ b/packages/lib/src/newlib/gir/const.ts @@ -1,14 +1,14 @@ import { TypeExpression } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; -import { ConstantElement } from "@gi.ts/parser"; +import {IntrospectedBase} from './base.js'; +import { GirConstantElement } from "../../index.js"; -import { GirNamespace } from "./namespace.js"; +import { IntrospectedNamespace } from "./namespace.js"; import { getType, parseDoc, parseMetadata, sanitizeIdentifierName } from "./util.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export class GirConst extends GirBase { +export class IntrospectedConstant extends IntrospectedBase { type: TypeExpression; value: string | null; @@ -28,7 +28,7 @@ export class GirConst extends GirBase { this.value = value; } - accept(visitor: GirVisitor): GirConst { + accept(visitor: GirVisitor): IntrospectedConstant { const node = this.copy({ type: visitor.visitType?.(this.type) }); @@ -41,10 +41,10 @@ export class GirConst extends GirBase { parent?: undefined; type?: TypeExpression; } = {} - ): GirConst { + ): IntrospectedConstant { const { type, name, value } = this; - return new GirConst({ + return new IntrospectedConstant({ name, type: options.type ?? type, value @@ -53,12 +53,12 @@ export class GirConst extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, _parent, - constant: ConstantElement - ): GirConst { - const c = new GirConst({ + constant: GirConstantElement + ): IntrospectedConstant { + const c = new IntrospectedConstant({ name: sanitizeIdentifierName(ns.name, constant.$.name), type: getType(modName, ns, constant), value: constant.$.value ?? null diff --git a/packages/lib/src/newlib/gir/enum.ts b/packages/lib/src/newlib/gir/enum.ts index 129a8154e..e61e7b1f2 100644 --- a/packages/lib/src/newlib/gir/enum.ts +++ b/packages/lib/src/newlib/gir/enum.ts @@ -1,24 +1,24 @@ import { NumberType, TypeIdentifier } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; -import { MemberElement, EnumElement, BitfieldElement } from "@gi.ts/parser"; +import { IntrospectedBase } from './base.js'; +import { GirMemberElement, GirEnumElement, GirBitfieldElement } from "../../index.js"; import { GirComplexRecord, GirRecord } from "./class.js"; -import { GirField } from "./property.js"; -import { GirStaticClassFunction } from "./function.js"; -import { GirNamespace } from "./namespace.js"; +import { Field } from "./property.js"; +import { IntrospectedStaticClassFunction } from "./function.js"; +import { IntrospectedNamespace } from "./namespace.js"; import { parseDoc, parseMetadata, sanitizeIdentifierName, sanitizeMemberName } from "./util.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export class GirEnum extends GirBase { +export class IntrospectedEnum extends IntrospectedBase { members = new Map(); flags: boolean = false; - namespace: GirNamespace; + namespace: IntrospectedNamespace; ns: string; - constructor(name: string, namespace: GirNamespace, options: { isIntrospectable?: boolean } = {}) { + constructor(name: string, namespace: IntrospectedNamespace, options: { isIntrospectable?: boolean } = {}) { super(sanitizeIdentifierName(namespace.name, name)); this.namespace = namespace; this.ns = namespace.name; @@ -29,10 +29,10 @@ export class GirEnum extends GirBase { }: { parent?: undefined; members?: Map; - } = {}): GirEnum { + } = {}): IntrospectedEnum { const { namespace, name, flags } = this; - const en = new GirEnum(name, namespace); + const en = new IntrospectedEnum(name, namespace); for (const [key, member] of (members ?? this.members).entries()) { en.members.set(key, member.copy()); @@ -45,7 +45,7 @@ export class GirEnum extends GirBase { return en; } - accept(visitor: GirVisitor): GirEnum { + accept(visitor: GirVisitor): IntrospectedEnum { const node = this.copy({ members: new Map( Array.from(this.members.entries()).map(([name, m]) => { @@ -72,7 +72,7 @@ export class GirEnum extends GirBase { clazz.fields.push( ...Array.from(this.members.values()).map(m => { - const field = new GirField({ + const field = new Field({ name: m.name, type: NumberType, writable: true, @@ -92,13 +92,13 @@ export class GirEnum extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, _parent, - m: EnumElement | BitfieldElement, + m: GirEnumElement | GirBitfieldElement, flags = false - ): GirEnum { - const em = new GirEnum(sanitizeMemberName(m.$.name), ns); + ): IntrospectedEnum { + const em = new IntrospectedEnum(sanitizeMemberName(m.$.name), ns); if (m.$["glib:type-name"]) { em.resolve_names.push(m.$["glib:type-name"]); @@ -133,7 +133,7 @@ export class GirEnum extends GirBase { } } -export class GirEnumMember extends GirBase { +export class GirEnumMember extends IntrospectedBase { value: string; c_identifier: string; @@ -156,10 +156,10 @@ export class GirEnumMember extends GirBase { static fromXML( _: string, - _ns: GirNamespace, + _ns: IntrospectedNamespace, options: LoadOptions, _parent, - m: MemberElement + m: GirMemberElement ): GirEnumMember { const upper = m.$.name.toUpperCase(); const c_identifier = m.$["c:identifier"]; @@ -179,12 +179,12 @@ export class GirEnumMember extends GirBase { } } -function isEnumElement(e: unknown): e is EnumElement { +function isEnumElement(e: unknown): e is GirEnumElement { return typeof e === "object" && e != null && "function" in e; } -export class GirError extends GirEnum { - functions: Map = new Map(); +export class IntrospectedError extends IntrospectedEnum { + functions: Map = new Map(); asString>(generator: T): ReturnType { return generator.generateError(this); @@ -195,10 +195,10 @@ export class GirError extends GirEnum { }: { parent?: undefined; members?: Map; - } = {}): GirEnum { + } = {}): IntrospectedEnum { const { namespace, name, flags } = this; - const en = new GirError(name, namespace); + const en = new IntrospectedError(name, namespace); for (const [key, member] of (members ?? this.members).entries()) { en.members.set(key, member.copy()); @@ -215,12 +215,12 @@ export class GirError extends GirEnum { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, parent, - m: EnumElement | BitfieldElement - ): GirEnum { - const err = new GirError(sanitizeMemberName(m.$.name), ns); + m: GirEnumElement | GirBitfieldElement + ): IntrospectedEnum { + const err = new IntrospectedError(sanitizeMemberName(m.$.name), ns); if (m.$["glib:type-name"]) { err.resolve_names.push(m.$["glib:type-name"]); @@ -248,7 +248,7 @@ export class GirError extends GirEnum { if (isEnumElement(m) && m.function) { m.function.forEach(f => { - const func = GirStaticClassFunction.fromXML(modName, ns, options, err, f); + const func = IntrospectedStaticClassFunction.fromXML(modName, ns, options, err, f); err.functions.set(func.name, func); }); } diff --git a/packages/lib/src/newlib/gir/function.ts b/packages/lib/src/newlib/gir/function.ts index 64f8256a5..1388553c1 100644 --- a/packages/lib/src/newlib/gir/function.ts +++ b/packages/lib/src/newlib/gir/function.ts @@ -12,18 +12,18 @@ import { } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; +import {IntrospectedBase, Options} from './base.js'; import { - FunctionElement, - MethodElement, - Direction, - CallableParamElement, - CallbackElement, - VirtualMethodElement, - ConstructorElement -} from "@gi.ts/parser"; - -import { GirNamespace, isIntrospectable } from "./namespace.js"; + GirFunctionElement, + GirMethodElement, + GirDirection, + GirCallableParamElement, + GirCallbackElement, + GirVirtualMethodElement, + GirConstructorElement +} from "../../index.js"; + +import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { getType, isInvalid, @@ -32,23 +32,23 @@ import { parseDoc, parseMetadata } from "./util.js"; -import { GirBaseClass, GirClass } from "./class.js"; -import { GirEnum } from "./enum.js"; -import { GirSignal } from "./signal.js"; +import { IntrospectedBaseClass, IntrospectedClass } from "./class.js"; +import { IntrospectedEnum } from "./enum.js"; +import { IntrospectedSignal } from "./signal.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -import { GirField } from "./property.js"; +import { Field } from "./property.js"; function hasShadow( - obj: FunctionElement | MethodElement -): obj is FunctionElement & { $: { shadows: string } } { + obj: GirFunctionElement | GirMethodElement +): obj is GirFunctionElement & { $: { shadows: string } } { return obj.$["shadows"] != null; } -export class GirFunction extends GirBase { - readonly parameters: GirFunctionParameter[]; - readonly output_parameters: GirFunctionParameter[]; +export class IntrospectedFunction extends IntrospectedBase { + readonly parameters: IntrospectedFunctionParameter[]; + readonly output_parameters: IntrospectedFunctionParameter[]; readonly return_type: TypeExpression; readonly raw_name: string; @@ -61,12 +61,12 @@ export class GirFunction extends GirBase { parameters = [], output_parameters = [], ...args - }: GirOptions<{ + }: Options<{ name: string; raw_name: string; return_type?: TypeExpression; - parameters?: GirFunctionParameter[]; - output_parameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; + output_parameters?: IntrospectedFunctionParameter[]; }>) { super(name, { ...args }); @@ -82,11 +82,11 @@ export class GirFunction extends GirBase { return_type }: { parent?: undefined; - parameters?: GirFunctionParameter[]; - outputParameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; - } = {}): GirFunction { - const fn = new GirFunction({ + } = {}): IntrospectedFunction { + const fn = new IntrospectedFunction({ raw_name: this.raw_name, name: this.name, return_type: return_type ?? this.return_type, @@ -99,7 +99,7 @@ export class GirFunction extends GirBase { return fn._copyBaseProperties(this); } - accept(visitor: GirVisitor): GirFunction { + accept(visitor: GirVisitor): IntrospectedFunction { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -115,11 +115,11 @@ export class GirFunction extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, _parent, - func: FunctionElement | MethodElement - ): GirFunction { + func: GirFunctionElement | GirMethodElement + ): IntrospectedFunction { let raw_name = func.$.name; let name = sanitizeIdentifierName(null, raw_name); @@ -138,7 +138,7 @@ export class GirFunction extends GirBase { return_type = VoidType; } - let parameters: GirFunctionParameter[] = []; + let parameters: IntrospectedFunctionParameter[] = []; if (func.parameters) { const param = func.parameters[0].parameter; @@ -148,7 +148,7 @@ export class GirFunction extends GirBase { return !!p.$.name; }); - parameters.push(...inputs.map(i => GirFunctionParameter.fromXML(modName, ns, options, null, i))); + parameters.push(...inputs.map(i => IntrospectedFunctionParameter.fromXML(modName, ns, options, null, i))); const unwrapped = return_type.unwrap(); @@ -205,24 +205,24 @@ export class GirFunction extends GirBase { }, { allowOptions: true, - params: [] as GirFunctionParameter[] + params: [] as IntrospectedFunctionParameter[] } ) .params.reverse() - .filter((p): p is GirFunctionParameter => p != null); + .filter((p): p is IntrospectedFunctionParameter => p != null); } } let input_parameters = parameters.filter( - param => param.direction === Direction.In || param.direction === Direction.Inout + param => param.direction === GirDirection.In || param.direction === GirDirection.Inout ); let output_parameters = parameters .filter( - param => param.direction && (param.direction === Direction.Out || param.direction === Direction.Inout) + param => param.direction && (param.direction === GirDirection.Out || param.direction === GirDirection.Inout) ) .map(parameter => parameter.copy({ isOptional: false })); - const fn = new GirFunction({ + const fn = new IntrospectedFunction({ parameters: input_parameters, output_parameters, return_type, @@ -243,10 +243,10 @@ export class GirFunction extends GirBase { return this.return_type; } - asCallback(): GirCallback { + asCallback(): IntrospectedCallback { const { raw_name, name, output_parameters, parameters, return_type } = this; - return new GirCallback({ + return new IntrospectedCallback({ raw_name, name, output_parameters, @@ -255,10 +255,10 @@ export class GirFunction extends GirBase { }); } - asClassFunction(parent: GirBaseClass | GirEnum): GirClassFunction { + asClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedClassFunction { const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - return new GirClassFunction({ + return new IntrospectedClassFunction({ parent, name, output_parameters, @@ -269,10 +269,10 @@ export class GirFunction extends GirBase { }); } - asVirtualClassFunction(parent: GirBaseClass): GirVirtualClassFunction { + asVirtualClassFunction(parent: IntrospectedBaseClass): IntrospectedVirtualClassFunction { const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - return new GirVirtualClassFunction({ + return new IntrospectedVirtualClassFunction({ parent, name, output_parameters, @@ -283,10 +283,10 @@ export class GirFunction extends GirBase { }); } - asStaticClassFunction(parent: GirBaseClass | GirEnum): GirStaticClassFunction { + asStaticClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedStaticClassFunction { const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - return new GirStaticClassFunction({ + return new IntrospectedStaticClassFunction({ parent, name, output_parameters, @@ -302,10 +302,10 @@ export class GirFunction extends GirBase { } } -export class GirDirectAllocationConstructor extends GirBase { - fields: GirField[]; +export class IntrospectedDirectAllocationConstructor extends IntrospectedBase { + fields: Field[]; - constructor(fields: GirField[]) { + constructor(fields: Field[]) { super("new", { isPrivate: false, isIntrospectable: true }); this.fields = fields @@ -322,16 +322,16 @@ export class GirDirectAllocationConstructor extends GirBase { } copy( - options?: { parent?: GirBase | undefined; fields: GirField[] } | undefined - ): GirDirectAllocationConstructor { - const copy = new GirDirectAllocationConstructor(options?.fields ?? this.fields); + options?: { parent?: IntrospectedBase | undefined; fields: Field[] } | undefined + ): IntrospectedDirectAllocationConstructor { + const copy = new IntrospectedDirectAllocationConstructor(options?.fields ?? this.fields); copy._copyBaseProperties(this); return copy; } - accept(visitor: GirVisitor): GirDirectAllocationConstructor { + accept(visitor: GirVisitor): IntrospectedDirectAllocationConstructor { const node = this.copy({ fields: this.fields.map(field => { return field.accept(visitor); @@ -342,8 +342,8 @@ export class GirDirectAllocationConstructor extends GirBase { } } -export class GirConstructor extends GirBase { - readonly parameters: GirFunctionParameter[] = []; +export class IntrospectedConstructor extends IntrospectedBase { + readonly parameters: IntrospectedFunctionParameter[] = []; readonly return_type: TypeExpression = UnknownType; constructor({ @@ -351,9 +351,9 @@ export class GirConstructor extends GirBase { parameters = [], return_type, ...args - }: GirOptions<{ + }: Options<{ name: string; - parameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; return_type: TypeExpression; }>) { super(name, { ...args }); @@ -366,10 +366,10 @@ export class GirConstructor extends GirBase { return_type }: { parent?: undefined; - parameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; - } = {}): GirConstructor { - return new GirConstructor({ + } = {}): IntrospectedConstructor { + return new IntrospectedConstructor({ name: this.name, return_type: return_type ?? this.return_type, parameters: parameters ?? this.parameters @@ -378,15 +378,15 @@ export class GirConstructor extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirBaseClass, - m: ConstructorElement - ): GirConstructor { - return GirClassFunction.fromXML(modName, ns, options, parent, m as FunctionElement).asConstructor(); + parent: IntrospectedBaseClass, + m: GirConstructorElement + ): IntrospectedConstructor { + return IntrospectedClassFunction.fromXML(modName, ns, options, parent, m as GirFunctionElement).asConstructor(); } - accept(visitor: GirVisitor): GirConstructor { + accept(visitor: GirVisitor): IntrospectedConstructor { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -406,13 +406,13 @@ export class GirConstructor extends GirBase { } } -export class GirFunctionParameter extends GirBase { +export class IntrospectedFunctionParameter extends IntrospectedBase { readonly type: TypeExpression; - readonly direction: Direction; + readonly direction: GirDirection; readonly isVarArgs: boolean = false; readonly isOptional: boolean = false; readonly isNullable: boolean = false; - readonly parent?: GirClassFunction | GirFunction | GirSignal | GirConstructor; + readonly parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; constructor({ name, @@ -424,11 +424,11 @@ export class GirFunctionParameter extends GirBase { isOptional = false, isNullable = false, ...args - }: GirOptions<{ + }: Options<{ name: string; - parent?: GirClassFunction | GirFunction | GirSignal | GirConstructor; + parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; type: TypeExpression; - direction: Direction; + direction: GirDirection; doc?: string | null; isVarArgs?: boolean; isOptional?: boolean; @@ -447,17 +447,17 @@ export class GirFunctionParameter extends GirBase { copy( options: { - parent?: GirClassFunction | GirFunction | GirSignal | GirConstructor; + parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; type?: TypeExpression; isOptional?: boolean; isNullable?: boolean; } = { parent: this.parent } - ): GirFunctionParameter { + ): IntrospectedFunctionParameter { const { type, parent, direction, isVarArgs, isOptional, isNullable, name, doc } = this; - return new GirFunctionParameter({ + return new IntrospectedFunctionParameter({ parent: options.parent ?? parent, name, direction, @@ -469,7 +469,7 @@ export class GirFunctionParameter extends GirBase { })._copyBaseProperties(this); } - accept(visitor: GirVisitor): GirFunctionParameter { + accept(visitor: GirVisitor): IntrospectedFunctionParameter { const node = this.copy({ type: visitor.visitType?.(this.type) }); @@ -483,11 +483,11 @@ export class GirFunctionParameter extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirSignal | GirClassFunction | GirFunction | GirConstructor | null, - parameter: CallableParamElement & { $: { name: string } } - ): GirFunctionParameter { + parent: IntrospectedSignal | IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor | null, + parameter: GirCallableParamElement & { $: { name: string } } + ): IntrospectedFunctionParameter { let name = sanitizeMemberName(parameter.$.name); if (isInvalid(name)) { @@ -499,12 +499,12 @@ export class GirFunctionParameter extends GirBase { let isNullable = false; let type: TypeExpression; - let direction: Direction; + let direction: GirDirection; if ( !parameter.$.direction || - parameter.$.direction === Direction.In || - parameter.$.direction === Direction.Inout + parameter.$.direction === GirDirection.In || + parameter.$.direction === GirDirection.Inout ) { if (name === "...") { isVarArgs = true; @@ -512,7 +512,7 @@ export class GirFunctionParameter extends GirBase { } // Default to "in" direction - direction = parameter.$.direction || Direction.In; + direction = parameter.$.direction || GirDirection.In; const optional = parameter.$.optional === "1"; const nullable = parameter.$.nullable === "1"; @@ -526,14 +526,14 @@ export class GirFunctionParameter extends GirBase { } type = getType(modName, ns, parameter); - } else if (parameter.$.direction === Direction.Out || parameter.$.direction === Direction.Inout) { + } else if (parameter.$.direction === GirDirection.Out || parameter.$.direction === GirDirection.Inout) { direction = parameter.$.direction; type = getType(modName, ns, parameter); } else { throw new Error(`Unknown parameter direction: ${parameter.$.direction}`); } - const fp = new GirFunctionParameter({ + const fp = new IntrospectedFunctionParameter({ isVarArgs, type: isVarArgs ? new ArrayType(type) : type, direction, @@ -553,14 +553,14 @@ export class GirFunctionParameter extends GirBase { } } -export class GirClassFunction extends GirBase { - readonly parameters: GirFunctionParameter[]; +export class IntrospectedClassFunction extends IntrospectedBase { + readonly parameters: IntrospectedFunctionParameter[]; protected readonly return_type: TypeExpression; - readonly output_parameters: GirFunctionParameter[]; + readonly output_parameters: IntrospectedFunctionParameter[]; protected _anyify: boolean = false; protected _generify: boolean = false; - parent: GirBaseClass | GirEnum; - interfaceParent: GirBaseClass | GirEnum | null = null; + parent: IntrospectedBaseClass | IntrospectedEnum; + interfaceParent: IntrospectedBaseClass | IntrospectedEnum | null = null; generics: Generic[] = []; @@ -572,12 +572,12 @@ export class GirClassFunction extends GirBase { parent, doc, ...args - }: GirOptions<{ + }: Options<{ name: string; - parameters?: GirFunctionParameter[]; - output_parameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; + output_parameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; - parent: GirBaseClass | GirEnum; + parent: IntrospectedBaseClass | IntrospectedEnum; doc?: string | null; }>) { super(name, { ...args }); @@ -589,12 +589,12 @@ export class GirClassFunction extends GirBase { this.doc = doc; } - asConstructor(): GirConstructor { + asConstructor(): IntrospectedConstructor { const { name, parameters } = this; - if (this.parent instanceof GirBaseClass) { + if (this.parent instanceof IntrospectedBaseClass) { // Always force constructors to have the correct return type. - return new GirConstructor({ + return new IntrospectedConstructor({ name, parameters, return_type: this.parent.getType(), @@ -607,10 +607,10 @@ export class GirClassFunction extends GirBase { ); } - asStaticClassFunction(parent: GirClass): any { + asStaticClassFunction(parent: IntrospectedClass): any { const { name, parameters, return_type, output_parameters } = this; - return new GirStaticClassFunction({ + return new IntrospectedStaticClassFunction({ name, parameters, output_parameters, @@ -627,18 +627,18 @@ export class GirClassFunction extends GirBase { outputParameters, returnType }: { - parent?: GirBaseClass | GirEnum; - interfaceParent?: GirBaseClass | GirEnum; - parameters?: GirFunctionParameter[]; - outputParameters?: GirFunctionParameter[]; + parent?: IntrospectedBaseClass | IntrospectedEnum; + interfaceParent?: IntrospectedBaseClass | IntrospectedEnum; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; returnType?: TypeExpression; - } = {}): GirClassFunction { - let constr = GirClassFunction; + } = {}): IntrospectedClassFunction { + let constr = IntrospectedClassFunction; - if (this instanceof GirVirtualClassFunction) { - constr = GirVirtualClassFunction; - } else if (this instanceof GirStaticClassFunction) { - constr = GirStaticClassFunction; + if (this instanceof IntrospectedVirtualClassFunction) { + constr = IntrospectedVirtualClassFunction; + } else if (this instanceof IntrospectedStaticClassFunction) { + constr = IntrospectedStaticClassFunction; } const fn = new constr({ @@ -658,7 +658,7 @@ export class GirClassFunction extends GirBase { return fn._copyBaseProperties(this); } - accept(visitor: GirVisitor): GirClassFunction { + accept(visitor: GirVisitor): IntrospectedClassFunction { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -686,12 +686,12 @@ export class GirClassFunction extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirBaseClass | GirEnum, - m: FunctionElement | MethodElement - ): GirClassFunction { - const fn = GirFunction.fromXML(modName, ns, options, null, m); + parent: IntrospectedBaseClass | IntrospectedEnum, + m: GirFunctionElement | GirMethodElement + ): IntrospectedClassFunction { + const fn = IntrospectedFunction.fromXML(modName, ns, options, null, m); return fn.asClassFunction(parent); } @@ -705,7 +705,7 @@ export class GirClassFunction extends GirBase { } } -export class GirVirtualClassFunction extends GirClassFunction { +export class IntrospectedVirtualClassFunction extends IntrospectedClassFunction { constructor({ name, parameters = [], @@ -714,12 +714,12 @@ export class GirVirtualClassFunction extends GirClassFunction { parent, doc, ...args - }: GirOptions<{ + }: Options<{ name: string; - parameters: GirFunctionParameter[]; - output_parameters?: GirFunctionParameter[]; + parameters: IntrospectedFunctionParameter[]; + output_parameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; - parent: GirBaseClass; + parent: IntrospectedBaseClass; doc?: string | null; }>) { super({ @@ -737,7 +737,7 @@ export class GirVirtualClassFunction extends GirClassFunction { return this.return_type; } - accept(visitor: GirVisitor): GirVirtualClassFunction { + accept(visitor: GirVisitor): IntrospectedVirtualClassFunction { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -752,12 +752,12 @@ export class GirVirtualClassFunction extends GirClassFunction { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirBaseClass, - m: VirtualMethodElement - ): GirVirtualClassFunction { - const fn = GirFunction.fromXML(modName, ns, options, parent, m); + parent: IntrospectedBaseClass, + m: GirVirtualMethodElement + ): IntrospectedVirtualClassFunction { + const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); return fn.asVirtualClassFunction(parent); } @@ -767,12 +767,12 @@ export class GirVirtualClassFunction extends GirClassFunction { } } -export class GirStaticClassFunction extends GirClassFunction { +export class IntrospectedStaticClassFunction extends IntrospectedClassFunction { asString>(generator: T): ReturnType { return generator.generateStaticClassFunction(this); } - accept(visitor: GirVisitor): GirStaticClassFunction { + accept(visitor: GirVisitor): IntrospectedStaticClassFunction { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -788,18 +788,18 @@ export class GirStaticClassFunction extends GirClassFunction { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirBaseClass | GirEnum, - m: FunctionElement - ): GirStaticClassFunction { - const fn = GirFunction.fromXML(modName, ns, options, parent, m); + parent: IntrospectedBaseClass | IntrospectedEnum, + m: GirFunctionElement + ): IntrospectedStaticClassFunction { + const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); return fn.asStaticClassFunction(parent); } } -export class GirCallback extends GirFunction { +export class IntrospectedCallback extends IntrospectedFunction { asFunctionType(): FunctionType { return new FunctionType( Object.fromEntries(this.parameters.map(p => [p.name, p.type] as const)), @@ -813,11 +813,11 @@ export class GirCallback extends GirFunction { outputParameters }: { parent?: undefined; - parameters?: GirFunctionParameter[]; - outputParameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; returnType?: TypeExpression; - } = {}): GirCallback { - const cb = new GirCallback({ + } = {}): IntrospectedCallback { + const cb = new IntrospectedCallback({ name: this.name, raw_name: this.raw_name, return_type: returnType ?? this.return_type, @@ -830,7 +830,7 @@ export class GirCallback extends GirFunction { return cb; } - accept(visitor: GirVisitor): GirCallback { + accept(visitor: GirVisitor): IntrospectedCallback { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -846,12 +846,12 @@ export class GirCallback extends GirFunction { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, _parent, - func: CallbackElement - ): GirCallback { - const cb = GirFunction.fromXML(modName, ns, options, null, func).asCallback(); + func: GirCallbackElement + ): IntrospectedCallback { + const cb = IntrospectedFunction.fromXML(modName, ns, options, null, func).asCallback(); if (func.$["glib:type-name"]) { cb.resolve_names.push(func.$["glib:type-name"]); diff --git a/packages/lib/src/newlib/gir/namespace.ts b/packages/lib/src/newlib/gir/namespace.ts index 5341f05ff..2820d8fc4 100644 --- a/packages/lib/src/newlib/gir/namespace.ts +++ b/packages/lib/src/newlib/gir/namespace.ts @@ -11,31 +11,31 @@ import { ClosureType } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; -import { AliasElement, GirXML, InfoAttrs, Type } from "@gi.ts/parser"; +import {IntrospectedBase, Options, Metadata} from './base.js'; +import { GirAliasElement, ParsedGir, GirInfoAttrs, GirType } from "../../index.js"; import { isPrimitiveType } from "./util.js"; -import { GirClass, GirInterface, GirRecord, GirBaseClass } from "./class.js"; -import { GirFunction, GirCallback } from "./function.js"; -import { GirEnum, GirError } from "./enum.js"; -import { GirConst } from "./const.js"; -import { GirAlias } from "./alias.js"; +import { IntrospectedClass, GirInterface, GirRecord, IntrospectedBaseClass } from "./class.js"; +import { IntrospectedFunction, IntrospectedCallback } from "./function.js"; +import { IntrospectedEnum, IntrospectedError } from "./enum.js"; +import { IntrospectedConstant } from "./const.js"; +import { IntrospectedAlias } from "./alias.js"; import { LoadOptions } from "../types.js"; -import { GirNSRegistry } from "./registry.js"; +import { NSRegistry } from "./registry.js"; import { GirVisitor } from "../visitor.js"; -export type GirNSMember = GirBaseClass | GirFunction | GirConst | GirEnum | GirAlias; +export type GirNSMember = IntrospectedBaseClass | IntrospectedFunction | IntrospectedConstant | IntrospectedEnum | IntrospectedAlias; -export const isIntrospectable = (e: { $?: InfoAttrs }) => +export const isIntrospectable = (e: { $?: GirInfoAttrs }) => !e || !e.$ || !e.$.introspectable || e.$.introspectable === "1"; -export const isDeprecated = (e: { $: InfoAttrs }) => e && e.$ && e.$.deprecated === "1"; -export const deprecatedVersion = (e: { $: InfoAttrs }) => e?.$?.["deprecated-version"]; -export const introducedVersion = (e: { $: InfoAttrs }) => e?.$?.version; +export const isDeprecated = (e: { $: GirInfoAttrs }) => e && e.$ && e.$.deprecated === "1"; +export const deprecatedVersion = (e: { $: GirInfoAttrs }) => e?.$?.["deprecated-version"]; +export const introducedVersion = (e: { $: GirInfoAttrs }) => e?.$?.version; -export function promisifyNamespaceFunctions(namespace: GirNamespace) { +export function promisifyNamespaceFunctions(namespace: IntrospectedNamespace) { return namespace.members.forEach(node => { - if (!(node instanceof GirFunction)) return; + if (!(node instanceof IntrospectedFunction)) return; if (node.parameters.length < 1) return; @@ -51,7 +51,7 @@ export function promisifyNamespaceFunctions(namespace: GirNamespace) { if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { let async_res = [ - ...Array.from(namespace.members.values()).filter((m): m is GirFunction => m instanceof GirFunction) + ...Array.from(namespace.members.values()).filter((m): m is IntrospectedFunction => m instanceof IntrospectedFunction) ].find( m => m.name === `${node.name.replace(/_async$/, "")}_finish` || m.name === `${node.name}_finish` ); @@ -91,7 +91,7 @@ export function promisifyNamespaceFunctions(namespace: GirNamespace) { }); } -export class GirNamespace { +export class IntrospectedNamespace { readonly name: string; readonly version: string; readonly c_prefixes: string[]; @@ -105,7 +105,7 @@ export class GirNamespace { __dts__references?: string[]; package_version!: readonly [string, string] | readonly [string, string, string]; - parent!: GirNSRegistry; + parent!: NSRegistry; constructor(name: string, version: string, prefixes: string[]) { this.name = name; @@ -153,7 +153,7 @@ export class GirNamespace { } } - getImportsForCPrefix(c_prefix: string): GirNamespace[] { + getImportsForCPrefix(c_prefix: string): IntrospectedNamespace[] { return this.parent.namespacesForPrefix(c_prefix); } @@ -161,7 +161,7 @@ export class GirNamespace { return this.default_imports.has(name) || this.imports.has(name); } - private _getImport(name: string): GirNamespace | null { + private _getImport(name: string): IntrospectedNamespace | null { let version = this.default_imports.get(name) ?? this.imports.get(name); if (name === this.name) { @@ -195,7 +195,7 @@ export class GirNamespace { return namespace; } - getInstalledImport(name: string): GirNamespace | null { + getInstalledImport(name: string): IntrospectedNamespace | null { let version = this.default_imports.get(name) ?? this.imports.get(name); if (name === this.name) { @@ -221,7 +221,7 @@ export class GirNamespace { return namespace; } - assertInstalledImport(name: string): GirNamespace { + assertInstalledImport(name: string): IntrospectedNamespace { let namespace = this._getImport(name); if (!namespace) { @@ -240,7 +240,7 @@ export class GirNamespace { this._getImport(ns_name); } - getMembers(name: string): GirBase[] { + getMembers(name: string): IntrospectedBase[] { const members = this.members.get(name); if (Array.isArray(members)) { @@ -272,7 +272,7 @@ export class GirNamespace { return null; } - assertClass(name: string): GirBaseClass { + assertClass(name: string): IntrospectedBaseClass { const clazz = this.getClass(name); if (!clazz) { @@ -282,28 +282,28 @@ export class GirNamespace { return clazz; } - getClass(name: string): GirBaseClass | null { + getClass(name: string): IntrospectedBaseClass | null { const member = this.getMemberWithoutOverrides(name); - if (member instanceof GirBaseClass) { + if (member instanceof IntrospectedBaseClass) { return member; } return null; } - getEnum(name: string): GirEnum | null { + getEnum(name: string): IntrospectedEnum | null { const member = this.getMemberWithoutOverrides(name); - if (member instanceof GirEnum) { + if (member instanceof IntrospectedEnum) { return member; } return null; } - getAlias(name: string): GirAlias | null { + getAlias(name: string): IntrospectedAlias | null { const member = this.getMemberWithoutOverrides(name); - if (member instanceof GirAlias) { + if (member instanceof IntrospectedAlias) { return member; } return null; @@ -321,7 +321,7 @@ export class GirNamespace { } const member = this.members.get(resolvedName.name); - if (member instanceof GirBase) { + if (member instanceof IntrospectedBase) { return member.name; } @@ -330,14 +330,14 @@ export class GirNamespace { findClassCallback(name: string): [string | null, string] { const clazzes = Array.from(this.members.values()).filter( - (m): m is GirBaseClass => m instanceof GirBaseClass + (m): m is IntrospectedBaseClass => m instanceof IntrospectedBaseClass ); const res = clazzes - .map<[GirBaseClass, GirCallback | undefined]>(m => [ + .map<[IntrospectedBaseClass, IntrospectedCallback | undefined]>(m => [ m, m.callbacks.find(c => c.name === name || c.resolve_names.includes(name)) ]) - .find((r): r is [GirBaseClass, GirCallback] => r[1] != null); + .find((r): r is [IntrospectedBaseClass, IntrospectedCallback] => r[1] != null); if (res) { return [res[0].name, res[1].name]; @@ -356,8 +356,10 @@ export class GirNamespace { this.__dts__references.push(reference); } - static fromXML(repo: GirXML, options: LoadOptions, registry: GirNSRegistry): GirNamespace { - const ns = repo.repository[0].namespace[0]; + static fromXML(repo: ParsedGir, options: LoadOptions, registry: NSRegistry): IntrospectedNamespace { + const ns = repo.repository[0]?.namespace?.[0]; + + if (!ns) throw new Error(`Missing namespace in ${repo.repository[0].package[0].$.name}`) const modName = ns.$["name"]; let version = ns.$["version"]; @@ -381,7 +383,7 @@ export class GirNamespace { console.debug(`Parsing ${modName}...`); } - const building = new GirNamespace(modName, version, c_prefix); + const building = new IntrospectedNamespace(modName, version, c_prefix); building.parent = registry; // Set the namespace object here to prevent re-parsing the namespace if // another namespace imports it. @@ -401,7 +403,7 @@ export class GirNamespace { } }); - const importConflicts = (el: GirConst | GirBaseClass | GirFunction) => { + const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { return !building.hasImport(el.name); }; @@ -410,9 +412,9 @@ export class GirNamespace { ns.enumeration ?.map(enumeration => { if (enumeration.$["glib:error-domain"]) { - return GirError.fromXML(modName, building, options, null, enumeration); + return IntrospectedError.fromXML(modName, building, options, null, enumeration); } else { - return GirEnum.fromXML(modName, building, options, null, enumeration); + return IntrospectedEnum.fromXML(modName, building, options, null, enumeration); } }) .forEach(c => building.members.set(c.name, c)); @@ -422,7 +424,7 @@ export class GirNamespace { if (ns.constant) { ns.constant ?.filter(isIntrospectable) - .map(constant => GirConst.fromXML(modName, building, options, null, constant)) + .map(constant => IntrospectedConstant.fromXML(modName, building, options, null, constant)) .filter(importConflicts) .forEach(c => building.members.set(c.name, c)); } @@ -431,7 +433,7 @@ export class GirNamespace { if (ns.function) { ns.function ?.filter(isIntrospectable) - .map(func => GirFunction.fromXML(modName, building, options, null, func)) + .map(func => IntrospectedFunction.fromXML(modName, building, options, null, func)) .filter(importConflicts) .forEach(c => building.members.set(c.name, c)); } @@ -439,7 +441,7 @@ export class GirNamespace { if (ns.callback) { ns.callback ?.filter(isIntrospectable) - .map(callback => GirCallback.fromXML(modName, building, options, null, callback)) + .map(callback => IntrospectedCallback.fromXML(modName, building, options, null, callback)) .filter(importConflicts) .forEach(c => building.members.set(c.name, c)); } @@ -447,7 +449,7 @@ export class GirNamespace { if (ns["glib:boxed"]) { ns["glib:boxed"] ?.filter(isIntrospectable) - .map(boxed => new GirAlias({ name: boxed.$["glib:name"], type: new NullableType(ObjectType) })) + .map(boxed => new IntrospectedAlias({ name: boxed.$["glib:name"], type: new NullableType(ObjectType) })) .forEach(c => building.members.set(c.name, c)); } @@ -456,14 +458,14 @@ export class GirNamespace { if (ns.bitfield) { ns.bitfield ?.filter(isIntrospectable) - .map(field => GirEnum.fromXML(modName, building, options, building, field, true)) + .map(field => IntrospectedEnum.fromXML(modName, building, options, building, field, true)) .forEach(c => building.members.set(c.name, c)); } // The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y) // to the name of the enum (Button) to resolve references (Gtk.Button.Y) Array.from(building.members.values()) - .filter((m): m is GirEnum => m instanceof GirEnum) + .filter((m): m is IntrospectedEnum => m instanceof IntrospectedEnum) .forEach(m => { m.members.forEach(member => { building.enum_constants.set(member.c_identifier, [m.name, member.name] as const); @@ -474,7 +476,7 @@ export class GirNamespace { if (ns.class) { ns.class ?.filter(isIntrospectable) - .map(klass => GirClass.fromXML(modName, building, options, building, klass)) + .map(klass => IntrospectedClass.fromXML(modName, building, options, building, klass)) .filter(importConflicts) .forEach(c => building.members.set(c.name, c)); } @@ -503,7 +505,7 @@ export class GirNamespace { } if (ns.alias) { - type NamedType = Type & { $: { name: string } }; + type NamedType = GirType & { $: { name: string } }; ns.alias ?.filter(isIntrospectable) @@ -517,7 +519,7 @@ export class GirNamespace { !isPrimitiveType(t.$.name) && !t.$.name.includes(".") ) { - return { $: { name: "unknown", "c:type": "unknown" } } as Type; + return { $: { name: "unknown", "c:type": "unknown" } } as GirType; } return t; @@ -525,8 +527,8 @@ export class GirNamespace { return b; }) - .map(alias => GirAlias.fromXML(modName, building, options, null, alias)) - .filter((alias): alias is GirAlias => alias != null) + .map(alias => IntrospectedAlias.fromXML(modName, building, options, null, alias)) + .filter((alias): alias is IntrospectedAlias => alias != null) .forEach(c => building.members.set(c.name, c)); } @@ -547,8 +549,8 @@ export class GirNamespace { micro = building.getMembers("VERSION_MICRO")[0] ?? null; } - if (major instanceof GirConst && minor instanceof GirConst && major.value && minor.value) { - if (micro instanceof GirConst && micro.value) { + if (major instanceof IntrospectedConstant && minor instanceof IntrospectedConstant && major.value && minor.value) { + if (micro instanceof IntrospectedConstant && micro.value) { building.package_version = [major.value, minor.value, micro.value] as const; } else { building.package_version = [major.value, minor.value] as const; diff --git a/packages/lib/src/newlib/gir/nodes.ts b/packages/lib/src/newlib/gir/nodes.ts index e83399465..053fb4a1f 100644 --- a/packages/lib/src/newlib/gir/nodes.ts +++ b/packages/lib/src/newlib/gir/nodes.ts @@ -1,19 +1,19 @@ -export { GirAlias } from "./alias.js"; -export { GirClass, GirInterface, GirRecord, GirComplexRecord, GirBaseClass } from "./class.js"; -export { GirConst } from "./const.js"; -export { GirEnum, GirError, GirEnumMember } from "./enum.js"; +export { IntrospectedAlias as GirAlias } from "./alias.js"; +export { IntrospectedClass as GirClass, GirInterface, GirRecord, GirComplexRecord, IntrospectedBaseClass as GirBaseClass } from "./class.js"; +export { IntrospectedConstant as GirConst } from "./const.js"; +export { IntrospectedEnum as GirEnum, IntrospectedError as GirError, GirEnumMember } from "./enum.js"; export { - GirFunction, - GirClassFunction, - GirCallback, - GirConstructor, - GirStaticClassFunction, - GirVirtualClassFunction, - GirFunctionParameter, - GirDirectAllocationConstructor, + IntrospectedFunction as GirFunction, + IntrospectedClassFunction as GirClassFunction, + IntrospectedCallback as GirCallback, + IntrospectedConstructor as GirConstructor, + IntrospectedStaticClassFunction as GirStaticClassFunction, + IntrospectedVirtualClassFunction as GirVirtualClassFunction, + IntrospectedFunctionParameter as GirFunctionParameter, + IntrospectedDirectAllocationConstructor as GirDirectAllocationConstructor, } from "./function.js"; -export { GirNamespace, GirNSMember } from "./namespace.js"; -export { GirNSRegistry, GirNSLoader } from "./registry.js"; -export { GirField, GirProperty } from "./property.js"; -export { GirSignal, GirSignalType } from "./signal.js"; +export { IntrospectedNamespace as GirNamespace, GirNSMember } from "./namespace.js"; +export { NSRegistry as GirNSRegistry, NSLoader as GirNSLoader } from "./registry.js"; +export { Field as GirField, GirProperty } from "./property.js"; +export { IntrospectedSignal as GirSignal, IntrospectedSignalType as GirSignalType } from "./signal.js"; export * as nodeUtils from "./util.js"; diff --git a/packages/lib/src/newlib/gir/property.ts b/packages/lib/src/newlib/gir/property.ts index c17005f2b..2df885eb9 100644 --- a/packages/lib/src/newlib/gir/property.ts +++ b/packages/lib/src/newlib/gir/property.ts @@ -1,16 +1,16 @@ import { TypeExpression } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; -import { FieldElement, PropertyElement } from "@gi.ts/parser"; +import {IntrospectedBase, Options} from './base.js'; +import { GirFieldElement, GirPropertyElement } from "../../index.js"; import { getType, parseDoc, parseMetadata } from "./util.js"; -import { GirNamespace, isIntrospectable } from "./namespace.js"; +import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -import { GirBaseClass } from "./class.js"; -import { GirEnum } from "./enum.js"; +import { IntrospectedBaseClass } from "./class.js"; +import { IntrospectedEnum } from "./enum.js"; -export class GirField extends GirBase { +export class Field extends IntrospectedBase { type: TypeExpression; // TODO: Make these properties readonly @@ -20,10 +20,10 @@ export class GirField extends GirBase { writable: boolean; isNative: boolean = false; - copy(options?: { parent?: GirBase; type?: TypeExpression; isStatic?: boolean }): GirField { + copy(options?: { parent?: IntrospectedBase; type?: TypeExpression; isStatic?: boolean }): Field { const { type, name, optional, computed, isStatic, writable } = this; - return new GirField({ + return new Field({ name, type: options?.type ?? type, optional, @@ -41,7 +41,7 @@ export class GirField extends GirBase { isStatic = false, writable = true, ...args - }: GirOptions<{ + }: Options<{ name: string; type: TypeExpression; computed?: boolean; @@ -62,7 +62,7 @@ export class GirField extends GirBase { return generator.generateField(this); } - accept(visitor: GirVisitor): GirField { + accept(visitor: GirVisitor): Field { const node = this.copy({ type: visitor.visitType?.(this.type) ?? this.type }); @@ -72,14 +72,14 @@ export class GirField extends GirBase { static fromXML( namespace: string, - ns: GirNamespace, + ns: IntrospectedNamespace, _options: LoadOptions, _parent, - field: FieldElement - ): GirField { + field: GirFieldElement + ): Field { let name = field.$["name"]; let _name = name.replace(/[-]/g, "_"); - const f = new GirField({ + const f = new Field({ name: _name, type: getType(namespace, ns, field), isPrivate: field.$.private === "1", @@ -90,20 +90,20 @@ export class GirField extends GirBase { } } -export class JSField extends GirField { +export class JSField extends Field { isNative = true; } -export class GirProperty extends GirBase { +export class GirProperty extends IntrospectedBase { type: TypeExpression; readonly writable: boolean = false; readonly readable: boolean = true; readonly constructOnly: boolean; - parent: GirBaseClass | GirEnum; + parent: IntrospectedBaseClass | IntrospectedEnum; - copy(options?: { name?: string; parent?: GirBaseClass | GirEnum; type?: TypeExpression }): GirProperty { + copy(options?: { name?: string; parent?: IntrospectedBaseClass | IntrospectedEnum; type?: TypeExpression }): GirProperty { const { name, writable, readable, type, constructOnly, parent } = this; return new GirProperty({ @@ -133,13 +133,13 @@ export class GirProperty extends GirBase { constructOnly, parent, ...args - }: GirOptions<{ + }: Options<{ name: string; type: TypeExpression; writable: boolean; readable: boolean; constructOnly: boolean; - parent: GirBaseClass | GirEnum; + parent: IntrospectedBaseClass | IntrospectedEnum; }>) { super(name, { ...args }); @@ -177,10 +177,10 @@ export class GirProperty extends GirBase { static fromXML( namespace: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirBaseClass | GirEnum, - prop: PropertyElement + parent: IntrospectedBaseClass | IntrospectedEnum, + prop: GirPropertyElement ): GirProperty { let name = prop.$["name"]; let _name = name.replace(/[-]/g, "_"); diff --git a/packages/lib/src/newlib/gir/registry.ts b/packages/lib/src/newlib/gir/registry.ts index 779446c2a..3d6c89c1d 100644 --- a/packages/lib/src/newlib/gir/registry.ts +++ b/packages/lib/src/newlib/gir/registry.ts @@ -12,26 +12,26 @@ import { TwoKeyMap } from "../util.js"; import { ClassVisitor } from "../validators/class.js"; import { InterfaceVisitor } from "../validators/interface.js"; import { GirVisitor } from "../visitor.js"; -import { GirNamespace } from "./namespace.js"; +import { IntrospectedNamespace } from "./namespace.js"; import { DtsModuleGenerator } from "../generators/dts-modules.js"; import { DtsInlineGenerator } from "../generators/dts-inline.js"; -export interface GirNSLoader { +export interface NSLoader { load(namespace: string, version: string): GirXML | null; loadAll(namespace: string): GirXML[]; } type GeneratorConstructor = { - new (namespace: GirNamespace, options: GenerationOptions, ...args: any[]): FormatGenerator; + new (namespace: IntrospectedNamespace, options: GenerationOptions, ...args: any[]): FormatGenerator; }; -export class GirNSRegistry { - mapping: TwoKeyMap = new TwoKeyMap(); +export class NSRegistry { + mapping: TwoKeyMap = new TwoKeyMap(); private formatters: Map = new Map(); private generators: Map> = new Map(); - c_mapping: Map = new Map(); + c_mapping: Map = new Map(); transformations: GirVisitor[] = []; - loaders: [GirNSLoader, LoadOptions][] = []; + loaders: [NSLoader, LoadOptions][] = []; subtypes = new TwoKeyMap>(); constructor() { @@ -57,13 +57,13 @@ export class GirNSRegistry { registerGenerator( output: string, - generator: { new (namespace: GirNamespace, options: GenerationOptions): FormatGenerator } + generator: { new (namespace: IntrospectedNamespace, options: GenerationOptions): FormatGenerator } ) { this.generators.set(output, generator); } - getGenerator(output: "json"): { new (namespace: GirNamespace, options: GenerationOptions): JsonGenerator }; - getGenerator(output: "dts"): { new (namespace: GirNamespace, options: GenerationOptions): DtsGenerator }; + getGenerator(output: "json"): { new (namespace: IntrospectedNamespace, options: GenerationOptions): JsonGenerator }; + getGenerator(output: "dts"): { new (namespace: IntrospectedNamespace, options: GenerationOptions): DtsGenerator }; getGenerator(output: string): GeneratorConstructor | undefined; getGenerator(output: string): GeneratorConstructor | undefined { if (output === "dts") { @@ -110,13 +110,13 @@ export class GirNSRegistry { return this.generators.get(output); } - private _transformNamespace(namespace: GirNamespace) { + private _transformNamespace(namespace: IntrospectedNamespace) { this.transformations.forEach(t => { namespace.accept(t); }); } - namespace(name: string, version: string): GirNamespace | null { + namespace(name: string, version: string): IntrospectedNamespace | null { const namespace = this.mapping.get(name, version); if (!namespace) { @@ -126,7 +126,7 @@ export class GirNSRegistry { return namespace; } - namespacesForPrefix(c_prefix): GirNamespace[] { + namespacesForPrefix(c_prefix): IntrospectedNamespace[] { return this.c_mapping.get(c_prefix) ?? []; } @@ -187,7 +187,7 @@ export class GirNSRegistry { throw new Error(`No single version found for unspecified dependency: ${name}.`); } - assertNamespace(name: string, version: string): GirNamespace { + assertNamespace(name: string, version: string): IntrospectedNamespace { let namespace = this.mapping.get(name, version) ?? null; if (!namespace) { @@ -201,8 +201,8 @@ export class GirNSRegistry { return namespace; } - load(gir: GirXML, options: LoadOptions): GirNamespace { - const namespace = GirNamespace.fromXML(gir, options, this); + load(gir: GirXML, options: LoadOptions): IntrospectedNamespace { + const namespace = IntrospectedNamespace.fromXML(gir, options, this); this.mapping.set(namespace.name, namespace.version, namespace); @@ -219,7 +219,7 @@ export class GirNSRegistry { return namespace; } - private _defaultVersionInternalLoad(name: string): GirNamespace | null { + private _defaultVersionInternalLoad(name: string): IntrospectedNamespace | null { const all = this.loaders .map(([loader, options]) => { try { @@ -253,7 +253,7 @@ export class GirNSRegistry { return ns; } - private _internalLoad(name: string, version: string): GirNamespace | null { + private _internalLoad(name: string, version: string): IntrospectedNamespace | null { for (const [loader, options] of this.loaders) { try { const xml = loader.load(name, version); @@ -276,7 +276,7 @@ export class GirNSRegistry { return null; } - registerLoader(loader: GirNSLoader, options: LoadOptions) { + registerLoader(loader: NSLoader, options: LoadOptions) { this.loaders.push([loader, options]); } } diff --git a/packages/lib/src/newlib/gir/signal.ts b/packages/lib/src/newlib/gir/signal.ts index 52134f4c1..ea2bb7345 100644 --- a/packages/lib/src/newlib/gir/signal.ts +++ b/packages/lib/src/newlib/gir/signal.ts @@ -1,35 +1,33 @@ import { - VoidType, UnknownType, NativeType, TypeExpression, ThisType, NumberType, - NullableType, ArrayType } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; -import { GirNamespace, isIntrospectable } from "./namespace.js"; -import { GirClass } from "./class.js"; -import { GirClassFunction, GirFunctionParameter, GirCallback } from "./function.js"; -import { SignalElement, Direction, CallableParamElement } from "@gi.ts/parser"; +import {IntrospectedBase, Options} from './base.js'; +import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; +import { IntrospectedClass } from "./class.js"; +import { IntrospectedClassFunction, IntrospectedFunctionParameter, IntrospectedCallback } from "./function.js"; +import { GirSignalElement, GirDirection, GirCallableParamElement } from "@gi.ts/parser"; import { getType, parseDoc, parseMetadata } from "./util.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export enum GirSignalType { +export enum IntrospectedSignalType { CONNECT, CONNECT_AFTER, EMIT } -export class GirSignal extends GirBase { - parameters: GirFunctionParameter[]; +export class IntrospectedSignal extends IntrospectedBase { + parameters: IntrospectedFunctionParameter[]; return_type: TypeExpression; - parent: GirClass; + parent: IntrospectedClass; constructor({ name, @@ -37,11 +35,11 @@ export class GirSignal extends GirBase { return_type = UnknownType, parent, ...args - }: GirOptions<{ + }: Options<{ name: string; - parameters?: GirFunctionParameter[]; + parameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; - parent: GirClass; + parent: IntrospectedClass; }>) { super(name, { ...args }); @@ -50,7 +48,7 @@ export class GirSignal extends GirBase { this.parent = parent; } - accept(visitor: GirVisitor): GirSignal { + accept(visitor: GirVisitor): IntrospectedSignal { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -66,11 +64,11 @@ export class GirSignal extends GirBase { parameters, returnType }: { - parent?: GirClass; - parameters?: GirFunctionParameter[]; + parent?: IntrospectedClass; + parameters?: IntrospectedFunctionParameter[]; returnType?: TypeExpression; - } = {}): GirSignal { - return new GirSignal({ + } = {}): IntrospectedSignal { + return new IntrospectedSignal({ name: this.name, parent, parameters: parameters ?? this.parameters, @@ -80,12 +78,12 @@ export class GirSignal extends GirBase { static fromXML( modName: string, - ns: GirNamespace, + ns: IntrospectedNamespace, options: LoadOptions, - parent: GirClass, - sig: SignalElement - ): GirSignal { - const signal = new GirSignal({ + parent: IntrospectedClass, + sig: GirSignalElement + ): IntrospectedSignal { + const signal = new IntrospectedSignal({ name: sig.$.name, parent, isIntrospectable: isIntrospectable(sig) @@ -94,8 +92,8 @@ export class GirSignal extends GirBase { if (sig.parameters && sig.parameters[0].parameter) { signal.parameters.push( ...sig.parameters[0].parameter - .filter((p): p is CallableParamElement & { $: { name: string } } => !!p.$.name) - .map(p => GirFunctionParameter.fromXML(modName, ns, options, signal, p)) + .filter((p): p is GirCallableParamElement & { $: { name: string } } => !!p.$.name) + .map(p => IntrospectedFunctionParameter.fromXML(modName, ns, options, signal, p)) ); } @@ -144,11 +142,11 @@ export class GirSignal extends GirBase { }, { allowOptions: true, - params: [] as GirFunctionParameter[] + params: [] as IntrospectedFunctionParameter[] } ) .params.reverse() - .filter((p): p is GirFunctionParameter => p != null); + .filter((p): p is IntrospectedFunctionParameter => p != null); signal.return_type = getType(modName, ns, sig["return-value"]?.[0]); @@ -170,17 +168,17 @@ export class GirSignal extends GirBase { }); const parameters = [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: prefix_signal ? "$signal" : "signal", type: NativeType.of(`'${this.name}'`), - direction: Direction.In + direction: GirDirection.In }), ...emit.parameters ]; const return_type = VoidType; - return new GirClassFunction({ + return new IntrospectedClassFunction({ return_type, parameters, name: "emit", @@ -194,33 +192,33 @@ export class GirSignal extends GirBase { const name = after ? "connect_after" : "connect"; const parent = this.parent; - const cb = new GirCallback({ + const cb = new IntrospectedCallback({ raw_name: "callback", name: "callback", output_parameters: [], parameters: [ - new GirFunctionParameter({ name: "_source", type: ThisType, direction: Direction.In }), + new IntrospectedFunctionParameter({ name: "_source", type: ThisType, direction: GirDirection.In }), ...connect.parameters.map(p => p.copy()) ], return_type: connect.return_type }); const parameters = [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "signal", type: NativeType.of(`'${this.name}'`), - direction: Direction.In + direction: GirDirection.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "callback", type: cb.asFunctionType(), - direction: Direction.In + direction: GirDirection.In }) ]; const return_type = NumberType; - return new GirClassFunction({ + return new IntrospectedClassFunction({ return_type, parameters, name, @@ -230,7 +228,7 @@ export class GirSignal extends GirBase { asString>( generator: T, - type?: GirSignalType + type?: IntrospectedSignalType ): ReturnType { return generator.generateSignal(this, type); } diff --git a/packages/lib/src/newlib/gir/util.ts b/packages/lib/src/newlib/gir/util.ts index 7ec730c4d..e4970381b 100644 --- a/packages/lib/src/newlib/gir/util.ts +++ b/packages/lib/src/newlib/gir/util.ts @@ -1,14 +1,14 @@ -import { deprecatedVersion, GirNamespace, introducedVersion, isDeprecated } from "./namespace.js"; +import { deprecatedVersion, IntrospectedNamespace, introducedVersion, isDeprecated } from "./namespace.js"; import { - CallableParamElement, - Direction, - AliasElement, - DocElement, - InfoAttrs, - Type, - ConstantElement, - CallableReturn, - FieldElement + GirCallableParamElement, + GirDirection, + GirAliasElement, + GirDocElement, + GirInfoAttrs, + GirType, + GirConstantElement, + GirCallableReturn, + GirFieldElement } from "@gi.ts/parser"; import { TypeIdentifier, @@ -33,8 +33,8 @@ import { NativeType } from "../gir.js"; -import {GirBase, GirOptions, GirMetadata} from './base.js'; -import { GirBaseClass } from "./class.js"; +import {IntrospectedBase, Options, Metadata} from './base.js'; +import { IntrospectedBaseClass } from "./class.js"; import { TwoKeyMap } from "../util.js"; const reservedWords = [ @@ -106,7 +106,7 @@ const reservedWords = [ "yield" ]; -export function getAliasType(modName: string, _ns: GirNamespace, parameter: AliasElement): TypeExpression { +export function getAliasType(modName: string, _ns: IntrospectedNamespace, parameter: GirAliasElement): TypeExpression { let name = parameter.type?.[0].$["name"] || "unknown"; let nameParts = name.split(" "); @@ -125,7 +125,7 @@ export function getAliasType(modName: string, _ns: GirNamespace, parameter: Alia * * Any type where the c:type ends with * */ -function isPointerType(types: Type[] | undefined) { +function isPointerType(types: GirType[] | undefined) { const type = types?.[0]; if (!type) return false; @@ -143,8 +143,8 @@ function isPointerType(types: Type[] | undefined) { /* Decode the type */ export function getType( modName: string, - _ns: GirNamespace, - param?: ConstantElement | CallableReturn | FieldElement + _ns: IntrospectedNamespace, + param?: GirConstantElement | GirCallableReturn | GirFieldElement ): TypeExpression { if (!param) return VoidType; @@ -153,7 +153,7 @@ export function getType( let length: number | null = null; let isPointer = false; - let parameter = param as CallableParamElement; + let parameter = param as GirCallableParamElement; if (parameter.array && parameter.array[0]) { arrayDepth = 1; @@ -354,15 +354,15 @@ export function isInvalid(name: string): boolean { return false; } -export function parseDoc(element: DocElement): string | null { +export function parseDoc(element: GirDocElement): string | null { return element.doc?.[0]?._ ?? null; } -export function parseDeprecatedDoc(element: DocElement): string | null { +export function parseDeprecatedDoc(element: GirDocElement): string | null { return element["doc-deprecated"]?.[0]?._ ?? null; } -export function parseMetadata(element: { $: InfoAttrs } & DocElement): GirMetadata | undefined { +export function parseMetadata(element: { $: GirInfoAttrs } & GirDocElement): Metadata | undefined { const version = introducedVersion(element); const deprecatedIn = deprecatedVersion(element); const deprecated = isDeprecated(element); @@ -517,20 +517,20 @@ export function resolvePrimitiveType(name: string): TypeExpression | null { return null; } -export function resolveDirectedType(type: TypeExpression, direction: Direction): TypeExpression | null { +export function resolveDirectedType(type: TypeExpression, direction: GirDirection): TypeExpression | null { if (type instanceof ArrayType) { if ( - (direction === Direction.In || direction === Direction.Inout) && + (direction === GirDirection.In || direction === GirDirection.Inout) && type.type.equals(Uint8ArrayType) && type.arrayDepth === 0 ) { return new BinaryType(type, StringType); } } else if (type instanceof TypeIdentifier) { - if ((direction === Direction.In || direction === Direction.Inout) && type.is("GLib", "Bytes")) { + if ((direction === GirDirection.In || direction === GirDirection.Inout) && type.is("GLib", "Bytes")) { return new BinaryType(type, Uint8ArrayType); } else if (type.is("GObject", "Value")) { - if (direction === Direction.In || direction === Direction.Inout) { + if (direction === GirDirection.In || direction === GirDirection.Inout) { return new BinaryType(type, AnyType); } else { // GJS converts GObject.Value out parameters to their unboxed type, which we don't know, @@ -538,7 +538,7 @@ export function resolveDirectedType(type: TypeExpression, direction: Direction): return UnknownType; } } else if (type.is("GLib", "HashTable")) { - if (direction === Direction.In) { + if (direction === GirDirection.In) { return new BinaryType(new NativeType("{ [key: string]: any }"), type); } else { return type; @@ -558,7 +558,7 @@ export function resolveDirectedType(type: TypeExpression, direction: Direction): * @param namespace * @param type */ -export function resolveTypeIdentifier(namespace: GirNamespace, type: TypeIdentifier): GirBaseClass | null { +export function resolveTypeIdentifier(namespace: IntrospectedNamespace, type: TypeIdentifier): IntrospectedBaseClass | null { const ns = type.namespace; const name = type.name; @@ -593,7 +593,7 @@ function isTypeConflict(a: TypeExpression, b: TypeExpression) { * @param parentType */ export function isSubtypeOf( - namespace: GirNamespace, + namespace: IntrospectedNamespace, thisType: TypeIdentifier, parentThisType: TypeIdentifier, potentialSubtype: TypeExpression, diff --git a/packages/lib/src/newlib/injections/gio.ts b/packages/lib/src/newlib/injections/gio.ts index bc4adca02..63fa98905 100644 --- a/packages/lib/src/newlib/injections/gio.ts +++ b/packages/lib/src/newlib/injections/gio.ts @@ -1,10 +1,10 @@ -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; import { - GirClassFunction, - GirConstructor, - GirFunction, - GirFunctionParameter, - GirStaticClassFunction + IntrospectedClassFunction, + IntrospectedConstructor, + IntrospectedFunction, + IntrospectedFunctionParameter, + IntrospectedStaticClassFunction } from "../gir/function.js"; import { StringType, @@ -20,13 +20,13 @@ import { Generic } from "../gir.js"; import { Direction } from "@gi.ts/parser"; -import { GirField, JSField } from "../gir/property.js"; -import { GirClass, GirInterface } from "../gir/class.js"; +import { Field, JSField } from "../gir/property.js"; +import { IntrospectedClass, GirInterface } from "../gir/class.js"; export default { namespace: "Gio", version: "2.0", - modifier(namespace: GirNamespace) { + modifier(namespace: IntrospectedNamespace) { // For IterableIterator... namespace.___dts___addReference(`/// `); @@ -34,10 +34,10 @@ export default { const DBusNodeInfo = namespace.assertClass("DBusNodeInfo"); DBusNodeInfo.constructors.push( - new GirConstructor({ + new IntrospectedConstructor({ name: "new_for_xml", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "info", type: StringType, direction: Direction.In @@ -52,10 +52,10 @@ export default { const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); DBusInterfaceInfo.constructors.push( - new GirConstructor({ + new IntrospectedConstructor({ name: "new_for_xml", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "info", type: StringType, direction: Direction.In @@ -70,7 +70,7 @@ export default { const ListStore = namespace.assertClass("ListStore"); ListStore.fields.push( - new GirField({ + new Field({ name: "Symbol.iterator", computed: true, type: new FunctionType( @@ -121,11 +121,11 @@ export default { DBusProxy.indexSignature = "[key: string]: any;"; DBusProxy.members.push( - new GirStaticClassFunction({ + new IntrospectedStaticClassFunction({ name: "makeProxyWrapper", parent: DBusProxy, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "args", type: new ArrayType(AnyType), isVarArgs: true, @@ -134,11 +134,11 @@ export default { ], return_type: AnyType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "connectSignal", parent: DBusProxy, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "args", type: new ArrayType(AnyType), isVarArgs: true, @@ -147,11 +147,11 @@ export default { ], return_type: AnyType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "disconnectSignal", parent: DBusProxy, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "args", type: new ArrayType(AnyType), isVarArgs: true, @@ -176,15 +176,15 @@ export default { if ( !( - bus_get instanceof GirFunction && - bus_get_finish instanceof GirFunction && - bus_get_sync instanceof GirFunction && - bus_own_name instanceof GirFunction && - bus_own_name_on_connection instanceof GirFunction && - bus_unown_name instanceof GirFunction && - bus_watch_name instanceof GirFunction && - bus_unwatch_name instanceof GirFunction && - bus_watch_name_on_connection instanceof GirFunction + bus_get instanceof IntrospectedFunction && + bus_get_finish instanceof IntrospectedFunction && + bus_get_sync instanceof IntrospectedFunction && + bus_own_name instanceof IntrospectedFunction && + bus_own_name_on_connection instanceof IntrospectedFunction && + bus_unown_name instanceof IntrospectedFunction && + bus_watch_name instanceof IntrospectedFunction && + bus_unwatch_name instanceof IntrospectedFunction && + bus_watch_name_on_connection instanceof IntrospectedFunction ) ) { throw new Error(`Invalid dbus functions found in Gio!`); @@ -254,25 +254,25 @@ export default { DBusConnection.members.splice(DBusConnection.members.indexOf(callFinish), 1, finishReplacement); DBusConnection.members.push( - new GirClassFunction({ + new IntrospectedClassFunction({ name: "watch_name", parameters: bus_watch_name_on_connection.parameters.slice(1), return_type: bus_watch_name_on_connection.return_type, parent: DBusConnection }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "unwatch_name", parameters: bus_unwatch_name.parameters.slice(), return_type: bus_unwatch_name.return_type, parent: DBusConnection }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "own_name", parameters: bus_own_name_on_connection.parameters.slice(1), return_type: bus_own_name_on_connection.return_type, parent: DBusConnection }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "unown_name", parameters: bus_unown_name.parameters.slice(), return_type: bus_unown_name.return_type, @@ -314,19 +314,19 @@ export default { const Variant = namespace.assertInstalledImport("GLib").assertClass("Variant"); const DBusConnection = namespace.assertClass("DBusConnection"); const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); - const DBusExportedObject = new GirClass("DBusExportedObject", namespace); + const DBusExportedObject = new IntrospectedClass("DBusExportedObject", namespace); DBusExportedObject.members.push( - new GirStaticClassFunction({ + new IntrospectedStaticClassFunction({ name: "wrapJSObject", parent: DBusExportedObject, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "info", type: StringType, direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "obj", type: AnyType, direction: Direction.In @@ -334,29 +334,29 @@ export default { ], return_type: DBusExportedObject.getType() }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "get_info", parent: DBusExportedObject, parameters: [], return_type: DBusInterfaceInfo.getType() }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "get_connection", parent: DBusExportedObject, parameters: [], return_type: DBusConnection.getType() }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "get_object_path", parent: DBusExportedObject, parameters: [], return_type: StringType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "unexport_from_connection", parent: DBusExportedObject, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "connection", type: DBusConnection.getType(), direction: Direction.In @@ -365,16 +365,16 @@ export default { return_type: VoidType }), // export(busConnection, objectPath) - new GirClassFunction({ + new IntrospectedClassFunction({ name: "export", parent: DBusExportedObject, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "busConnection", type: DBusConnection.getType(), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "objectPath", type: StringType, direction: Direction.In @@ -383,28 +383,28 @@ export default { return_type: VoidType }), // unexport() - new GirClassFunction({ + new IntrospectedClassFunction({ name: "unexport", parent: DBusExportedObject, return_type: VoidType }), // flush() - new GirClassFunction({ + new IntrospectedClassFunction({ name: "flush", parent: DBusExportedObject, return_type: VoidType }), // emit_signal(name, variant) - new GirClassFunction({ + new IntrospectedClassFunction({ name: "emit_signal", parent: DBusExportedObject, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "name", type: StringType, direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "variant", type: Variant.getType(), direction: Direction.In @@ -413,16 +413,16 @@ export default { return_type: VoidType }), // emit_property_changed(name, variant) - new GirClassFunction({ + new IntrospectedClassFunction({ name: "emit_property_changed", parent: DBusExportedObject, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "name", type: StringType, direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "variant", type: Variant.getType(), direction: Direction.In diff --git a/packages/lib/src/newlib/injections/glib.ts b/packages/lib/src/newlib/injections/glib.ts index 0549ad2b5..67f04ac44 100644 --- a/packages/lib/src/newlib/injections/glib.ts +++ b/packages/lib/src/newlib/injections/glib.ts @@ -1,10 +1,10 @@ -import { GirNamespace } from "../gir/namespace.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; import { - GirConstructor, - GirFunctionParameter, - GirClassFunction, - GirFunction, - GirDirectAllocationConstructor + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedClassFunction, + IntrospectedFunction, + IntrospectedDirectAllocationConstructor } from "../gir/function.js"; import { NativeType, @@ -18,32 +18,32 @@ import { BinaryType } from "../gir.js"; import { Direction } from "@gi.ts/parser"; -import { GirNSRegistry } from "../gir/registry.js"; +import { NSRegistry } from "../gir/registry.js"; import { GirRecord } from "../gir/class.js"; export default { namespace: "GLib", version: "2.0", - modifier(namespace: GirNamespace, registry: GirNSRegistry) { + modifier(namespace: IntrospectedNamespace, registry: NSRegistry) { // export function log_structured(logDomain, logLevel, stringFields); namespace.members.set( "log_structured", - new GirFunction({ + new IntrospectedFunction({ name: "log_structured", raw_name: "log_structured", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "logDomain", type: AnyType, direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "logLevel", type: AnyType, direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "stringFields", type: AnyType, direction: Direction.In @@ -57,11 +57,11 @@ export default { namespace.members.set( "strstrip", - new GirFunction({ + new IntrospectedFunction({ name: "strstrip", raw_name: "strstrip", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "str", type: StringType, direction: Direction.In @@ -76,7 +76,7 @@ export default { { const Error = namespace.assertClass("Error"); - const fixQuark = (c: T): T => { + const fixQuark = (c: T): T => { return c.copy({ parameters: c.parameters.map(p => { if (p.type instanceof TypeIdentifier && p.type.is("GLib", "Quark")) { @@ -90,7 +90,7 @@ export default { }) as T; }; - if (Error.mainConstructor && !(Error.mainConstructor instanceof GirDirectAllocationConstructor)) + if (Error.mainConstructor && !(Error.mainConstructor instanceof IntrospectedDirectAllocationConstructor)) Error.mainConstructor = fixQuark(Error.mainConstructor); Error.constructors = Error.constructors.map(c => fixQuark(c)); @@ -120,18 +120,18 @@ export default { }); const VariantParams = [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "sig", type: new GenericType("A"), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "value", type: AnyType, direction: Direction.In }) ]; - const VariantConstructor = new GirConstructor({ + const VariantConstructor = new IntrospectedConstructor({ name: "new", parameters: VariantParams.map(vp => vp.copy()), return_type: Variant.getType() @@ -143,7 +143,7 @@ export default { // static new: (sig: any, value: any) => Variant; VariantConstructor.copy(), // static _new_internal: (sig: any, value: any) => any;, - new GirConstructor({ + new IntrospectedConstructor({ name: "_new_internal", parameters: VariantParams.map(vp => vp.copy()), return_type: AnyType @@ -152,31 +152,31 @@ export default { Variant.members.push( // unpack(): T; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "unpack", return_type: UnknownType, parent: Variant }), // deepUnpack(): T; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "deepUnpack", return_type: UnknownType, parent: Variant }), // deep_unpack: any; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "deep_unpack", return_type: UnknownType, parent: Variant }), // recursiveUnpack: () => any; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "recursiveUnpack", return_type: AnyType, parent: Variant }), // _init(sig: any, value: any): Variant; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "_init", return_type: Variant.getType(), parent: Variant, @@ -192,23 +192,23 @@ export default { VariantDict.members.push( // lookup(key: any, variantType?: any, deep?: any): any; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "lookup", return_type: AnyType, parent: VariantDict, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "key", direction: Direction.In, type: AnyType }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "variantType", direction: Direction.In, type: AnyType, isOptional: true }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "deep", direction: Direction.In, type: BooleanType, @@ -226,7 +226,7 @@ export default { Bytes.members.push( // toArray(): Uint8Array; - new GirClassFunction({ + new IntrospectedClassFunction({ name: "toArray", return_type: Uint8ArrayType, parent: Bytes, diff --git a/packages/lib/src/newlib/injections/gobject.ts b/packages/lib/src/newlib/injections/gobject.ts index d8577a5a5..2f78fc53c 100644 --- a/packages/lib/src/newlib/injections/gobject.ts +++ b/packages/lib/src/newlib/injections/gobject.ts @@ -1,5 +1,5 @@ -import { GirNamespace } from "../gir/namespace.js"; -import { GirFunctionParameter, GirClassFunction, GirFunction, GirStaticClassFunction } from "../gir/function.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { IntrospectedFunctionParameter, IntrospectedClassFunction, IntrospectedFunction, IntrospectedStaticClassFunction } from "../gir/function.js"; import { NativeType, AnyType, @@ -20,13 +20,13 @@ import { GenerifiedTypeIdentifier } from "../gir.js"; import { Direction } from "@gi.ts/parser"; -import { GirField } from "../gir/property.js"; -import { GirAlias } from "../gir/alias.js"; +import { Field } from "../gir/property.js"; +import { IntrospectedAlias } from "../gir/alias.js"; import { GirInterface } from "../gir/class.js"; -import { GirNSRegistry } from "../gir/registry.js"; +import { NSRegistry } from "../gir/registry.js"; function typeParam(name: string, type: TypeExpression) { - return new GirFunctionParameter({ + return new IntrospectedFunctionParameter({ name, direction: Direction.In, type: type @@ -40,25 +40,25 @@ function anyParam(name: string) { export default { namespace: "GObject", version: "2.0", - modifier(namespace: GirNamespace, _registry: GirNSRegistry) { + modifier(namespace: IntrospectedNamespace, _registry: NSRegistry) { { const SignalMatch = new GirInterface({ name: "SignalMatch", namespace, fields: [ - new GirField({ + new Field({ name: "signalId", type: StringType, isStatic: false, writable: true }), - new GirField({ + new Field({ name: "detail", type: StringType, isStatic: false, writable: true }), - new GirField({ + new Field({ name: "func", type: AnyFunctionType, isStatic: false, @@ -72,7 +72,7 @@ export default { namespace.members.set("SignalMatch", SignalMatch); - const GType = new GirAlias({ + const GType = new IntrospectedAlias({ name: "GType", type: new NativeType("any") }); @@ -95,7 +95,7 @@ export default { defaultValueType: TypeExpression = AnyType, addGeneric = false ) { - const fn = new GirStaticClassFunction({ + const fn = new IntrospectedStaticClassFunction({ name, parameters: [ typeParam("name", StringType), @@ -107,7 +107,7 @@ export default { ? !addGeneric ? [anyParam(`${type}Type`)] : [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: `${type}Type`, direction: Direction.In, type: new NativeType("GType | { $gtype: GType }") @@ -128,7 +128,7 @@ export default { } ParamSpec.fields.push( - new GirField({ + new Field({ name: "override", isStatic: true, type: AnyType, @@ -166,14 +166,14 @@ export default { default: UnknownType }); - const object = new GirStaticClassFunction({ + const object = new IntrospectedStaticClassFunction({ name: "object", parameters: [ anyParam("name"), anyParam("nick"), anyParam("blurb"), anyParam("flags"), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: `objectType`, direction: Direction.In, type: new NativeType("GType | { $gtype: GType }") @@ -248,7 +248,7 @@ export default { namespace.members.set( "Closure", - new GirAlias({ + new IntrospectedAlias({ name: "Closure", type: NativeType.of("(...args: P[]) => R"), generics: [ @@ -271,11 +271,11 @@ export default { const get_property = Object.members.findIndex(m => m.name === "get_property"); const set_property = Object.members.findIndex(m => m.name === "set_property"); - Object.members[get_property] = new GirClassFunction({ + Object.members[get_property] = new IntrospectedClassFunction({ name: "get_property", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "property_name", type: StringType, direction: Direction.In @@ -284,16 +284,16 @@ export default { return_type: AnyType }); - Object.members[set_property] = new GirClassFunction({ + Object.members[set_property] = new IntrospectedClassFunction({ name: "set_property", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "property_name", type: StringType, direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "value", type: AnyType, direction: Direction.In @@ -303,11 +303,11 @@ export default { }); Object.members.push( - new GirStaticClassFunction({ + new IntrospectedStaticClassFunction({ name: "_classInit", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "klass", type: AnyType, direction: Direction.In @@ -315,11 +315,11 @@ export default { ], return_type: AnyType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "disconnect", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: NumberType, direction: Direction.In @@ -328,11 +328,11 @@ export default { return_type: VoidType }), // TODO: Add per-class set type checking. - new GirClassFunction({ + new IntrospectedClassFunction({ name: "set", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "properties", type: new NativeType("{ [key: string]: any }"), direction: Direction.In @@ -340,11 +340,11 @@ export default { ], return_type: VoidType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "block_signal_handler", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: NumberType, direction: Direction.In @@ -352,11 +352,11 @@ export default { ], return_type: AnyType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "unblock_signal_handler", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "id", type: NumberType, direction: Direction.In @@ -364,11 +364,11 @@ export default { ], return_type: AnyType }), - new GirClassFunction({ + new IntrospectedClassFunction({ name: "stop_emission_by_name", parent: Object, parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "detailedName", type: StringType, direction: Direction.In @@ -378,7 +378,7 @@ export default { }) ); - function replaceFunction(name: string, ...functions: GirFunction[]) { + function replaceFunction(name: string, ...functions: IntrospectedFunction[]) { namespace.members.delete(name); namespace.members.set(name, functions); @@ -388,16 +388,16 @@ export default { replaceFunction( "signal_handlers_block_by_func", - new GirFunction({ + new IntrospectedFunction({ name: "signal_handlers_block_by_func", raw_name: "signal_handlers_block_by_func", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "instance", type: Object.getType(), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "func", type: AnyFunctionType, direction: Direction.In @@ -411,16 +411,16 @@ export default { replaceFunction( "signal_handlers_unblock_by_func", - new GirFunction({ + new IntrospectedFunction({ name: "signal_handlers_unblock_by_func", raw_name: "signal_handlers_unblock_by_func", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "instance", type: Object.getType(), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "func", type: AnyFunctionType, direction: Direction.In @@ -434,16 +434,16 @@ export default { replaceFunction( "signal_handlers_disconnect_by_func", - new GirFunction({ + new IntrospectedFunction({ name: "signal_handlers_disconnect_by_func", raw_name: "signal_handlers_disconnect_by_func", parameters: [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "instance", type: Object.getType(), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "func", type: AnyFunctionType, direction: Direction.In @@ -455,7 +455,7 @@ export default { // signal_handler_find - const args = new GirFunctionParameter({ + const args = new IntrospectedFunctionParameter({ name: "args", direction: Direction.In, isVarArgs: true, @@ -474,13 +474,13 @@ export default { }); const modifiedArgs = [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "instance", direction: Direction.In, type: Object.getType() }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "match", direction: Direction.In, type: NativeType.of("SignalMatch") @@ -488,38 +488,38 @@ export default { ]; const originalArgs = [ - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "instance", direction: Direction.In, type: Object.getType() }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "match", direction: Direction.In, type: new TypeIdentifier("SignalMatchType", "GObject") }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "signal_id", direction: Direction.In, type: NumberType }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "detail", type: new TypeIdentifier("Quark", "GLib"), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "closure", type: new NullableType(new TypeIdentifier("Closure", "GObject")), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "func", type: new NullableType(ObjectType), direction: Direction.In }), - new GirFunctionParameter({ + new IntrospectedFunctionParameter({ name: "object", type: new NullableType(ObjectType), direction: Direction.In @@ -527,7 +527,7 @@ export default { ]; function originalFunc(name: string) { - return new GirFunction({ + return new IntrospectedFunction({ name, raw_name: name, return_type: NumberType, @@ -539,14 +539,14 @@ export default { replaceFunction( name, // [name](...args: [Object, SignalMatch] | [Object, SignalMatchType, number, GLib.Quark, Closure | null, object | null, object | null]): number; - new GirFunction({ + new IntrospectedFunction({ name, raw_name: name, return_type: NumberType, parameters: [args] }), // export function [name](instance: Object, match: SignalMatch): number; - new GirFunction({ + new IntrospectedFunction({ name, raw_name: name, return_type: NumberType, diff --git a/packages/lib/src/newlib/injections/inject.ts b/packages/lib/src/newlib/injections/inject.ts index ffc397f82..1134670c1 100644 --- a/packages/lib/src/newlib/injections/inject.ts +++ b/packages/lib/src/newlib/injections/inject.ts @@ -2,12 +2,12 @@ import glib from "./glib.js"; import gobject from "./gobject.js"; import gio from "./gio.js"; -import { GirNamespace } from "../gir/namespace.js"; -import { GirNSRegistry } from "../gir/registry.js"; +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { NSRegistry } from "../gir/registry.js"; -export type NamespaceInjection = (namespace: GirNamespace, registry: GirNSRegistry) => void; +export type NamespaceInjection = (namespace: IntrospectedNamespace, registry: NSRegistry) => void; -function injectDefinitions(registry: GirNSRegistry) { +function injectDefinitions(registry: NSRegistry) { return (definition: { namespace: string; version: string; modifier: NamespaceInjection }) => { const ns = registry.assertNamespace(definition.namespace, definition.version); @@ -15,7 +15,7 @@ function injectDefinitions(registry: GirNSRegistry) { }; } -export function inject(registry: GirNSRegistry) { +export function inject(registry: NSRegistry) { const $ = injectDefinitions(registry); $(glib); diff --git a/packages/lib/src/newlib/lib.ts b/packages/lib/src/newlib/lib.ts index 42f727cbe..7b8909798 100644 --- a/packages/lib/src/newlib/lib.ts +++ b/packages/lib/src/newlib/lib.ts @@ -1,4 +1,4 @@ -import { GirNSRegistry } from "./gir/registry.js"; +import { NSRegistry } from "./gir/registry.js"; import { SanitizedIdentifiers } from "./gir/util.js"; import { GenerationOptions, Metadata } from "./types.js"; @@ -14,15 +14,15 @@ export * from "./types.js"; export * from "./gir.js"; export * from "./gir/nodes.js"; -export { GirNSRegistry } from "./gir/registry.js"; +export { NSRegistry as GirNSRegistry } from "./gir/registry.js"; export { Formatter } from "./formatters/formatter.js"; export function getSanitizedIdentifiers(): ReadonlyMap { return SanitizedIdentifiers; } -export function createRegistry(): GirNSRegistry { - return new GirNSRegistry(); +export function createRegistry(): NSRegistry { + return new NSRegistry(); } export interface GeneratedModule { @@ -32,7 +32,7 @@ export interface GeneratedModule { export async function generateModule( options: GenerationOptions, - registry: GirNSRegistry, + registry: NSRegistry, name: string, version: string ): Promise { diff --git a/packages/lib/src/newlib/validators/class.ts b/packages/lib/src/newlib/validators/class.ts index 1a5e8b27c..d627cd1f8 100644 --- a/packages/lib/src/newlib/validators/class.ts +++ b/packages/lib/src/newlib/validators/class.ts @@ -1,13 +1,11 @@ -import { FormatGenerator } from "../generators/index.js"; -import { AnyType, ArrayType, GirBase, NativeType, TypeIdentifier } from "../gir.js"; -import { GirBaseClass, GirClass, GirInterface, GirRecord } from "../gir/class.js"; -import { GirEnum, GirError } from "../gir/enum.js"; -import { GirDirectAllocationConstructor } from "../gir/function.js"; -import { GirClassFunction, GirConstructor, GirStaticClassFunction } from "../gir/nodes.js"; +import { NativeType, TypeIdentifier } from "../gir.js"; +import { IntrospectedBaseClass, IntrospectedClass, GirInterface, GirRecord } from "../gir/class.js"; +import { IntrospectedError } from "../gir/enum.js"; +import { IntrospectedClassFunction, IntrospectedDirectAllocationConstructor, IntrospectedStaticClassFunction } from "../gir/function.js"; import { resolveTypeIdentifier } from "../gir/util.js"; import { GirVisitor } from "../visitor.js"; -const filterIntrospectableClassMembers = (node: T): T => { +const filterIntrospectableClassMembers = (node: T): T => { node.fields = node.fields.filter(field => field.isIntrospectable); node.props = node.props.filter(prop => prop.isIntrospectable); node.callbacks = node.callbacks.filter(prop => prop.isIntrospectable); @@ -19,7 +17,7 @@ const filterIntrospectableClassMembers = (node: T): T => const PROTECTED_FIELD_NAMES = ["parent_instance", "parent", "parent_class", "object_class"]; -const filterProtectedFields = (node: T): T => { +const filterProtectedFields = (node: T): T => { const set = new Set(PROTECTED_FIELD_NAMES); node.fields = node.fields.filter(f => { @@ -29,16 +27,16 @@ const filterProtectedFields = (node: T): T => { return node; }; -const filterConflictingNamedClassMembers = (node: T): T => { +const filterConflictingNamedClassMembers = (node: T): T => { // Props shadow members node.members = node.members.filter(m => { - return !node.props.some(prop => prop.name === m.name && !(m instanceof GirStaticClassFunction)); + return !node.props.some(prop => prop.name === m.name && !(m instanceof IntrospectedStaticClassFunction)); }); // Props and members shadow fields node.fields = node.fields.filter( f => - !node.members.some(n => n.name === f.name && !(n instanceof GirStaticClassFunction)) && + !node.members.some(n => n.name === f.name && !(n instanceof IntrospectedStaticClassFunction)) && !node.props.some(n => n.name === f.name) ); @@ -57,7 +55,7 @@ const filterConflictingNamedClassMembers = (node: T): T * @param node * @returns */ -const fixParamSpecSubtypes = (node: T): T => { +const fixParamSpecSubtypes = (node: T): T => { if (node.parent?.namespace === "GObject" && node.parent.name.startsWith("ParamSpec")) { // We don't assert this import because we don't want to force libraries // to unnecessarily import GObject. @@ -77,7 +75,7 @@ const fixParamSpecSubtypes = (node: T): T => { * * @param node */ -const fixMissingParent = (node: T): T => { +const fixMissingParent = (node: T): T => { const { namespace } = node; if (node.parent == null) { @@ -98,7 +96,7 @@ const fixMissingParent = (node: T): T => { * * @param node */ -const removeComplexFields = (node: T): T => { +const removeComplexFields = (node: T): T => { const { namespace } = node; node.fields = node.fields.filter(f => { @@ -124,7 +122,7 @@ const removeComplexFields = (node: T): T => { const en = namespace.assertInstalledImport(type.namespace).getEnum(type.name); - if (!(en instanceof GirError)) { + if (!(en instanceof IntrospectedError)) { return true; } @@ -137,7 +135,7 @@ const removeComplexFields = (node: T): T => { return node; }; -const removePrivateFields = (node: T): T => { +const removePrivateFields = (node: T): T => { node.fields = node.fields.filter(f => { return !f.isPrivate && !f.name.startsWith("_"); }); @@ -169,7 +167,7 @@ const resolveMainConstructor = (node: GirRecord): GirRecord => { if (zeroArgsConstructor || node.isSimpleWithoutPointers()) { node.mainConstructor = - new GirDirectAllocationConstructor(node.fields); + new IntrospectedDirectAllocationConstructor(node.fields); return node; } @@ -180,7 +178,7 @@ const resolveMainConstructor = (node: GirRecord): GirRecord => { } if (node.isSimple()) { - node.mainConstructor = new GirDirectAllocationConstructor(node.fields); + node.mainConstructor = new IntrospectedDirectAllocationConstructor(node.fields); return node; } @@ -188,7 +186,7 @@ const resolveMainConstructor = (node: GirRecord): GirRecord => { return node; }; -const mergeStaticDefinitions = (node: GirClass): GirClass => { +const mergeStaticDefinitions = (node: IntrospectedClass): IntrospectedClass => { if (!node.staticDefinition) { return node; } @@ -201,13 +199,13 @@ const mergeStaticDefinitions = (node: GirClass): GirClass => { } const staticMethods = staticDefinition.members - .filter(m => m instanceof GirClassFunction) + .filter(m => m instanceof IntrospectedClassFunction) .map(m => m.asStaticClassFunction(node)); for (const staticMethod of staticMethods) { if ( !node.members.some( - member => member.name === staticMethod.name && member instanceof GirStaticClassFunction + member => member.name === staticMethod.name && member instanceof IntrospectedStaticClassFunction ) ) { node.members.push(staticMethod); @@ -228,7 +226,7 @@ function chainVisitors(node: T, ...args: ((node: T) => T)[]) { } export class ClassVisitor extends GirVisitor { - visitClass = (node: GirClass) => + visitClass = (node: IntrospectedClass) => chainVisitors( node, fixMissingParent, diff --git a/packages/lib/src/newlib/visitor.ts b/packages/lib/src/newlib/visitor.ts index 026d8879e..1c89e0e7f 100644 --- a/packages/lib/src/newlib/visitor.ts +++ b/packages/lib/src/newlib/visitor.ts @@ -1,47 +1,47 @@ import { TypeExpression } from "./gir.js"; -import { GirAlias } from "./gir/alias.js"; -import { GirRecord, GirInterface, GirClass } from "./gir/class.js"; -import { GirConst } from "./gir/const.js"; -import { GirEnumMember, GirError, GirEnum } from "./gir/enum.js"; +import { IntrospectedAlias } from "./gir/alias.js"; +import { GirRecord, GirInterface, IntrospectedClass } from "./gir/class.js"; +import { IntrospectedConstant } from "./gir/const.js"; +import { GirEnumMember, IntrospectedError, IntrospectedEnum } from "./gir/enum.js"; import { - GirCallback, - GirConstructor, - GirFunctionParameter, - GirFunction, - GirClassFunction, - GirStaticClassFunction, - GirVirtualClassFunction, - GirDirectAllocationConstructor + IntrospectedCallback, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedFunction, + IntrospectedClassFunction, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction, + IntrospectedDirectAllocationConstructor } from "./gir/function.js"; -import { GirNamespace } from "./gir/namespace.js"; -import { GirProperty, GirField } from "./gir/property.js"; -import { GirSignal, GirSignalType } from "./gir/signal.js"; +import { IntrospectedNamespace } from "./gir/namespace.js"; +import { GirProperty, Field } from "./gir/property.js"; +import { IntrospectedSignal, IntrospectedSignalType } from "./gir/signal.js"; export abstract class GirVisitor { visitType?: (node: TypeExpression) => TypeExpression; - visitCallback?: (node: GirCallback) => GirCallback; - visitAlias?: (node: GirAlias) => GirAlias; - visitConstructor?: (node: GirConstructor) => GirConstructor; - visitDirectAllocationConstructor?: (node: GirDirectAllocationConstructor) => GirDirectAllocationConstructor; - visitConstructorFunction?: (node: GirConstructor) => GirConstructor; + visitCallback?: (node: IntrospectedCallback) => IntrospectedCallback; + visitAlias?: (node: IntrospectedAlias) => IntrospectedAlias; + visitConstructor?: (node: IntrospectedConstructor) => IntrospectedConstructor; + visitDirectAllocationConstructor?: (node: IntrospectedDirectAllocationConstructor) => IntrospectedDirectAllocationConstructor; + visitConstructorFunction?: (node: IntrospectedConstructor) => IntrospectedConstructor; visitRecord?: (node: GirRecord) => GirRecord; visitInterface?: (node: GirInterface) => GirInterface; visitEnumMember?: (node: GirEnumMember) => GirEnumMember; - visitError?: (node: GirError) => GirError; - visitEnum?: (node: GirEnum) => GirEnum; - visitConst?: (node: GirConst) => GirConst; - visitClass?: (node: GirClass) => GirClass; - visitParameter?: (node: GirFunctionParameter) => GirFunctionParameter; + visitError?: (node: IntrospectedError) => IntrospectedError; + visitEnum?: (node: IntrospectedEnum) => IntrospectedEnum; + visitConst?: (node: IntrospectedConstant) => IntrospectedConstant; + visitClass?: (node: IntrospectedClass) => IntrospectedClass; + visitParameter?: (node: IntrospectedFunctionParameter) => IntrospectedFunctionParameter; visitProperty?: (node: GirProperty) => GirProperty; - visitField?: (node: GirField) => GirField; - visitSignal?: (node: GirSignal, type?: GirSignalType) => GirSignal; - visitFunction?: (node: GirFunction) => GirFunction; - visitClassFunction?: (node: GirClassFunction) => GirClassFunction; - visitStaticClassFunction?: (node: GirStaticClassFunction) => GirStaticClassFunction; - visitVirtualClassFunction?: (node: GirVirtualClassFunction) => GirVirtualClassFunction; - visitNamespace?: (node: GirNamespace) => GirNamespace; + visitField?: (node: Field) => Field; + visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal; + visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction; + visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction; + visitStaticClassFunction?: (node: IntrospectedStaticClassFunction) => IntrospectedStaticClassFunction; + visitVirtualClassFunction?: (node: IntrospectedVirtualClassFunction) => IntrospectedVirtualClassFunction; + visitNamespace?: (node: IntrospectedNamespace) => IntrospectedNamespace; } -export function visit(namespace: GirNamespace, visitor: GirVisitor) { +export function visit(namespace: IntrospectedNamespace, visitor: GirVisitor) { namespace.accept(visitor); } diff --git a/packages/lib/src/transformation.ts b/packages/lib/src/transformation.ts index e3d39d2cc..f9d851102 100644 --- a/packages/lib/src/transformation.ts +++ b/packages/lib/src/transformation.ts @@ -284,9 +284,6 @@ export class Transformation { }, }, constructorPropertyName: { - node: { - transformation: 'underscores', - }, gjs: { transformation: 'lowerCamelCase', }, From 57619813c9de9bc166dcf595516964b67b45240d Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 12:04:39 -0700 Subject: [PATCH 09/53] Cleaup unused code in conflict resolver --- packages/lib/src/conflict-resolver.ts | 264 +------------------------- 1 file changed, 2 insertions(+), 262 deletions(-) diff --git a/packages/lib/src/conflict-resolver.ts b/packages/lib/src/conflict-resolver.ts index baaa62276..8c97f6508 100644 --- a/packages/lib/src/conflict-resolver.ts +++ b/packages/lib/src/conflict-resolver.ts @@ -1,7 +1,7 @@ import { GirFactory } from './gir-factory.js' import { Logger } from './logger.js' import { NO_TSDATA } from './messages.js' -import { isEqual, merge, clone, typesContainsOptional } from './utils.js' +import { isEqual } from './utils.js' import { SIGNAL_METHOD_NAMES, MAX_CLASS_PARENT_DEPTH } from './constants.js' import { @@ -24,13 +24,11 @@ import { type TsTypeSeparator, type TsType, type TsClass, - type TsParameter, type TypeGirFunction, type TypeGirProperty, type ConflictChildElement, type ConflictGroupedElements, type ConflictGroupedElement, - GirDirection, } from './types/index.js' /** @@ -45,7 +43,7 @@ export class ConflictResolver { constructor( private readonly environment: Environment, - private readonly verbose: boolean, + verbose: boolean, ) { this.log = new Logger(environment, verbose, 'ConflictResolver') } @@ -214,22 +212,6 @@ export class ConflictResolver { } } - private tsElementIsMethod(el: TsFunction | TsVar) { - return !this.tsElementIsStatic(el) && this.tsElementIsMethodOrFunction(el) - } - - private tsElementIsStaticFunction(el: TsFunction | TsVar) { - return this.tsElementIsStatic(el) && this.tsElementIsMethodOrFunction(el) - } - - private tsElementIsProperty(el: TsFunction | TsVar) { - return !this.tsElementIsStatic(el) && this.tsElementIsPropertyOrVariable(el) - } - - private tsElementIsStaticProperty(el: TsFunction | TsVar) { - return this.tsElementIsStatic(el) && this.tsElementIsPropertyOrVariable(el) - } - private tsElementIsSignal(el: TsFunction | TsVar) { return el.tsTypeName === 'event-methods' } @@ -258,14 +240,6 @@ export class ConflictResolver { ) } - private typeIsString(type: TsType) { - return ( - type.type === 'string' || - (type.type.startsWith("'") && type.type.endsWith("'")) || - (type.type.startsWith('"') && type.type.endsWith('"')) - ) - } - private tsTypeIsEqual(a: TsType, b: TsType) { return ( a && @@ -295,168 +269,6 @@ export class ConflictResolver { return dest } - private setTypesProperty(types: TsType[], property: 'optional', value: boolean) { - for (const type of types) { - type[property] = value - } - return types - } - - /** - * Merges two parameter name and type of two parameters - * @param a - * @param b - * @returns - */ - private mergeParam(a: GirCallableParamElement | undefined, b: GirCallableParamElement | undefined) { - if (!a?._tsData && !b?._tsData) { - throw new Error('At least one parameter must be defined!') - } - - let dest: GirCallableParamElement - - if (a?._tsData && b?._tsData) { - dest = merge({}, clone(a), clone(b)) - if (!dest._tsData) { - throw new Error('Error on merge parameters!') - } - dest._tsData.type = [] - dest._tsData.type = this.mergeTypes('|', ...a._tsData.type, ...b._tsData.type) - if (a._tsData.name !== b._tsData.name) { - dest._tsData.name = `${a._tsData.name}_or_${b._tsData.name}` - } - } else { - dest = clone((a || b) as GirCallableParamElement) - if (!dest._tsData) { - throw new Error('Error on merge parameters!') - } - // If `a` or `b` is undefined make the types optional - dest._tsData.type = this.setTypesProperty(dest._tsData.type, 'optional', true) - } - - if (typesContainsOptional(dest._tsData.type)) { - dest._tsData.type = this.setTypesProperty(dest._tsData.type, 'optional', true) - } - - return dest - } - - /** - * Merges parameter names and types of multiple functions - * @param params - * @returns - */ - private mergeParams(...params: GirCallableParamElement[][]) { - let dest: GirCallableParamElement[] = [] - - for (const a of params) { - for (const b of params) { - if (a === b) { - continue - } - if (isEqual(a, b)) { - dest = clone(a) - } else { - const length = Math.max(a.length, b.length) - dest = new Array(length) - for (let i = 0; i < length; i++) { - const aParam = a[i] as GirCallableParamElement | undefined - const bParam = b[i] as GirCallableParamElement | undefined - dest[i] = this.mergeParam(aParam, bParam) - } - } - } - } - - return dest - } - - private paramCanBeOptional( - girParam: GirCallableParamElement, - girParams: GirCallableParamElement[], - skip: GirCallableParamElement[] = [], - ) { - if (!girParam._tsData) return false - let canBeOptional = true - const index = girParams.indexOf(girParam) - const following = girParams - .slice(index) - .filter((p) => !!p._tsData) - .filter(() => !skip.includes(girParam)) - .filter((p) => p.$.direction !== GirDirection.Out) - .map((p) => p._tsData) - - if (following.some((p) => p && !typesContainsOptional(p.type))) { - canBeOptional = false - } - - return canBeOptional - } - - /** - * In Typescript no optional parameters are allowed if the following ones are not optional - * @param girParams - * @returns - */ - private fixOptionalParameters(girParams: GirCallableParamElement[]) { - for (const girParam of girParams) { - if (!girParam._tsData) throw new Error(NO_TSDATA('fixOptionalParameters')) - if (typesContainsOptional(girParam._tsData.type) && !this.paramCanBeOptional(girParam, girParams)) { - this.setTypesProperty(girParam._tsData.type, 'optional', false) - } - } - return girParams - } - - /** - * Merge function types and parameters together - * @param baseFunc The function to change or null if you want to create a new property - * @param funcs The functions you want to merge - * @returns - */ - public mergeFunctions(baseFunc: TsFunction | null, ...funcs: TsFunction[]) { - const returnTypesMap: TsType[] = [] - for (const func of funcs) { - returnTypesMap.push(...func.returnTypes) - } - const returnTypes = this.mergeTypes('|', ...returnTypesMap) - - const inParamsMap = funcs.map((func) => func.inParams) - const inParams: GirCallableParamElement[] = [] - if (this.paramsHasConflict(...inParamsMap)) { - inParams.push(...this.mergeParams(...inParamsMap)) - } - - const outParamsMap = funcs.map((func) => func.outParams) - const outParams: GirCallableParamElement[] = [] - if (this.paramsHasConflict(...outParamsMap)) { - outParams.push(...this.mergeParams(...outParamsMap)) - } - - if (!funcs[0]) { - throw new Error('At least one function must exist!') - } - - if (baseFunc) { - baseFunc.returnTypes = returnTypes - return baseFunc - } - - return this.girFactory.newTsFunction( - { - name: funcs[0].name, - returnTypes: returnTypes, - isStatic: funcs[0].isStatic || false, - inParams: inParams.map((inParam) => inParam._tsData).filter((inParam) => !!inParam) as TsParameter[], - outParams: outParams - .map((outParam) => outParam._tsData) - .filter((outParam) => !!outParam) as TsParameter[], - girTypeName: funcs[0].girTypeName, - }, - funcs[0].parent, - ) - } - /** * Merge property types together * @param baseProp The property to change or null if you want to create a new property @@ -578,78 +390,6 @@ export class ConflictResolver { return canAdd } - public groupSignalConflicts(signalsMethods: ConflictChildElement[], baseClass: TsClass) { - const groupedConflicts: ConflictGroupedElements = {} - for (const base of signalsMethods) { - for (const b of signalsMethods) { - if (base === b) { - continue - } - - if (base.data.name !== 'connect' && base.data.name !== 'connect_after') { - continue - } - - const sigNameParam = base.data.inParams[0] - // const callbackParam = base.data.inParams[1] - - const eventName = sigNameParam?._tsData?.type?.[0]?.type - // TODO do not render the callback type as a full string, create a TSCallback instead - // const callbackType = callbackParam?._tsData?.type?.[0]?.type - // console.debug('eventName', eventName, callbackType) - - if (!eventName || eventName === 'string') { - continue - } - groupedConflicts[eventName] ||= { - baseElements: [], - inheritedElements: [], - baseClass, - } - - const groupedConflict = groupedConflicts[eventName] - const isBaseElement = base.depth === 0 - if (isBaseElement) { - if (!groupedConflict.baseElements.find((c) => isEqual(c.data, base.data))) { - groupedConflict.baseElements.push(base) - } - } else { - if (!groupedConflict.inheritedElements.find((c) => isEqual(c.data, base.data))) { - groupedConflict.inheritedElements.push(base) - } - } - } - } - - return groupedConflicts - } - - public fixSignalConflicts(groupedElements: ConflictGroupedElements) { - for (const eventName of Object.keys(groupedElements)) { - const elements = groupedElements[eventName] - - const bases = elements.baseElements - - if (!bases.length) { - // TODO - // return this.fixIndirectSignalConflicts(elements.inheritedElements, elements.baseClass) - return - } - - for (const base of bases) { - if (base.data.hasUnresolvedConflict) { - continue - } - for (const b of elements.inheritedElements) { - if (b === base || b.data.hasUnresolvedConflict) { - continue - } - // TODO - } - } - } - } - /** * Check conflicts between the implementations / inheritances * To fix type errors like: From d8a1d88a3dfc506b95cb3f5b3cb3bd61f5311076 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 4 Nov 2023 15:22:45 -0700 Subject: [PATCH 10/53] Adapt @gi.ts/lib codebase to ts-for-gir coding conventions --- packages/lib/src/newlib/.eslintrc.cjs | 26 + packages/lib/src/newlib/.prettierrc.json | 9 + packages/lib/src/newlib/formatters/default.ts | 6 +- .../lib/src/newlib/formatters/formatter.ts | 2 +- packages/lib/src/newlib/formatters/json.ts | 6 +- .../lib/src/newlib/generators/dts-inline.ts | 116 +- .../lib/src/newlib/generators/dts-modules.ts | 186 +- packages/lib/src/newlib/generators/dts.ts | 1359 +++++---- packages/lib/src/newlib/generators/dts/gio.ts | 5 +- .../lib/src/newlib/generators/dts/glib.ts | 12 +- .../lib/src/newlib/generators/dts/gobject.ts | 42 +- .../lib/src/newlib/generators/generator.ts | 70 +- packages/lib/src/newlib/generators/index.ts | 4 +- packages/lib/src/newlib/generators/json.ts | 2236 +++++++------- packages/lib/src/newlib/generics/clutter.ts | 94 +- packages/lib/src/newlib/generics/generify.ts | 50 +- packages/lib/src/newlib/generics/gio.ts | 94 +- packages/lib/src/newlib/generics/glib.ts | 28 +- packages/lib/src/newlib/generics/meta.ts | 32 +- packages/lib/src/newlib/generics/st.ts | 210 +- packages/lib/src/newlib/generics/visitor.ts | 617 ++-- packages/lib/src/newlib/gir.ts | 1081 ++++--- packages/lib/src/newlib/gir/alias.ts | 106 +- packages/lib/src/newlib/gir/base.ts | 108 +- packages/lib/src/newlib/gir/class.ts | 2698 +++++++++-------- packages/lib/src/newlib/gir/const.ts | 114 +- packages/lib/src/newlib/gir/enum.ts | 399 ++- packages/lib/src/newlib/gir/function.ts | 1636 +++++----- packages/lib/src/newlib/gir/generics.ts | 100 +- packages/lib/src/newlib/gir/namespace.ts | 912 +++--- packages/lib/src/newlib/gir/nodes.ts | 24 +- packages/lib/src/newlib/gir/property.ts | 357 +-- packages/lib/src/newlib/gir/registry.ts | 388 +-- packages/lib/src/newlib/gir/signal.ts | 414 +-- packages/lib/src/newlib/gir/util.ts | 990 +++--- packages/lib/src/newlib/injections/gio.ts | 850 +++--- packages/lib/src/newlib/injections/glib.ts | 455 ++- packages/lib/src/newlib/injections/gobject.ts | 1096 +++---- packages/lib/src/newlib/injections/inject.ts | 16 +- packages/lib/src/newlib/lib.ts | 82 +- packages/lib/src/newlib/types.ts | 60 +- packages/lib/src/newlib/util.ts | 94 +- packages/lib/src/newlib/validators/class.ts | 295 +- .../lib/src/newlib/validators/interface.ts | 12 +- packages/lib/src/newlib/visitor.ts | 66 +- .../lib/src/types/gir-interface-element.ts | 2 +- packages/parser/src/xml.ts | 4 +- 47 files changed, 8859 insertions(+), 8704 deletions(-) create mode 100644 packages/lib/src/newlib/.eslintrc.cjs create mode 100644 packages/lib/src/newlib/.prettierrc.json diff --git a/packages/lib/src/newlib/.eslintrc.cjs b/packages/lib/src/newlib/.eslintrc.cjs new file mode 100644 index 000000000..5f4fa1024 --- /dev/null +++ b/packages/lib/src/newlib/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "extends": [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + "rules": { + "semi": ["error", "always"], + "quotes": ["error", "double", {avoidEscape: true}], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + "camelcase": "off", + "@typescript-eslint/camelcase": "off" + }, + "parserOptions": { + "tsconfigRootDir": __dirname, + "project": ["../../tsconfig.json"] + }, + "globals": { + "imports": true + } +} diff --git a/packages/lib/src/newlib/.prettierrc.json b/packages/lib/src/newlib/.prettierrc.json new file mode 100644 index 000000000..cec7730e5 --- /dev/null +++ b/packages/lib/src/newlib/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "semi": true, + "trailingComma": "none", + "arrowParens": "avoid", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 + } + \ No newline at end of file diff --git a/packages/lib/src/newlib/formatters/default.ts b/packages/lib/src/newlib/formatters/default.ts index d0f6a4d1b..fe08c4415 100644 --- a/packages/lib/src/newlib/formatters/default.ts +++ b/packages/lib/src/newlib/formatters/default.ts @@ -1,7 +1,7 @@ import { Formatter } from "./formatter.js"; export class DefaultFormatter extends Formatter { - format(source: string): string { - return source; - } + format(source: string): string { + return source; + } } diff --git a/packages/lib/src/newlib/formatters/formatter.ts b/packages/lib/src/newlib/formatters/formatter.ts index dc9cb743f..ee7c36d4b 100644 --- a/packages/lib/src/newlib/formatters/formatter.ts +++ b/packages/lib/src/newlib/formatters/formatter.ts @@ -1,3 +1,3 @@ export abstract class Formatter { - abstract format(source: string): string; + abstract format(source: string): string; } diff --git a/packages/lib/src/newlib/formatters/json.ts b/packages/lib/src/newlib/formatters/json.ts index af58ec037..f38765413 100644 --- a/packages/lib/src/newlib/formatters/json.ts +++ b/packages/lib/src/newlib/formatters/json.ts @@ -1,7 +1,7 @@ import { Formatter } from "./formatter.js"; export class JSONFormatter extends Formatter { - format(source: string): string { - return JSON.stringify(JSON.parse(source), null, 4); - } + format(source: string): string { + return JSON.stringify(JSON.parse(source), null, 4); + } } diff --git a/packages/lib/src/newlib/generators/dts-inline.ts b/packages/lib/src/newlib/generators/dts-inline.ts index 7d674cf35..54c44c80d 100644 --- a/packages/lib/src/newlib/generators/dts-inline.ts +++ b/packages/lib/src/newlib/generators/dts-inline.ts @@ -9,79 +9,79 @@ import { override as overrideGio } from "./dts/gio.js"; import { DtsGenerator } from "./dts.js"; export class DtsInlineGenerator extends DtsGenerator { - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { - super(namespace, options); - } + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + super(namespace, options); + } - async generateNamespace(node: IntrospectedNamespace): Promise { - const { namespace, options } = this; + generateNamespace(node: IntrospectedNamespace): Promise { + const { namespace, options } = this; - if (options.verbose) { - console.debug(`Resolving the types of ${namespace.name}...`); - } + if (options.verbose) { + console.debug(`Resolving the types of ${namespace.name}...`); + } - let suffix = ""; + let suffix = ""; - if (!options.noAdvancedVariants && node.name === "GLib") { - suffix = `\n${overrideGLib(node)}\n`; - } else if (node.name === "GObject") { - suffix = `\n${overrideGObject(node)}\n`; - } else if (node.name === "Gio") { - suffix = `\n${overrideGio(node)}\n`; - } + if (!options.noAdvancedVariants && node.name === "GLib") { + suffix = `\n${overrideGLib(node)}\n`; + } else if (node.name === "GObject") { + suffix = `\n${overrideGObject(node)}\n`; + } else if (node.name === "Gio") { + suffix = `\n${overrideGio(node)}\n`; + } - try { - const { name } = node; + try { + const { name } = node; - const header = ` + const header = ` /** * ${name} ${node.version} * * Generated from ${node.package_version.join(".")} */ `; - const base = ` + const base = ` `; - if (options.promisify) { - promisifyNamespaceFunctions(node); - } - - const content = Array.from(node.members.values()) - .map(m => { - return `${(Array.isArray(m) ? m : [m]) - .map(m => (m.emit ? (m as GirBase).asString(this) : "")) - .join(`\n`)}`; - }) - .join(`\n`); - - // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. - const imports = Array.from(node.getImports()) - .map( - ([i, version]) => - `import * as ${i} from "${options.importPrefix}${i.toLowerCase()}${ - options.versionedImports ? version.toLowerCase().split(".")[0] : "" - }";` - ) - .join(`${`\n`}`); - - const output = [header, imports, base, content, suffix].join(`\n\n`); - - if (options.verbose) { - console.debug(`Printing ${namespace.name}...`); - } - - return output; - } catch (err) { - console.error(`Failed to generate namespace: ${node.name}`); - console.error(err); - - return null; + if (options.promisify) { + promisifyNamespaceFunctions(node); + } + + const content = Array.from(node.members.values()) + .map(m => { + return `${(Array.isArray(m) ? m : [m]) + .map(m => (m.emit ? (m as GirBase).asString(this) : "")) + .join("\n")}`; + }) + .join("\n"); + + // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. + const imports = Array.from(node.getImports()) + .map( + ([i, version]) => + `import * as ${i} from "${options.importPrefix}${i.toLowerCase()}${ + options.versionedImports ? version.toLowerCase().split(".")[0] : "" + }";` + ) + .join(`${"\n"}`); + + const output = [header, imports, base, content, suffix].join("\n\n"); + + if (options.verbose) { + console.debug(`Printing ${namespace.name}...`); + } + + return Promise.resolve(output); + } catch (err) { + console.error(`Failed to generate namespace: ${node.name}`); + console.error(err); + + return Promise.resolve(null); + } } - } - async stringifyNamespace(node: IntrospectedNamespace): Promise { - return this.generateNamespace(node); - } + async stringifyNamespace(node: IntrospectedNamespace): Promise { + return this.generateNamespace(node); + } } diff --git a/packages/lib/src/newlib/generators/dts-modules.ts b/packages/lib/src/newlib/generators/dts-modules.ts index 7a6696295..9f41ba6e5 100644 --- a/packages/lib/src/newlib/generators/dts-modules.ts +++ b/packages/lib/src/newlib/generators/dts-modules.ts @@ -1,7 +1,6 @@ import { IntrospectedNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; -import { - GirBase } from "../gir.js"; +import { GirBase } from "../gir.js"; import { GenerationOptions } from "../types.js"; import { override as overrideGLib } from "./dts/glib.js"; @@ -10,75 +9,80 @@ import { override as overrideGio } from "./dts/gio.js"; import { DtsGenerator, versionImportFormat } from "./dts.js"; export class DtsModuleGenerator extends DtsGenerator { - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { - super(namespace, options); - } + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + super(namespace, options); + } + generateNamespace(node: IntrospectedNamespace): Promise { + const { namespace, options } = this; - async generateNamespace(node: IntrospectedNamespace): Promise { - const { namespace, options } = this; + if (options.verbose) { + console.debug(`Resolving the types of ${namespace.name}...`); + } - if (options.verbose) { - console.debug(`Resolving the types of ${namespace.name}...`); - } + let suffix = ""; - let suffix = ""; + if (!options.noAdvancedVariants && node.name === "GLib") { + suffix = `\n${overrideGLib(node)}\n`; + } else if (node.name === "GObject") { + suffix = `\n${overrideGObject(node)}\n`; + } else if (node.name === "Gio") { + suffix = `\n${overrideGio(node)}\n`; + } - if (!options.noAdvancedVariants && node.name === "GLib") { - suffix = `\n${overrideGLib(node)}\n`; - } else if (node.name === "GObject") { - suffix = `\n${overrideGObject(node)}\n`; - } else if (node.name === "Gio") { - suffix = `\n${overrideGio(node)}\n`; - } + try { + const { name } = node; - try { - const { name } = node; - - const header = ` + const header = ` /** * ${name} ${node.version} * * Generated from ${node.package_version.join(".")} */ `; - const base = ` + const base = ` `; - if (options.promisify) { - promisifyNamespaceFunctions(node); - } - - const content = Array.from(node.members.values()) - .map(m => { - return `${(Array.isArray(m) ? m : [m]) - .map(m => (m.emit ? (m as GirBase).asString(this) : "")) - .join(`\n`)}`; - }) - .join(`\n`); - - const pathSuffix = options.outputFormat === "folder" ? "/index.d.ts" : ".d.ts"; - const referenceType = options.importPrefix.startsWith(".") ? "path" : "types"; - const references = [ - ...(node.__dts__references ?? []), - ...Array.from(node.getImports()).map( - ([i, version]) => - `/// ` - ) - ].join(`\n`); - - // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. - const imports = Array.from(node.getImports()) - .map( - ([i, version]) => - `import ${i} from 'gi://${i}${options.versionedImports ? `?version=${version}` : ""}';` - ) - .join(`\n`); - - const metadata = ` + if (options.promisify) { + promisifyNamespaceFunctions(node); + } + + const content = Array.from(node.members.values()) + .map(m => { + return `${(Array.isArray(m) ? m : [m]) + .map(m => (m.emit ? (m as GirBase).asString(this) : "")) + .join("\n")}`; + }) + .join("\n"); + + const pathSuffix = options.outputFormat === "folder" ? "/index.d.ts" : ".d.ts"; + const referenceType = options.importPrefix.startsWith(".") ? "path" : "types"; + const references = [ + ...(node.__dts__references ?? []), + ...Array.from(node.getImports()).map( + ([i, version]) => + `/// ` + ) + ].join("\n"); + + // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. + const imports = Array.from(node.getImports()) + .map( + ([i, version]) => + `import ${i} from 'gi://${i}${options.versionedImports ? `?version=${version}` : ""}';` + ) + .join("\n"); + + const metadata = ` /** * Name of the imported GIR library * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188 @@ -91,49 +95,49 @@ export const __name__: string; export const __version__: string; `; - const moduleIdentifier = `gi://${name}`; - const versionedNamespaceIdentifier = `${name}${node.version.split('.')[0].replace(/[^A-z0-9_]/g, '_')}`; - const versionedModuleIdentifier = `${moduleIdentifier}?version=${node.version}`; + const moduleIdentifier = `gi://${name}`; + const versionedNamespaceIdentifier = `${name}${node.version.split(".")[0].replace(/[^A-z0-9_]/g, "_")}`; + const versionedModuleIdentifier = `${moduleIdentifier}?version=${node.version}`; - const [versionedModuleHeader, versionedModuleSuffix] = [ - `declare module "${versionedModuleIdentifier}" { + const [versionedModuleHeader, versionedModuleSuffix] = [ + `declare module "${versionedModuleIdentifier}" { namespace ${versionedNamespaceIdentifier} {`, - `}; + `}; export default ${versionedNamespaceIdentifier}; }` - ]; - const moduleDefinition = `declare module "${moduleIdentifier}" { + ]; + const moduleDefinition = `declare module "${moduleIdentifier}" { export * from "${versionedModuleIdentifier}"; }`; - const output = [ - references, - header, - versionedModuleHeader, - imports, - base, - content, - suffix, - metadata, - versionedModuleSuffix, - moduleDefinition - ].join(`\n\n`); - - if (options.verbose) { - console.debug(`Printing ${namespace.name}...`); - } - - return output; - } catch (err) { - console.error(`Failed to generate namespace: ${node.name}`); - console.error(err); - - return null; + const output = [ + references, + header, + versionedModuleHeader, + imports, + base, + content, + suffix, + metadata, + versionedModuleSuffix, + moduleDefinition + ].join("\n\n"); + + if (options.verbose) { + console.debug(`Printing ${namespace.name}...`); + } + + return Promise.resolve(output); + } catch (err) { + console.error(`Failed to generate namespace: ${node.name}`); + console.error(err); + + return Promise.resolve(null); + } } - } - async stringifyNamespace(node: IntrospectedNamespace): Promise { - return this.generateNamespace(node); - } + async stringifyNamespace(node: IntrospectedNamespace): Promise { + return this.generateNamespace(node); + } } diff --git a/packages/lib/src/newlib/generators/dts.ts b/packages/lib/src/newlib/generators/dts.ts index 56e6e2be4..fc6de3947 100644 --- a/packages/lib/src/newlib/generators/dts.ts +++ b/packages/lib/src/newlib/generators/dts.ts @@ -2,874 +2,895 @@ import { FormatGenerator } from "./generator.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; import { - IntrospectedBaseClass, - GirRecord, - GirInterface, - IntrospectedClass, - filterConflicts, - filterFunctionConflict, - FilterBehavior, - promisifyFunctions + IntrospectedBaseClass, + IntrospectedRecord, + IntrospectedInterface, + IntrospectedClass, + filterConflicts, + filterFunctionConflict, + FilterBehavior, + promisifyFunctions } from "../gir/class.js"; import { IntrospectedConstant } from "../gir/const.js"; import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; import { GirProperty, Field } from "../gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; -import { IntrospectedFunction, IntrospectedConstructor, IntrospectedFunctionParameter, IntrospectedCallback, IntrospectedDirectAllocationConstructor } from "../gir/function.js"; -import { IntrospectedClassFunction, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction } from "../gir/function.js"; +import { + IntrospectedFunction, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedCallback, + IntrospectedDirectAllocationConstructor +} from "../gir/function.js"; +import { + IntrospectedClassFunction, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction +} from "../gir/function.js"; import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js"; import { - TypeExpression, - NativeType, - AnyType, - VoidType, - StringType, - NumberType, - ArrayType, - AnyFunctionType, - Generic, - ConflictType, - TypeConflict, - BinaryType, - GirBase + TypeExpression, + NativeType, + AnyType, + VoidType, + StringType, + NumberType, + ArrayType, + AnyFunctionType, + Generic, + ConflictType, + TypeConflict, + BinaryType, + GirBase } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedAlias } from "../gir/alias.js"; import { GenerationOptions } from "../types.js"; export function versionImportFormat(versionFormat: string, namespace: string, version: string) { - const versionSlug = version.toLowerCase().split(".")[0]; - const namespaceLowercase = namespace.toLowerCase(); - - return `${versionFormat.replace('{version}', version).replace('{version-slug}', versionSlug).replace('{namespace}', namespace).replace('{namespace-lower}', namespaceLowercase)}`; + const versionSlug = version.toLowerCase().split(".")[0]; + const namespaceLowercase = namespace.toLowerCase(); + + return `${versionFormat + .replace("{version}", version) + .replace("{version-slug}", versionSlug) + .replace("{namespace}", namespace) + .replace("{namespace-lower}", namespaceLowercase)}`; } export abstract class DtsGenerator extends FormatGenerator { - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { - super(namespace, options); - } - - protected generateParameters(parameters: IntrospectedFunctionParameter[]): string { - return parameters - .map(p => { - return p.asString(this); - }) - .join(", "); - } - - generateGenerics(nodes: Generic[], withDefaults = true) { - const { namespace, options } = this; - - const list = nodes.map(generic => { - const Type = generic.type.rootPrint(namespace, options); - - if (generic.defaultType && withDefaults) { - let defaultType = generic.defaultType.rootPrint(namespace, options); - - if (generic.constraint) { - let constraint = generic.constraint.rootPrint(namespace, options); - return `${Type} extends ${constraint} = ${defaultType}`; - } - - return `${Type} = ${defaultType}`; - } else if (generic.constraint && withDefaults) { - let constraint = generic.constraint.rootPrint(namespace, options); - return `${Type} extends ${constraint}`; - } else { - return `${Type}`; - } - }); + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + super(namespace, options); + } - if (list.length > 0) { - return `<${list.join(", ")}>`; + protected generateParameters(parameters: IntrospectedFunctionParameter[]): string { + return parameters + .map(p => { + return p.asString(this); + }) + .join(", "); } - return ""; - } + generateGenerics(nodes: Generic[], withDefaults = true) { + const { namespace, options } = this; - generateCallbackType(node: IntrospectedCallback): [string, string] { - const { namespace, options } = this; + const list = nodes.map(generic => { + const Type = generic.type.rootPrint(namespace, options); - const Parameters = this.generateParameters(node.parameters); + if (generic.defaultType && withDefaults) { + const defaultType = generic.defaultType.rootPrint(namespace, options); - if (node.generics.length > 0) { - const GenericDefinitions = this.generateGenerics(node.generics); + if (generic.constraint) { + const constraint = generic.constraint.rootPrint(namespace, options); + return `${Type} extends ${constraint} = ${defaultType}`; + } - return [ - `${GenericDefinitions}`, - `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}` - ]; - } - return [``, `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`]; - } - - generateCallback(node: IntrospectedCallback): string { - return `${this.docString(node)}export type ${node.name}${this.generateCallbackType(node).join(" = ")};`; - } - - generateReturn(return_type: TypeExpression, output_parameters: IntrospectedFunctionParameter[]) { - const { namespace, options } = this; - - let resolved_return_type = - resolveDirectedType(return_type, GirDirection.Out)?.resolve(namespace, options) ?? - return_type.resolve(namespace, options); - - const type = resolved_return_type.rootPrint(namespace, options); - - if (output_parameters.length > 0) { - const exclude_first = type === "void" || type === ""; - const returns = [ - ...(exclude_first ? [] : [`${type}`]), - ...output_parameters - .map(op => { - return ( - resolveDirectedType(op.type, GirDirection.Out)?.resolve(namespace, options) ?? - op.type.resolve(namespace, options) - ); - }) - .map(p => p.rootPrint(namespace, options)) - ]; - if (returns.length > 1) { - return `[${returns.join(", ")}]`; - } else { - return `${returns[0]}`; - } + return `${Type} = ${defaultType}`; + } else if (generic.constraint && withDefaults) { + const constraint = generic.constraint.rootPrint(namespace, options); + return `${Type} extends ${constraint}`; + } else { + return `${Type}`; + } + }); + + if (list.length > 0) { + return `<${list.join(", ")}>`; + } + + return ""; } - return type; - } + generateCallbackType(node: IntrospectedCallback): [string, string] { + const { namespace, options } = this; + + const Parameters = this.generateParameters(node.parameters); + + if (node.generics.length > 0) { + const GenericDefinitions = this.generateGenerics(node.generics); - generateEnum(node: IntrospectedEnum): string { - const { namespace } = this; + return [ + `${GenericDefinitions}`, + `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}` + ]; + } + return ["", `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`]; + } + + generateCallback(node: IntrospectedCallback): string { + return `${this.docString(node)}export type ${node.name}${this.generateCallbackType(node).join(" = ")};`; + } - const isInvalidEnum = Array.from(node.members.keys()).some( - name => name.match(/^[0-9]+$/) || name === "NaN" || name === "Infinity" - ); + generateReturn(return_type: TypeExpression, output_parameters: IntrospectedFunctionParameter[]) { + const { namespace, options } = this; + + const resolved_return_type = + resolveDirectedType(return_type, GirDirection.Out)?.resolve(namespace, options) ?? + return_type.resolve(namespace, options); + + const type = resolved_return_type.rootPrint(namespace, options); + + if (output_parameters.length > 0) { + const exclude_first = type === "void" || type === ""; + const returns = [ + ...(exclude_first ? [] : [`${type}`]), + ...output_parameters + .map(op => { + return ( + resolveDirectedType(op.type, GirDirection.Out)?.resolve(namespace, options) ?? + op.type.resolve(namespace, options) + ); + }) + .map(p => p.rootPrint(namespace, options)) + ]; + if (returns.length > 1) { + return `[${returns.join(", ")}]`; + } else { + return `${returns[0]}`; + } + } - if (isInvalidEnum) { - return node.asClass().asString(this); + return type; } - // So we can use GObject.GType - this.namespace.assertInstalledImport("GObject"); + generateEnum(node: IntrospectedEnum): string { + const { namespace } = this; + + const isInvalidEnum = Array.from(node.members.keys()).some( + name => name.match(/^[0-9]+$/) || name === "NaN" || name === "Infinity" + ); - return ` + if (isInvalidEnum) { + return node.asClass().asString(this); + } + + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); + + return ` export namespace ${node.name} { export const $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${node.name}>; } ${this.docString(node)}export enum ${node.name} { ${Array.from(node.members.values()) - .map(member => `${member.asString(this)}`) - .join(`\n `)} + .map(member => `${member.asString(this)}`) + .join("\n ")} }`; - } + } - generateError(node: IntrospectedError): string { - const { namespace } = this; - const clazz = node.asClass(); + generateError(node: IntrospectedError): string { + const { namespace } = this; + const clazz = node.asClass(); - clazz.members = []; - clazz.members.push(...Array.from(node.functions.values())); + clazz.members = []; + clazz.members.push(...Array.from(node.functions.values())); - const GLib = namespace.assertInstalledImport("GLib"); - const GLibError = GLib.assertClass("Error"); + const GLib = namespace.assertInstalledImport("GLib"); + const GLibError = GLib.assertClass("Error"); - clazz.parent = GLibError.getType(); + clazz.parent = GLibError.getType(); - // Manually construct a GLib.Error constructor. - clazz.mainConstructor = new IntrospectedConstructor({ - name: "new", - parameters: [ - new IntrospectedFunctionParameter({ - name: "options", - type: NativeType.of("{ message: string, code: number}"), - direction: GirDirection.In - }) - ], - return_type: clazz.getType() - }); + // Manually construct a GLib.Error constructor. + clazz.mainConstructor = new IntrospectedConstructor({ + name: "new", + parameters: [ + new IntrospectedFunctionParameter({ + name: "options", + type: NativeType.of("{ message: string, code: number}"), + direction: GirDirection.In + }) + ], + return_type: clazz.getType() + }); - return clazz.asString(this); - } + return clazz.asString(this); + } - generateConst(node: IntrospectedConstant): string { - const { namespace, options } = this; + generateConst(node: IntrospectedConstant): string { + const { namespace, options } = this; - return `${this.docString(node)}export const ${node.name}: ${node.type.resolve(namespace, options).print(namespace, options)};`; - } + return `${this.docString(node)}export const ${node.name}: ${node.type + .resolve(namespace, options) + .print(namespace, options)};`; + } - protected implements(node: IntrospectedClass) { - const { namespace, options } = this; + protected implements(node: IntrospectedClass) { + const { namespace, options } = this; - const interfaces = node.interfaces.map(i => { - const identifier = i.resolveIdentifier(namespace, options); + const interfaces = node.interfaces.map(i => { + const identifier = i.resolveIdentifier(namespace, options); - if (!identifier) { - throw new Error( - `Unable to resolve type: ${i.name} from ${i.namespace} in ${node.namespace.name} ${node.namespace.version}` - ); - } + if (!identifier) { + throw new Error( + `Unable to resolve type: ${i.name} from ${i.namespace} in ${node.namespace.name} ${node.namespace.version}` + ); + } - return identifier; - }); + return identifier; + }); - if (interfaces.length > 0) { - return ` implements ${interfaces - .map(i => { - const Type = i.print(namespace, options); - return `${Type}`; - }) - .join(", ")}`; + if (interfaces.length > 0) { + return ` implements ${interfaces + .map(i => { + const Type = i.print(namespace, options); + return `${Type}`; + }) + .join(", ")}`; + } + + return ""; } - return ""; - } + protected extends(node: IntrospectedBaseClass) { + const { namespace: ns, options } = this; + if (node.parent) { + const ResolvedType = node.parent.resolveIdentifier(ns, options); + const Type = ResolvedType?.print(ns, options); - protected extends(node: IntrospectedBaseClass) { - const { namespace: ns, options } = this; - if (node.parent) { - const ResolvedType = node.parent.resolveIdentifier(ns, options); - const Type = ResolvedType?.print(ns, options); + if (Type) { + return ` extends ${Type}`; + } - if (Type) { - return ` extends ${Type}`; - } + throw new Error( + `Unable to resolve type: ${node.parent.name} from ${node.parent.namespace} in ${node.namespace.name} ${node.namespace.version}` + ); + } - throw new Error( - `Unable to resolve type: ${node.parent.name} from ${node.parent.namespace} in ${node.namespace.name} ${node.namespace.version}` - ); + return ""; } - return ""; - } - - generateInterface(node: GirInterface): string { - const { namespace, options } = this; + generateInterface(node: IntrospectedInterface): string { + const { namespace, options } = this; - const isGObject = node.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); + const isGObject = node.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); - const name = node.name; + const name = node.name; - let generics = node.generics; + const generics = node.generics; - let Generics = ""; - let GenericTypes = ""; - - if (generics.length > 0) { - Generics = `${this.generateGenerics(generics)}`; - GenericTypes = `${this.generateGenerics(generics, false)}`; - } + let Generics = ""; + let GenericTypes = ""; - const Extends = this.extends(node); - const filteredFunctions = filterFunctionConflict(node.namespace, node, node.members, []); - const functions = options.promisify ? promisifyFunctions(filteredFunctions) : filteredFunctions; + if (generics.length > 0) { + Generics = `${this.generateGenerics(generics)}`; + GenericTypes = `${this.generateGenerics(generics, false)}`; + } - const staticFunctions = functions.filter(f => f instanceof IntrospectedStaticClassFunction); - const staticFields = node.fields - .filter(f => f.isStatic) - .map(f => - f.copy({ - isStatic: false - }) - ); + const Extends = this.extends(node); + const filteredFunctions = filterFunctionConflict(node.namespace, node, node.members, []); + const functions = options.promisify ? promisifyFunctions(filteredFunctions) : filteredFunctions; + + const staticFunctions = functions.filter(f => f instanceof IntrospectedStaticClassFunction); + const staticFields = node.fields + .filter(f => f.isStatic) + .map(f => + f.copy({ + isStatic: false + }) + ); - const nonStaticFunctions = functions.filter(f => !(f instanceof IntrospectedStaticClassFunction)); - const nonStaticFields = node.fields.filter(f => !f.isStatic); + const nonStaticFunctions = functions.filter(f => !(f instanceof IntrospectedStaticClassFunction)); + const nonStaticFields = node.fields.filter(f => !f.isStatic); - const hasNamespace = isGObject || staticFunctions.length > 0 || node.callbacks.length > 0; + const hasNamespace = isGObject || staticFunctions.length > 0 || node.callbacks.length > 0; - if (isGObject) { - // So we can use GObject.GType - this.namespace.assertInstalledImport("GObject"); - } + if (isGObject) { + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); + } - return ` + return ` ${ - node.callbacks.length > 0 - ? `export module ${name} { - ${node.callbacks.map(c => c.asString(this)).join(`\n`)} + node.callbacks.length > 0 + ? `export module ${name} { + ${node.callbacks.map(c => c.asString(this)).join("\n")} }` - : "" + : "" } ${ - hasNamespace - ? `${this.docString(node)}export interface ${name}Namespace { + hasNamespace + ? `${this.docString(node)}export interface ${name}Namespace { ${isGObject ? `$gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>;` : ""} prototype: ${name}Prototype; - ${staticFields.length > 0 ? staticFields.map(sf => sf.asString(this)).join(`\n`) : ""} + ${staticFields.length > 0 ? staticFields.map(sf => sf.asString(this)).join("\n") : ""} ${ - staticFunctions.length > 0 - ? staticFunctions.map(sf => IntrospectedClassFunction.prototype.asString.call(sf, this)).join(`\n`) - : "" + staticFunctions.length > 0 + ? staticFunctions.map(sf => IntrospectedClassFunction.prototype.asString.call(sf, this)).join("\n") + : "" } }` - : "" + : "" } export type ${name}${Generics} = ${name}Prototype${GenericTypes}; -export interface ${name}Prototype${Generics}${Extends} {${ - node.indexSignature ? `\n${node.indexSignature}\n` : "" - } - ${node.props.length > 0 ? `// Properties` : ""} +export interface ${name}Prototype${Generics}${Extends} {${node.indexSignature ? `\n${node.indexSignature}\n` : ""} + ${node.props.length > 0 ? "// Properties" : ""} ${filterConflicts(node.namespace, node, node.props) - .map(p => p.asString(this)) - .join(`\n`)} - ${nonStaticFields.length > 0 ? `// Fields` : ""} + .map(p => p.asString(this)) + .join("\n")} + ${nonStaticFields.length > 0 ? "// Fields" : ""} ${filterConflicts(node.namespace, node, nonStaticFields) - .map(p => p.asString(this)) - .join(`\n`)} - ${nonStaticFunctions.length > 0 ? `// Members\n` : ""} - ${nonStaticFunctions.map(m => m.asString(this)).join(`\n`)} + .map(p => p.asString(this)) + .join("\n")} + ${nonStaticFunctions.length > 0 ? "// Members\n" : ""} + ${nonStaticFunctions.map(m => m.asString(this)).join("\n")} }${hasNamespace ? `\n\nexport const ${name}: ${name}Namespace;\n` : ""}`; - } + } - generateRecord(node: GirRecord): string { - const { options, namespace } = this; + generateRecord(node: IntrospectedRecord): string { + const { options, namespace } = this; - const { name } = node; + const { name } = node; - const Extends = this.extends(node); + const Extends = this.extends(node); - let Generics = ""; + let Generics = ""; - if (node.generics.length > 0) { - Generics = `${this.generateGenerics(node.generics)}`; - } + if (node.generics.length > 0) { + Generics = `${this.generateGenerics(node.generics)}`; + } - let MainConstructor: string = ""; + let MainConstructor: string = ""; - if (node.isForeign()) { - MainConstructor = ""; - } else if (node.mainConstructor) { - MainConstructor = node.mainConstructor.asString(this); - } + if (node.isForeign()) { + MainConstructor = ""; + } else if (node.mainConstructor) { + MainConstructor = node.mainConstructor.asString(this); + } - const hasCallbacks = node.callbacks.length > 0; + const hasCallbacks = node.callbacks.length > 0; - const Properties = filterConflicts(node.namespace, node, node.props) - .map(v => v.asString(this)) - .join(`\n`); + const Properties = filterConflicts(node.namespace, node, node.props) + .map(v => v.asString(this)) + .join("\n"); - const Fields = filterConflicts(node.namespace, node, node.fields) - .map(v => v.asString(this)) - .join(`\n`); + const Fields = filterConflicts(node.namespace, node, node.fields) + .map(v => v.asString(this)) + .join("\n"); - const Constructors = filterConflicts(node.namespace, node, node.constructors) - .map(v => this.generateConstructorFunction(v)) - .join(`\n`); + const Constructors = filterConflicts(node.namespace, node, node.constructors) + .map(v => this.generateConstructorFunction(v)) + .join("\n"); - const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []); - const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers) - .map(v => v.asString(this)) - .join(`\n`); + const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []); + const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers) + .map(v => v.asString(this)) + .join("\n"); - // So we can use GObject.GType - this.namespace.assertInstalledImport("GObject"); + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); - return `${ - hasCallbacks - ? `export module ${name} { - ${node.callbacks.map(c => c.asString(this)).join(`\n`)} + return `${ + hasCallbacks + ? `export module ${name} { + ${node.callbacks.map(c => c.asString(this)).join("\n")} }` - : `` - } + : "" + } -${this.docString(node)}export class ${name}${Generics}${Extends} {${node.indexSignature ? `\n${node.indexSignature}\n` : ""} +${this.docString(node)}export class ${name}${Generics}${Extends} {${ + node.indexSignature ? `\n${node.indexSignature}\n` : "" + } static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>; ${MainConstructor} constructor(copy: ${node.name}); - ${node.props.length > 0 ? `// Properties` : ""} + ${node.props.length > 0 ? "// Properties" : ""} ${Properties} - ${node.fields.length > 0 ? `// Fields` : ""} + ${node.fields.length > 0 ? "// Fields" : ""} ${Fields} - ${node.constructors.length > 0 ? `// Constructors` : ""} + ${node.constructors.length > 0 ? "// Constructors" : ""} ${Constructors} - ${node.members.length > 0 ? `// Members` : ""} + ${node.members.length > 0 ? "// Members" : ""} ${Members} }`; - } - - generateClass(node: IntrospectedClass): string { - const { options, namespace } = this; - - const name = node.name; - - let injectConstructorBucket = !node.mainConstructor; - - let Generics = ""; - let GenericTypes = ""; - - if (node.generics.length > 0) { - Generics = `${this.generateGenerics(node.generics)}`; - GenericTypes = `${this.generateGenerics(node.generics, false)}`; } - const Extends = this.extends(node); - const Implements = this.implements(node); - - const implementedProperties = node.implementedProperties(); - const implementedMethods = node.implementedMethods(implementedProperties); - - let MainConstructor: string = ""; + generateClass(node: IntrospectedClass): string { + const { options, namespace } = this; - if (node.mainConstructor) { - MainConstructor = `\n${node.mainConstructor.asString(this)}`; - } else { - MainConstructor = `\nconstructor(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]);\n`; + const name = node.name; - if (!options.noInitTypes) { - MainConstructor += `_init(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]): void;\n`; - } else { - MainConstructor += `_init(...args: any[]): void;\n`; - } - } + const injectConstructorBucket = !node.mainConstructor; - const ConstructorProps = filterConflicts( - node.namespace, - node, - // TODO: Include properties from interface parents too. - node.props - ) - .map(v => v.asString(this, true)) - .join(`\n `); + let Generics = ""; + let GenericTypes = ""; - const Properties = filterConflicts(node.namespace, node, node.props) - .map(v => v.asString(this)) - .join(`\n `); + if (node.generics.length > 0) { + Generics = `${this.generateGenerics(node.generics)}`; + GenericTypes = `${this.generateGenerics(node.generics, false)}`; + } - const Fields = filterConflicts(node.namespace, node, node.fields) - .map(v => v.asString(this)) - .join(`\n `); + const Extends = this.extends(node); + const Implements = this.implements(node); - const Constructors = filterFunctionConflict(node.namespace, node, node.constructors, []) - .map(v => this.generateConstructorFunction(v)) - .join(`\n `); + const implementedProperties = node.implementedProperties(); + const implementedMethods = node.implementedMethods(implementedProperties); - const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []); - const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers) - .map(v => v.asString(this)) - .join(`\n `); + let MainConstructor: string = ""; - const ImplementedProperties = filterConflicts(node.namespace, node, implementedProperties) - .map(m => m.asString(this)) - .join(`\n `); + if (node.mainConstructor) { + MainConstructor = `\n${node.mainConstructor.asString(this)}`; + } else { + MainConstructor = `\nconstructor(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]);\n`; - const FilteredImplMethods = filterFunctionConflict(node.namespace, node, implementedMethods, []); - const ImplementedMethods = ( - options.promisify ? promisifyFunctions(FilteredImplMethods) : FilteredImplMethods - ) - .map(m => m.asString(this)) - .join(`\n `); - - // TODO Move these to a cleaner place. - - const Connect = new IntrospectedClassFunction({ - name: "connect", - parent: node, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: StringType, - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "callback", - type: AnyFunctionType, - direction: GirDirection.In - }) - ], - return_type: NumberType - }); - - const ConnectAfter = new IntrospectedClassFunction({ - name: "connect_after", - parent: node, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: StringType, - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "callback", - type: AnyFunctionType, - direction: GirDirection.In - }) - ], - return_type: NumberType - }); - - const Emit = new IntrospectedClassFunction({ - name: "emit", - parent: node, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: StringType, - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "args", - isVarArgs: true, - type: new ArrayType(AnyType), - direction: GirDirection.In - }) - ], - return_type: VoidType - }); - - let default_signals = [] as IntrospectedClassFunction[]; - let hasConnect, hasConnectAfter, hasEmit; - - if (node.signals.length > 0) { - hasConnect = node.members.some(m => m.name === "connect"); - hasConnectAfter = node.members.some(m => m.name === "connect_after"); - hasEmit = node.members.some(m => m.name === "emit"); - - if (!hasConnect) { - default_signals.push(Connect); - } - if (!hasConnectAfter) { - default_signals.push(ConnectAfter); - } - if (!hasEmit) { - default_signals.push(Emit); - } - - default_signals = filterConflicts(namespace, node, default_signals, FilterBehavior.DELETE); + if (!options.noInitTypes) { + MainConstructor += `_init(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]): void;\n`; + } else { + MainConstructor += "_init(...args: any[]): void;\n"; + } + } - hasConnect = !default_signals.some(s => s.name === "connect"); - hasConnectAfter = !default_signals.some(s => s.name === "connect_after"); - hasEmit = !default_signals.some(s => s.name === "emit"); - } + const ConstructorProps = filterConflicts( + node.namespace, + node, + // TODO: Include properties from interface parents too. + node.props + ) + .map(v => v.asString(this, true)) + .join("\n "); + + const Properties = filterConflicts(node.namespace, node, node.props) + .map(v => v.asString(this)) + .join("\n "); + + const Fields = filterConflicts(node.namespace, node, node.fields) + .map(v => v.asString(this)) + .join("\n "); + + const Constructors = filterFunctionConflict(node.namespace, node, node.constructors, []) + .map(v => this.generateConstructorFunction(v)) + .join("\n "); + + const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []); + const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers) + .map(v => v.asString(this)) + .join("\n "); + + const ImplementedProperties = filterConflicts(node.namespace, node, implementedProperties) + .map(m => m.asString(this)) + .join("\n "); + + const FilteredImplMethods = filterFunctionConflict(node.namespace, node, implementedMethods, []); + const ImplementedMethods = (options.promisify ? promisifyFunctions(FilteredImplMethods) : FilteredImplMethods) + .map(m => m.asString(this)) + .join("\n "); + + // TODO Move these to a cleaner place. + + const Connect = new IntrospectedClassFunction({ + name: "connect", + parent: node, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: NumberType + }); + + const ConnectAfter = new IntrospectedClassFunction({ + name: "connect_after", + parent: node, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: NumberType + }); + + const Emit = new IntrospectedClassFunction({ + name: "emit", + parent: node, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "args", + isVarArgs: true, + type: new ArrayType(AnyType), + direction: GirDirection.In + }) + ], + return_type: VoidType + }); + + let default_signals = [] as IntrospectedClassFunction[]; + let hasConnect, hasConnectAfter, hasEmit; + + if (node.signals.length > 0) { + hasConnect = node.members.some(m => m.name === "connect"); + hasConnectAfter = node.members.some(m => m.name === "connect_after"); + hasEmit = node.members.some(m => m.name === "emit"); + + if (!hasConnect) { + default_signals.push(Connect); + } + if (!hasConnectAfter) { + default_signals.push(ConnectAfter); + } + if (!hasEmit) { + default_signals.push(Emit); + } + + default_signals = filterConflicts(namespace, node, default_signals, FilterBehavior.DELETE); + + hasConnect = !default_signals.some(s => s.name === "connect"); + hasConnectAfter = !default_signals.some(s => s.name === "connect_after"); + hasEmit = !default_signals.some(s => s.name === "emit"); + } - const SignalsList = [ - // TODO Relocate these. - ...default_signals.map(s => s.asString(this)), - ...node.signals - .map(s => { - const methods = [] as string[]; + const SignalsList = [ + // TODO Relocate these. + ...default_signals.map(s => s.asString(this)), + ...node.signals + .map(s => { + const methods = [] as string[]; - if (!hasConnect) methods.push(s.asString(this, IntrospectedSignalType.CONNECT)); - if (!hasConnectAfter) methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER)); - if (!hasEmit) methods.push(s.asString(this, IntrospectedSignalType.EMIT)); + if (!hasConnect) methods.push(s.asString(this, IntrospectedSignalType.CONNECT)); + if (!hasConnectAfter) methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER)); + if (!hasEmit) methods.push(s.asString(this, IntrospectedSignalType.EMIT)); - return methods; - }) - .flat() - ]; + return methods; + }) + .flat() + ]; - const hasSignals = SignalsList.length > 0; - const Signals = SignalsList.join(`\n`); + const hasSignals = SignalsList.length > 0; + const Signals = SignalsList.join("\n"); - const hasCallbacks = node.callbacks.length > 0; - const hasModule = injectConstructorBucket || hasCallbacks; + const hasCallbacks = node.callbacks.length > 0; + const hasModule = injectConstructorBucket || hasCallbacks; - // So we can use GObject.GType - this.namespace.assertInstalledImport("GObject"); + // So we can use GObject.GType + this.namespace.assertInstalledImport("GObject"); - let [ExtendsInterface, ExtendsGenerics = ""] = Extends.split("<"); + const parts = Extends.split("<"); + const ExtendsInterface = parts[0]; + let ExtendsGenerics = parts[1] ?? ""; - if (ExtendsGenerics.length > 0) { - ExtendsGenerics = `<${ExtendsGenerics}`; - } + if (ExtendsGenerics.length > 0) { + ExtendsGenerics = `<${ExtendsGenerics}`; + } - return `${ - hasModule - ? `export module ${name} { - ${hasCallbacks ? node.callbacks.map(c => c.asString(this)).join(`\n`) : ""} + return `${ + hasModule + ? `export module ${name} { + ${hasCallbacks ? node.callbacks.map(c => c.asString(this)).join("\n") : ""} ${ - injectConstructorBucket - ? `export interface ConstructorProperties${Generics}${ - Extends ? `${ExtendsInterface}.ConstructorProperties${ExtendsGenerics}` : "" - } { + injectConstructorBucket + ? `export interface ConstructorProperties${Generics}${ + Extends ? `${ExtendsInterface}.ConstructorProperties${ExtendsGenerics}` : "" + } { [key: string]: any; ${ConstructorProps} }` - : "" + : "" } }` - : "" - } - export ${node.isAbstract ? `abstract ` : ""}class ${name}${Generics}${Extends}${Implements} {${ - node.indexSignature ? `\n${node.indexSignature}\n` : "" - } + : "" + } + export ${node.isAbstract ? "abstract " : ""}class ${name}${Generics}${Extends}${Implements} {${ + node.indexSignature ? `\n${node.indexSignature}\n` : "" + } static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>; ${MainConstructor} - ${node.props.length > 0 ? `// Properties` : ""} + ${node.props.length > 0 ? "// Properties" : ""} ${Properties} - ${node.fields.length > 0 ? `// Fields` : ""} + ${node.fields.length > 0 ? "// Fields" : ""} ${Fields} - ${hasSignals ? `// Signals\n` : ""} + ${hasSignals ? "// Signals\n" : ""} ${Signals} - ${implementedProperties.length > 0 ? `// Implemented Properties\n` : ""} + ${implementedProperties.length > 0 ? "// Implemented Properties\n" : ""} ${ImplementedProperties} - ${node.constructors.length > 0 ? `// Constructors\n` : ""} + ${node.constructors.length > 0 ? "// Constructors\n" : ""} ${Constructors} - ${node.members.length > 0 ? `// Members\n` : ""} + ${node.members.length > 0 ? "// Members\n" : ""} ${Members} - ${implementedMethods.length > 0 ? `// Implemented Members\n` : ""} + ${implementedMethods.length > 0 ? "// Implemented Members\n" : ""} ${ImplementedMethods} }`; - } + } - generateField(node: Field): string { - const { namespace, options } = this; - const { name, computed } = node; - const invalid = isInvalid(name); + generateField(node: Field): string { + const { namespace, options } = this; + const { name, computed } = node; + const invalid = isInvalid(name); - const Static = node.isStatic ? "static" : ""; - const ReadOnly = node.writable ? "" : "readonly"; + const Static = node.isStatic ? "static" : ""; + const ReadOnly = node.writable ? "" : "readonly"; - const Modifier = [Static, ReadOnly].filter(a => a !== "").join(" "); + const Modifier = [Static, ReadOnly].filter(a => a !== "").join(" "); - const Name = computed ? `[${name}]` : invalid ? `"${name}"` : name; + const Name = computed ? `[${name}]` : invalid ? `"${name}"` : name; - let { type } = node; - let fieldAnnotation = ""; - if (type instanceof TypeConflict) { - if (type.conflictType === ConflictType.PROPERTY_ACCESSOR_CONFLICT) { - fieldAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + let { type } = node; + let fieldAnnotation = ""; + if (type instanceof TypeConflict) { + if (type.conflictType === ConflictType.PROPERTY_ACCESSOR_CONFLICT) { + fieldAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. // @ts-expect-error\n`; - } + } - type = new BinaryType(type.unwrap(), AnyType); - } + type = new BinaryType(type.unwrap(), AnyType); + } - return `${this.docString(node)}${fieldAnnotation}${Modifier} ${Name}${node.optional ? "?" : ""}: ${type - .resolve(namespace, options) - .rootPrint(namespace, options)};`; - } + return `${this.docString(node)}${fieldAnnotation}${Modifier} ${Name}${node.optional ? "?" : ""}: ${type + .resolve(namespace, options) + .rootPrint(namespace, options)};`; + } - generateProperty(node: GirProperty, construct: boolean = false): string { - const { namespace, options } = this; + generateProperty(node: GirProperty, construct: boolean = false): string { + const { namespace, options } = this; - const invalid = isInvalid(node.name); - const Name = invalid ? `"${node.name}"` : node.name; + const invalid = isInvalid(node.name); + const Name = invalid ? `"${node.name}"` : node.name; - let type = node.type; - let getterAnnotation = ""; - let setterAnnotation = ""; - let getterSetterAnnotation = ""; + let type = node.type; + let getterAnnotation = ""; + let setterAnnotation = ""; + let getterSetterAnnotation = ""; - if (type instanceof TypeConflict) { - switch (type.conflictType) { - case ConflictType.FUNCTION_NAME_CONFLICT: - case ConflictType.FIELD_NAME_CONFLICT: - getterSetterAnnotation = - setterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + if (type instanceof TypeConflict) { + switch (type.conflictType) { + case ConflictType.FUNCTION_NAME_CONFLICT: + case ConflictType.FIELD_NAME_CONFLICT: + getterSetterAnnotation = + setterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. // @ts-expect-error\n`; - case ConflictType.ACCESSOR_PROPERTY_CONFLICT: - getterSetterAnnotation = - getterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + case ConflictType.ACCESSOR_PROPERTY_CONFLICT: + getterSetterAnnotation = + getterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. // @ts-expect-error\n`; - type = type.unwrap(); - break; - case ConflictType.PROPERTY_ACCESSOR_CONFLICT: - type = new BinaryType(type.unwrap(), AnyType); - break; - case ConflictType.PROPERTY_NAME_CONFLICT: - getterSetterAnnotation = - setterAnnotation = - getterAnnotation = - `// This accessor conflicts with another accessor's type in a parent class or interface.\n`; - type = new BinaryType(type.unwrap(), AnyType); - break; - } + type = type.unwrap(); + break; + case ConflictType.PROPERTY_ACCESSOR_CONFLICT: + type = new BinaryType(type.unwrap(), AnyType); + break; + case ConflictType.PROPERTY_NAME_CONFLICT: + getterSetterAnnotation = + setterAnnotation = + getterAnnotation = + "// This accessor conflicts with another accessor's type in a parent class or interface.\n"; + type = new BinaryType(type.unwrap(), AnyType); + break; + } + + if (construct && !(type instanceof BinaryType)) { + // For constructor properties we just convert to any. + type = new BinaryType(type, AnyType); + } + } - if (construct && !(type instanceof BinaryType)) { - // For constructor properties we just convert to any. - type = new BinaryType(type, AnyType); - } + const Type = type.resolve(namespace, options).rootPrint(namespace, options) || "any"; + + if (construct) { + return `${Name}: ${Type};`; + } + + const { readable, writable, constructOnly } = node; + + const hasGetter = readable; + const hasSetter = writable && !constructOnly; + + if (node.parent instanceof IntrospectedInterface) { + if (!hasSetter && hasGetter) { + return `readonly ${Name}: ${Type};`; + } else { + return `${Name}: ${Type};`; + } + } + + if (hasGetter && hasSetter) { + return `${getterAnnotation} get ${Name}(): ${Type}; + ${setterAnnotation} set ${Name}(val: ${Type});`; + } else if (hasGetter) { + return `${getterSetterAnnotation} get ${Name}(): ${Type};`; + } else { + return `${getterSetterAnnotation} set ${Name}(val: ${Type});`; + } } - let Type = type.resolve(namespace, options).rootPrint(namespace, options) || "any"; + generateSignal(node: IntrospectedSignal, type: IntrospectedSignalType = IntrospectedSignalType.CONNECT): string { + switch (type) { + case IntrospectedSignalType.CONNECT: + return node.asConnect(false).asString(this); + case IntrospectedSignalType.CONNECT_AFTER: + return node.asConnect(true).asString(this); + case IntrospectedSignalType.EMIT: + return node.asEmit().asString(this); + } + } - if (construct) { - return `${Name}: ${Type};`; + generateEnumMember(node: GirEnumMember): string { + const invalid = isInvalid(node.name); + if (node.value != null && !Number.isNaN(Number.parseInt(node.value, 10))) { + return invalid + ? `${this.docString(node)}"${node.name}" = ${node.value},` + : `${this.docString(node)}${node.name} = ${node.value},`; + } else { + return invalid ? `${this.docString(node)}"${node.name}",` : `${this.docString(node)}${node.name},`; + } } - const { readable, writable, constructOnly } = node; + generateParameter(node: IntrospectedFunctionParameter): string { + const { namespace, options } = this; - let hasGetter = readable; - let hasSetter = writable && !constructOnly; + const type: string = + resolveDirectedType(node.type, node.direction)?.resolve(namespace, options).rootPrint(namespace, options) ?? + node.type.resolve(namespace, options).rootPrint(namespace, options); - if (node.parent instanceof GirInterface) { - if (!hasSetter && hasGetter) { - return `readonly ${Name}: ${Type};`; - } else { - return `${Name}: ${Type};`; - } - } + if (node.isVarArgs) { + return `...args: ${type}`; + } - if (hasGetter && hasSetter) { - return `${getterAnnotation} get ${Name}(): ${Type}; - ${setterAnnotation} set ${Name}(val: ${Type});`; - } else if (hasGetter) { - return `${getterSetterAnnotation} get ${Name}(): ${Type};`; - } else { - return `${getterSetterAnnotation} set ${Name}(val: ${Type});`; + if (node.isOptional) { + return `${node.name}?: ${type}`; + } else { + return `${node.name}: ${type}`; + } } - } - - generateSignal(node: IntrospectedSignal, type: IntrospectedSignalType = IntrospectedSignalType.CONNECT): string { - switch (type) { - case IntrospectedSignalType.CONNECT: - return node.asConnect(false).asString(this); - case IntrospectedSignalType.CONNECT_AFTER: - return node.asConnect(true).asString(this); - case IntrospectedSignalType.EMIT: - return node.asEmit().asString(this); + + docString(node: GirBase) { + // TODO: Support node.doc not being a string? + return typeof node.doc === "string" && this.options.withDocs + ? `/** +${node.doc + .split("\n") + .map(line => + ` * ${line + .trim() + .replace("*/", "*\\/") + .replace(/@([a-z_]+?)([. ])/g, "`$1$2`")}`.replace(/@([a-z])/g, "$1") + ) + .join("\n")} + */\n` + : ""; } - } - - generateEnumMember(node: GirEnumMember): string { - const invalid = isInvalid(node.name); - if (node.value != null && !Number.isNaN(Number.parseInt(node.value, 10))) { - return invalid ? `${this.docString(node)}"${node.name}" = ${node.value},` : `${this.docString(node)}${node.name} = ${node.value},`; - } else { - return invalid ? `${this.docString(node)}"${node.name}",` : `${this.docString(node)}${node.name},`; + + generateFunction(node: IntrospectedFunction): string { + const { namespace } = this; + // Register our identifier with the sanitized identifiers. + // We avoid doing this in fromXML because other class-level function classes + // depends on that code. + sanitizeIdentifierName(namespace.name, node.raw_name); + + const Parameters = this.generateParameters(node.parameters); + const ReturnType = this.generateReturn(node.return(), node.output_parameters); + const Generics = this.generateGenerics(node.generics); + return `${this.docString(node)}export function ${node.name}${Generics}(${Parameters}): ${ReturnType};`; } - } - generateParameter(node: IntrospectedFunctionParameter): string { - const { namespace, options } = this; + generateConstructorFunction(node: IntrospectedConstructor): string { + const { namespace, options } = this; - let type: string = - resolveDirectedType(node.type, node.direction) - ?.resolve(namespace, options) - .rootPrint(namespace, options) ?? node.type.resolve(namespace, options).rootPrint(namespace, options); + const Parameters = this.generateParameters(node.parameters); - if (node.isVarArgs) { - return `...args: ${type}`; + const invalid = isInvalid(node.name); + const name = invalid ? `["${node.name}"]` : node.name; + const warning = node.getWarning(); + return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${name}(${Parameters}): ${node + .return() + .resolve(namespace, options) + .rootPrint(namespace, options)};`; } - if (node.isOptional) { - return `${node.name}?: ${type}`; - } else { - return `${node.name}: ${type}`; + generateConstructor(node: IntrospectedConstructor): string { + const Parameters = this.generateParameters(node.parameters); + + return `constructor(${Parameters});`; } - } - - docString(node: GirBase) { - // TODO: Support node.doc not being a string? - return typeof node.doc === 'string' && this.options.withDocs ? `/** -${node.doc.split('\n').map(line => ` * ${line.trim() - .replace('*/', '*\\/') -.replace(/@([a-z_]+?)([. ])/g, '`$1$2`')}` -.replace(/@([a-z])/g, '$1')) -.join('\n')} - */\n` : '' - } - - generateFunction(node: IntrospectedFunction): string { - const { namespace } = this; - // Register our identifier with the sanitized identifiers. - // We avoid doing this in fromXML because other class-level function classes - // depends on that code. - sanitizeIdentifierName(namespace.name, node.raw_name); - - const Parameters = this.generateParameters(node.parameters); - const ReturnType = this.generateReturn(node.return(), node.output_parameters); - const Generics = this.generateGenerics(node.generics); - return `${this.docString(node)}export function ${node.name}${Generics}(${Parameters}): ${ReturnType};`; - } - - generateConstructorFunction(node: IntrospectedConstructor): string { - const { namespace, options } = this; - - const Parameters = this.generateParameters(node.parameters); - - const invalid = isInvalid(node.name); - const name = invalid ? `["${node.name}"]` : node.name; - const warning = node.getWarning(); - return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${name}(${Parameters}): ${node - .return() - .resolve(namespace, options) - .rootPrint(namespace, options)};`; - } - - generateConstructor(node: IntrospectedConstructor): string { - const Parameters = this.generateParameters(node.parameters); - - return `constructor(${Parameters});`; - } - - generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string { - const ConstructorFields = node.fields.map(field => field.asString(this)).join(`\n`); - - return ` + + generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string { + const ConstructorFields = node.fields.map(field => field.asString(this)).join("\n"); + + return ` constructor(properties?: Partial<{ ${ConstructorFields} }>);`; - } + } + + generateClassFunction(node: IntrospectedClassFunction): string { + const invalid = isInvalid(node.name); - generateClassFunction(node: IntrospectedClassFunction): string { - const invalid = isInvalid(node.name); + const parameters = node.parameters; + const output_parameters = node.output_parameters; + const return_type = node.return(); - let parameters = node.parameters; - let output_parameters = node.output_parameters; - let return_type = node.return(); + const Parameters = this.generateParameters(parameters); + const ReturnType = this.generateReturn(return_type, output_parameters); - const Parameters = this.generateParameters(parameters); - let ReturnType = this.generateReturn(return_type, output_parameters); + const Generics = this.generateGenerics(node.generics); - const Generics = this.generateGenerics(node.generics); + if (node.shouldAnyify()) { + return `${invalid ? `["${node.name}"]` : node.name}: ${Generics}((${Parameters}) => ${ReturnType}) | any;`; + } - if (node.shouldAnyify()) { - return `${ - invalid ? `["${node.name}"]` : node.name - }: ${Generics}((${Parameters}) => ${ReturnType}) | any;`; + const warning = node.getWarning(); + return `${warning ? `${warning}\n` : ""}${this.docString(node)}${ + invalid ? `["${node.name}"]` : node.name + }${Generics}(${Parameters}): ${ReturnType};`; } - const warning = node.getWarning(); - return `${warning ? `${warning}\n` : ""}${this.docString(node)}${ - invalid ? `["${node.name}"]` : node.name - }${Generics}(${Parameters}): ${ReturnType};`; - } - - generateStaticClassFunction(node: IntrospectedStaticClassFunction): string { - const Generics = this.generateGenerics(node.generics); - - let ReturnType = this.generateReturn(node.return(), node.output_parameters); - - const warning = node.getWarning(); - return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${node.name}${Generics}(${this.generateParameters( - node.parameters - )}): ${ReturnType};`; - } - - generateAlias(node: IntrospectedAlias): string { - const { namespace, options } = this; - const Type = node.type.resolve(namespace, options).print(namespace, options); - const GenericBase = node.generics - .map(g => { - if (g.type) { - return `${g.name} = ${g.type.resolve(namespace, options).rootPrint(namespace, options)}`; - } + generateStaticClassFunction(node: IntrospectedStaticClassFunction): string { + const Generics = this.generateGenerics(node.generics); - return `${g.name}`; - }) - .join(", "); - const Generic = GenericBase ? `<${GenericBase}>` : ""; + const ReturnType = this.generateReturn(node.return(), node.output_parameters); - return `${this.docString(node)}export type ${node.name}${Generic} = ${Type};`; - } + const warning = node.getWarning(); + return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${ + node.name + }${Generics}(${this.generateParameters(node.parameters)}): ${ReturnType};`; + } + + generateAlias(node: IntrospectedAlias): string { + const { namespace, options } = this; + const Type = node.type.resolve(namespace, options).print(namespace, options); + const GenericBase = node.generics + .map(g => { + if (g.type) { + return `${g.name} = ${g.type.resolve(namespace, options).rootPrint(namespace, options)}`; + } + + return `${g.name}`; + }) + .join(", "); + const Generic = GenericBase ? `<${GenericBase}>` : ""; - generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): string { - return this.generateClassFunction(node); - } + return `${this.docString(node)}export type ${node.name}${Generic} = ${Type};`; + } + + generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): string { + return this.generateClassFunction(node); + } } diff --git a/packages/lib/src/newlib/generators/dts/gio.ts b/packages/lib/src/newlib/generators/dts/gio.ts index 8e962a6ed..551bdab80 100644 --- a/packages/lib/src/newlib/generators/dts/gio.ts +++ b/packages/lib/src/newlib/generators/dts/gio.ts @@ -1,7 +1,8 @@ import { IntrospectedNamespace } from "../../gir/namespace.js"; -export function override(_node: IntrospectedNamespace) { - return ` +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function override(node: IntrospectedNamespace) { + return ` export function _promisify(klass: any, function_name: string, finish_function_name: string): void; export interface _LocalFilePrototype extends FilePrototype {} export const _LocalFilePrototype: _LocalFilePrototype; diff --git a/packages/lib/src/newlib/generators/dts/glib.ts b/packages/lib/src/newlib/generators/dts/glib.ts index b083358ef..89b69dba0 100644 --- a/packages/lib/src/newlib/generators/dts/glib.ts +++ b/packages/lib/src/newlib/generators/dts/glib.ts @@ -1,13 +1,13 @@ import { IntrospectedNamespace } from "../../gir/namespace.js"; export function override(node: IntrospectedNamespace) { - // We provide manually written versions of these types below. - node.assertClass("Variant").noEmit(); - node.assertClass("VariantType").noEmit(); - node.assertClass("VariantBuilder").noEmit(); - node.assertClass("VariantDict").noEmit(); + // We provide manually written versions of these types below. + node.assertClass("Variant").noEmit(); + node.assertClass("VariantType").noEmit(); + node.assertClass("VariantBuilder").noEmit(); + node.assertClass("VariantDict").noEmit(); - return ` + return ` // Variant parsing inspired by https://jamie.build/ slightly infamous JSON-in-TypeScript parsing. type CreateIndexType = diff --git a/packages/lib/src/newlib/generators/dts/gobject.ts b/packages/lib/src/newlib/generators/dts/gobject.ts index 2306bebc7..aae49c39f 100644 --- a/packages/lib/src/newlib/generators/dts/gobject.ts +++ b/packages/lib/src/newlib/generators/dts/gobject.ts @@ -4,27 +4,27 @@ import { IntrospectedClassFunction, IntrospectedFunctionParameter } from "../../ import { IntrospectedNamespace } from "../../gir/namespace.js"; export function override(node: IntrospectedNamespace) { - const ParamSpec = node.assertClass("ParamSpec"); - - // We only inject __type__ for .d.ts files. - const type_function = new IntrospectedClassFunction({ - name: "__type__", - parent: ParamSpec, - parameters: [ - new IntrospectedFunctionParameter({ - name: "arg", - type: NeverType, - direction: GirDirection.In - }) - ], - return_type: new NativeType("A") - // TODO: Add support for generic native type replacement. - // return_type: UnknownType - }); - - ParamSpec.members.push(type_function.copy()); - - return ` + const ParamSpec = node.assertClass("ParamSpec"); + + // We only inject __type__ for .d.ts files. + const type_function = new IntrospectedClassFunction({ + name: "__type__", + parent: ParamSpec, + parameters: [ + new IntrospectedFunctionParameter({ + name: "arg", + type: NeverType, + direction: GirDirection.In + }) + ], + return_type: new NativeType("A") + // TODO: Add support for generic native type replacement. + // return_type: UnknownType + }); + + ParamSpec.members.push(type_function.copy()); + + return ` // GJS OVERRIDES // __type__ forces all GTypes to not match structurally. diff --git a/packages/lib/src/newlib/generators/generator.ts b/packages/lib/src/newlib/generators/generator.ts index 7969c93d5..1098be7c7 100644 --- a/packages/lib/src/newlib/generators/generator.ts +++ b/packages/lib/src/newlib/generators/generator.ts @@ -1,10 +1,16 @@ import { IntrospectedNamespace } from "../gir/namespace.js"; -import { IntrospectedClass, GirRecord, GirInterface } from "../gir/class.js"; +import { IntrospectedClass, IntrospectedRecord, IntrospectedInterface } from "../gir/class.js"; import { IntrospectedConstant } from "../gir/const.js"; import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; import { GirProperty, Field } from "../gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; -import { IntrospectedFunction, IntrospectedFunctionParameter, IntrospectedConstructor, IntrospectedCallback, IntrospectedDirectAllocationConstructor } from "../gir/function.js"; +import { + IntrospectedFunction, + IntrospectedFunctionParameter, + IntrospectedConstructor, + IntrospectedCallback, + IntrospectedDirectAllocationConstructor +} from "../gir/function.js"; import { IntrospectedClassFunction } from "../gir/function.js"; import { IntrospectedStaticClassFunction } from "../gir/function.js"; import { IntrospectedVirtualClassFunction } from "../gir/function.js"; @@ -13,40 +19,40 @@ import { TypeExpression } from "../gir.js"; import { GenerationOptions } from "../types.js"; export interface GenericDescriptor { - type: TypeExpression; - name: string; + type: TypeExpression; + name: string; } export abstract class FormatGenerator { - protected namespace: IntrospectedNamespace; - protected options: GenerationOptions; + protected namespace: IntrospectedNamespace; + protected options: GenerationOptions; - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { - this.namespace = namespace; - this.options = options; - } + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + this.namespace = namespace; + this.options = options; + } - abstract generateNamespace(node: IntrospectedNamespace): Promise; - abstract stringifyNamespace(node: IntrospectedNamespace): Promise; + abstract generateNamespace(node: IntrospectedNamespace): Promise; + abstract stringifyNamespace(node: IntrospectedNamespace): Promise; - abstract generateCallback(node: IntrospectedCallback): T; - abstract generateAlias(node: IntrospectedAlias): T; - abstract generateConstructor(node: IntrospectedConstructor): T; - abstract generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): T; - abstract generateConstructorFunction(node: IntrospectedConstructor): T; - abstract generateRecord(node: GirRecord): T; - abstract generateInterface(node: GirInterface): T; - abstract generateEnumMember(node: GirEnumMember): T; - abstract generateError(node: IntrospectedError): T; - abstract generateEnum(node: IntrospectedEnum): T; - abstract generateConst(node: IntrospectedConstant): T; - abstract generateClass(node: IntrospectedClass): T; - abstract generateParameter(node: IntrospectedFunctionParameter): T; - abstract generateProperty(node: GirProperty, construct?: boolean): T; - abstract generateField(node: Field): T; - abstract generateSignal(node: IntrospectedSignal, type?: IntrospectedSignalType): T; - abstract generateFunction(node: IntrospectedFunction): T; - abstract generateClassFunction(node: IntrospectedClassFunction): T; - abstract generateStaticClassFunction(node: IntrospectedStaticClassFunction): T; - abstract generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): T; + abstract generateCallback(node: IntrospectedCallback): T; + abstract generateAlias(node: IntrospectedAlias): T; + abstract generateConstructor(node: IntrospectedConstructor): T; + abstract generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): T; + abstract generateConstructorFunction(node: IntrospectedConstructor): T; + abstract generateRecord(node: IntrospectedRecord): T; + abstract generateInterface(node: IntrospectedInterface): T; + abstract generateEnumMember(node: GirEnumMember): T; + abstract generateError(node: IntrospectedError): T; + abstract generateEnum(node: IntrospectedEnum): T; + abstract generateConst(node: IntrospectedConstant): T; + abstract generateClass(node: IntrospectedClass): T; + abstract generateParameter(node: IntrospectedFunctionParameter): T; + abstract generateProperty(node: GirProperty, construct?: boolean): T; + abstract generateField(node: Field): T; + abstract generateSignal(node: IntrospectedSignal, type?: IntrospectedSignalType): T; + abstract generateFunction(node: IntrospectedFunction): T; + abstract generateClassFunction(node: IntrospectedClassFunction): T; + abstract generateStaticClassFunction(node: IntrospectedStaticClassFunction): T; + abstract generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): T; } diff --git a/packages/lib/src/newlib/generators/index.ts b/packages/lib/src/newlib/generators/index.ts index 64e8900b0..51f64203d 100644 --- a/packages/lib/src/newlib/generators/index.ts +++ b/packages/lib/src/newlib/generators/index.ts @@ -2,5 +2,5 @@ export * from "./generator.js"; export { JsonGenerator } from "./json.js"; export { DtsModuleGenerator as DtsGenerator } from "./dts-modules.js"; -export { DtsInlineGenerator } from './dts-inline.js'; -export { DtsGenerator as DtsAbstractGenerator } from './dts.js'; \ No newline at end of file +export { DtsInlineGenerator } from "./dts-inline.js"; +export { DtsGenerator as DtsAbstractGenerator } from "./dts.js"; diff --git a/packages/lib/src/newlib/generators/json.ts b/packages/lib/src/newlib/generators/json.ts index 381268317..c4637b6a6 100644 --- a/packages/lib/src/newlib/generators/json.ts +++ b/packages/lib/src/newlib/generators/json.ts @@ -1,1294 +1,1316 @@ import { FormatGenerator } from "./generator.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; -import { IntrospectedBaseClass, GirRecord, GirInterface, IntrospectedClass } from "../gir/class.js"; +import { IntrospectedBaseClass, IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from "../gir/class.js"; import { IntrospectedConstant } from "../gir/const.js"; import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; import { GirProperty, Field } from "../gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; import { - IntrospectedFunction, - IntrospectedConstructor, - IntrospectedFunctionParameter, - IntrospectedCallback, - IntrospectedDirectAllocationConstructor + IntrospectedFunction, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedCallback, + IntrospectedDirectAllocationConstructor +} from "../gir/function.js"; +import { + IntrospectedClassFunction, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction } from "../gir/function.js"; -import { IntrospectedClassFunction, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction } from "../gir/function.js"; import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js"; import { - TypeExpression, - NativeType, - AnyType, - VoidType, - StringType, - NumberType, - ArrayType, - TypeIdentifier, - OrType, - TupleType, - NullableType, - ClosureType, - GirBase, - AnyFunctionType, - TypeConflict, - GirMetadata + TypeExpression, + NativeType, + AnyType, + VoidType, + StringType, + NumberType, + ArrayType, + TypeIdentifier, + OrType, + TupleType, + NullableType, + ClosureType, + GirBase, + AnyFunctionType, + TypeConflict, + GirMetadata } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedAlias } from "../gir/alias.js"; import { GenerationOptions } from "../types.js"; export const enum NodeKind { - class = "class", - interface = "interface", - function = "function", - classFunction = "class_function", - staticClassFunction = "static_class_function", - virtualClassFunction = "virtual_class_function", - prop = "prop", - field = "field", - alias = "alias", - namespace = "namespace", - callback = "callback", - constant = "constant", - record = "record", - constructor = "constructor", - propertiesConstructor = "properties_constructor", - parameter = "parameter", - enum = "enum", - enumMember = "enum_member", - error = "error" + class = "class", + interface = "interface", + function = "function", + classFunction = "class_function", + staticClassFunction = "static_class_function", + virtualClassFunction = "virtual_class_function", + prop = "prop", + field = "field", + alias = "alias", + namespace = "namespace", + callback = "callback", + constant = "constant", + record = "record", + constructor = "constructor", + propertiesConstructor = "properties_constructor", + parameter = "parameter", + enum = "enum", + enumMember = "enum_member", + error = "error" } export type Primitive = string[] | number[] | boolean[] | null | string | number | boolean; export type Json = { - [key: string]: Primitive | Json | Json[]; + [key: string]: Primitive | Json | Json[]; }; export type NodeJson = { - kind: NodeKind; - doc: string | null; - metadata: MetadataJson | null; - private: boolean; + kind: NodeKind; + doc: string | null; + metadata: MetadataJson | null; + private: boolean; } & Json; export const enum TypeKind { - or = "or", - tuple = "tuple", - identifier = "identifier", - native = "native", - array = "array", - nulled = "null", - closure = "closure" + or = "or", + tuple = "tuple", + identifier = "identifier", + native = "native", + array = "array", + nulled = "null", + closure = "closure" } function generateType(type: TypeExpression): TypeJson { - if (type instanceof TypeIdentifier) { - return { - kind: TypeKind.identifier, - name: type.name, - namespace: type.namespace - }; - } else if (type instanceof NativeType) { - return { - kind: TypeKind.native, - type: type.expression() - }; - } else if (type instanceof ClosureType) { - return { - kind: TypeKind.closure, - type: generateType(type.type), - user_data: type.user_data - }; - } else if (type instanceof ArrayType) { - return { - kind: TypeKind.array, - type: generateType(type.type), - depth: type.arrayDepth - }; - } else if (type instanceof NullableType) { - return { - kind: TypeKind.nulled, - type: generateType(type.type) - }; - } else if (type instanceof TypeConflict) { - // Type conflicts aren't considered in JSON outputs. - return generateType(type.type); - } else if (type instanceof TupleType) { - return { - kind: TypeKind.tuple, - types: type.types.map(t => generateType(t)) - }; - } else if (type instanceof OrType) { - return { - kind: TypeKind.or, - types: type.types.map(t => generateType(t)) - }; - } else { - return { - kind: TypeKind.native, - type: "any" - }; - } + if (type instanceof TypeIdentifier) { + return { + kind: TypeKind.identifier, + name: type.name, + namespace: type.namespace + }; + } else if (type instanceof NativeType) { + return { + kind: TypeKind.native, + type: type.expression() + }; + } else if (type instanceof ClosureType) { + return { + kind: TypeKind.closure, + type: generateType(type.type), + user_data: type.user_data + }; + } else if (type instanceof ArrayType) { + return { + kind: TypeKind.array, + type: generateType(type.type), + depth: type.arrayDepth + }; + } else if (type instanceof NullableType) { + return { + kind: TypeKind.nulled, + type: generateType(type.type) + }; + } else if (type instanceof TypeConflict) { + // Type conflicts aren't considered in JSON outputs. + return generateType(type.type); + } else if (type instanceof TupleType) { + return { + kind: TypeKind.tuple, + types: type.types.map(t => generateType(t)) + }; + } else if (type instanceof OrType) { + return { + kind: TypeKind.or, + types: type.types.map(t => generateType(t)) + }; + } else { + return { + kind: TypeKind.native, + type: "any" + }; + } } function capitalize(str: string) { - if (str.length === 0) { - return ""; - } + if (str.length === 0) { + return ""; + } - if (str.length === 1) { - return str[0].toUpperCase(); - } + if (str.length === 1) { + return str[0].toUpperCase(); + } - return str[0].toUpperCase() + str.substring(1).toLowerCase(); + return str[0].toUpperCase() + str.substring(1).toLowerCase(); } export interface ParameterJson extends NodeJson { - kind: NodeKind.parameter; - optional: boolean; - varargs: boolean; - name: string; - type: TypeJson; + kind: NodeKind.parameter; + optional: boolean; + varargs: boolean; + name: string; + type: TypeJson; } export type TypeJson = Json & - ( - | { - kind: TypeKind.native; - type: string; - } - | { - kind: TypeKind.array; - depth: number; - type: TypeJson; - } - | { - kind: TypeKind.or | TypeKind.tuple; - types: TypeJson[]; - } - | { - kind: TypeKind.nulled; - type: TypeJson; - } - | { - kind: TypeKind.closure; - user_data: number | null; - type: TypeJson; - } - | { - kind: TypeKind.identifier; - namespace: string; - name: string; - } - ); + ( + | { + kind: TypeKind.native; + type: string; + } + | { + kind: TypeKind.array; + depth: number; + type: TypeJson; + } + | { + kind: TypeKind.or | TypeKind.tuple; + types: TypeJson[]; + } + | { + kind: TypeKind.nulled; + type: TypeJson; + } + | { + kind: TypeKind.closure; + user_data: number | null; + type: TypeJson; + } + | { + kind: TypeKind.identifier; + namespace: string; + name: string; + } + ); export interface EnumMemberJson extends NodeJson { - kind: NodeKind.enumMember; - name: string; - value: string | null; + kind: NodeKind.enumMember; + name: string; + value: string | null; } export interface EnumJson extends NodeJson { - kind: NodeKind.enum; - name: string; - members: EnumMemberJson[]; + kind: NodeKind.enum; + name: string; + members: EnumMemberJson[]; } export interface CallbackJson extends NodeJson { - kind: NodeKind.callback; - name: string; - type: [Json, Json]; - parameters: ParameterJson[]; - returnType: TypeJson; + kind: NodeKind.callback; + name: string; + type: [Json, Json]; + parameters: ParameterJson[]; + returnType: TypeJson; } export interface PropertyJson extends NodeJson { - kind: NodeKind.prop; - name: string; - type: TypeJson; + kind: NodeKind.prop; + name: string; + type: TypeJson; } export interface FieldJson extends NodeJson { - kind: NodeKind.field; - name: string; - type: TypeJson; + kind: NodeKind.field; + name: string; + type: TypeJson; } export interface MethodJson extends NodeJson { - kind: NodeKind.classFunction; - name: string; - parameters: ParameterJson[]; - returnType: TypeJson[] | TypeJson; + kind: NodeKind.classFunction; + name: string; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; } export interface StaticMethodJson extends NodeJson { - kind: NodeKind.staticClassFunction; - name: string; - parameters: ParameterJson[]; - returnType: TypeJson[] | TypeJson; + kind: NodeKind.staticClassFunction; + name: string; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; } export interface VirtualMethodJson extends NodeJson { - kind: NodeKind.virtualClassFunction; - name: string; - parameters: ParameterJson[]; - returnType: TypeJson[] | TypeJson; + kind: NodeKind.virtualClassFunction; + name: string; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; } export interface MetadataJson extends Json {} export interface ConstJson extends NodeJson { - kind: NodeKind.constant; - name: string; - type: TypeJson; + kind: NodeKind.constant; + name: string; + type: TypeJson; } export interface InterfaceJson extends NodeJson { - kind: NodeKind.interface; - name: string; - extends: TypeJson | null; - type: TypeJson; - props: PropertyJson[]; - methods: MethodJson[]; - staticMethods: StaticMethodJson[]; - virtualMethods: VirtualMethodJson[]; + kind: NodeKind.interface; + name: string; + extends: TypeJson | null; + type: TypeJson; + props: PropertyJson[]; + methods: MethodJson[]; + staticMethods: StaticMethodJson[]; + virtualMethods: VirtualMethodJson[]; } export interface BaseClassJson extends NodeJson { - name: string; - type: TypeJson; - constructors: MethodJson[]; - mainConstructor: PropertiesConstructorJson | ConstructorJson | null; - extends: TypeJson | null; - implements: TypeJson[]; - props: PropertyJson[]; - fields: FieldJson[]; - methods: MethodJson[]; - staticMethods: StaticMethodJson[]; - virtualMethods: VirtualMethodJson[]; + name: string; + type: TypeJson; + constructors: MethodJson[]; + mainConstructor: PropertiesConstructorJson | ConstructorJson | null; + extends: TypeJson | null; + implements: TypeJson[]; + props: PropertyJson[]; + fields: FieldJson[]; + methods: MethodJson[]; + staticMethods: StaticMethodJson[]; + virtualMethods: VirtualMethodJson[]; } export interface ClassJson extends BaseClassJson { - kind: NodeKind.class; - abstract: boolean; + kind: NodeKind.class; + abstract: boolean; } export interface RecordJson extends BaseClassJson { - kind: NodeKind.record; - mainConstructor: ConstructorJson | null; + kind: NodeKind.record; + mainConstructor: ConstructorJson | null; } export interface ErrorJson extends BaseClassJson { - kind: NodeKind.error; - mainConstructor: ConstructorJson | null; + kind: NodeKind.error; + mainConstructor: ConstructorJson | null; } export interface FunctionJson extends NodeJson { - name: string; - kind: NodeKind.function; - parameters: ParameterJson[]; - returnType: TypeJson[] | TypeJson; + name: string; + kind: NodeKind.function; + parameters: ParameterJson[]; + returnType: TypeJson[] | TypeJson; } export interface AliasJson extends NodeJson { - name: string; - kind: NodeKind.alias; - type: TypeJson; + name: string; + kind: NodeKind.alias; + type: TypeJson; } export interface PropertiesConstructorJson extends NodeJson { - name: string; - kind: NodeKind.propertiesConstructor; - properties: ParameterJson[]; + name: string; + kind: NodeKind.propertiesConstructor; + properties: ParameterJson[]; } export interface ConstructorJson extends NodeJson { - name: string; - kind: NodeKind.constructor; - parameters: ParameterJson[]; + name: string; + kind: NodeKind.constructor; + parameters: ParameterJson[]; } export type ImportsJson = { [lib: string]: string }; export interface NamespaceJson extends Json { - kind: NodeKind.namespace; - imports: ImportsJson; - version: string; - name: string; - alias: AliasJson[]; - enums: EnumJson[]; - errors: ErrorJson[]; - functions: FunctionJson[]; - callbacks: CallbackJson[]; - constants: ConstJson[]; - records: RecordJson[]; - interfaces: InterfaceJson[]; - classes: ClassJson[]; + kind: NodeKind.namespace; + imports: ImportsJson; + version: string; + name: string; + alias: AliasJson[]; + enums: EnumJson[]; + errors: ErrorJson[]; + functions: FunctionJson[]; + callbacks: CallbackJson[]; + constants: ConstJson[]; + records: RecordJson[]; + interfaces: InterfaceJson[]; + classes: ClassJson[]; } export class JsonGenerator extends FormatGenerator { - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { - super(namespace, options); - } - - /** - * Intelligently reformats # and () references - * to handle c-prefixes and namespacing. - * - * @param doc - */ - private generateDoc(doc: string): string { - const { namespace } = this; - - function resolveClass(ns: IntrospectedNamespace, className: string): readonly [GirBase | null, boolean] { - let classes = ns.getMembers(className); - - let plural = false; - - if (classes.length === 0 && className.endsWith("Class")) { - classes = ns.getMembers(className.slice(0, -5)); - } - - if (classes.length === 0 && className.endsWith("Iface")) { - classes = ns.getMembers(className.slice(0, -5)); - } - - if (classes.length === 0 && className.endsWith("Interface")) { - classes = ns.getMembers(className.slice(0, -9)); - } - - if (classes.length === 0 && className.endsWith("s")) { - plural = true; - classes = ns.getMembers(className.slice(0, -1)); - } - - return [classes[0] ?? null, plural] as const; + constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + super(namespace, options); } - function formatReference(identifier: string, member_name: string, punc?: string): string | null { - const parts = identifier - .split(/([A-Z])/) - .filter(p => p != "") - .reduce((prev, next) => { - if (next.toUpperCase() === next) { - prev.push(`${next}`); - } else { - const lastCapital = prev.pop(); - - prev.push(`${lastCapital}${next}`); - } + /** + * Intelligently reformats # and () references + * to handle c-prefixes and namespacing. + * + * @param doc + */ + private generateDoc(doc: string): string { + const { namespace } = this; - return prev; - }, [] as string[]); + function resolveClass(ns: IntrospectedNamespace, className: string): readonly [GirBase | null, boolean] { + let classes = ns.getMembers(className); - let [base_part] = parts; + let plural = false; - const [, , namespaces, className] = parts.slice(1).reduce( - ([underscore, camel, ns, selected], next) => { - const next_underscore = [underscore, next.toLowerCase()].join("_"); + if (classes.length === 0 && className.endsWith("Class")) { + classes = ns.getMembers(className.slice(0, -5)); + } - const namespaces = namespace.getImportsForCPrefix(next_underscore); - const nextCamel = camel + capitalize(next); + if (classes.length === 0 && className.endsWith("Iface")) { + classes = ns.getMembers(className.slice(0, -5)); + } - if (namespaces.length > 0) { - return [next_underscore, nextCamel, namespaces, capitalize(next)] as const; - } + if (classes.length === 0 && className.endsWith("Interface")) { + classes = ns.getMembers(className.slice(0, -9)); + } - return [next_underscore, nextCamel, ns, selected + capitalize(next)] as const; - }, - [ - base_part.toLowerCase(), - capitalize(base_part), - namespace.getImportsForCPrefix(base_part.toLowerCase()), - "" - ] as const - ); + if (classes.length === 0 && className.endsWith("s")) { + plural = true; + classes = ns.getMembers(className.slice(0, -1)); + } - let ns = namespaces.find(n => n.hasSymbol(className)); + return [classes[0] ?? null, plural] as const; + } - if (!ns) { - ns = namespaces.find(n => { - const [c] = resolveClass(n, className); + function formatReference(identifier: string, member_name: string, punc?: string): string | null { + const parts = identifier + .split(/([A-Z])/) + .filter(p => p != "") + .reduce((prev, next) => { + if (next.toUpperCase() === next) { + prev.push(`${next}`); + } else { + const lastCapital = prev.pop(); + + prev.push(`${lastCapital}${next}`); + } + + return prev; + }, [] as string[]); + + const [base_part] = parts; + + const [, , namespaces, className] = parts.slice(1).reduce( + ([underscore, camel, ns, selected], next) => { + const next_underscore = [underscore, next.toLowerCase()].join("_"); + + const namespaces = namespace.getImportsForCPrefix(next_underscore); + const nextCamel = camel + capitalize(next); + + if (namespaces.length > 0) { + return [next_underscore, nextCamel, namespaces, capitalize(next)] as const; + } + + return [next_underscore, nextCamel, ns, selected + capitalize(next)] as const; + }, + [ + base_part.toLowerCase(), + capitalize(base_part), + namespace.getImportsForCPrefix(base_part.toLowerCase()), + "" as string + ] as const + ); + + let ns = namespaces.find(n => n.hasSymbol(className)); + + if (!ns) { + ns = namespaces.find(n => { + const [c] = resolveClass(n, className); + + return c != null; + }); + } - return c != null; - }); - } + if (ns) { + const is_prop = punc === ":"; + const modified_name = is_prop ? member_name.replace(/[\-]/g, "_") : member_name; - if (ns) { - const is_prop = punc === ":"; - const modified_name = is_prop ? member_name.replace(/[\-]/g, "_") : member_name; + const [clazz, plural] = resolveClass(ns, className); - let [clazz, plural] = resolveClass(ns, className); + if (clazz instanceof IntrospectedBaseClass || clazz instanceof IntrospectedEnum) { + const r = `#${plural ? "{" : ""}${ns.name}.${clazz.name}${punc ? `${punc}${modified_name}` : ""}${ + plural ? "}s" : "" + }`; + return r; + } - if (clazz instanceof IntrospectedBaseClass || clazz instanceof IntrospectedEnum) { - const r = `#${plural ? "{" : ""}${ns.name}.${clazz.name}${punc ? `${punc}${modified_name}` : ""}${ - plural ? "}s" : "" - }`; - return r; + return `#${ns.name}${punc ? ` (${punc}${modified_name})` : ""}`; + } else { + return null; + } } - return `#${ns.name}${punc ? ` (${punc}${modified_name})` : ""}`; - } else { - return null; - } - } + function formatFunctionReference(func: string, upper = false): string | null { + // namespace_class_do_thing() - function formatFunctionReference(func: string, upper = false): string | null { - // namespace_class_do_thing() + const parts = func.toLowerCase().split("_"); - const parts = func.toLowerCase().split("_"); + // ['namespace', 'class', 'do', 'thing'] - // ['namespace', 'class', 'do', 'thing'] + const [base_part] = parts; - const [base_part] = parts; + // ['namespace'] - // ['namespace'] + const namespaceBase = [ + base_part.toLowerCase(), + capitalize(base_part), + namespace.getImportsForCPrefix(base_part.toLowerCase()), + 0 as number + ] as const; - const namespaceBase = [ - base_part.toLowerCase(), - capitalize(base_part), - namespace.getImportsForCPrefix(base_part.toLowerCase()), - 0 - ] as const; + // ['namespace', 'Namespace', { Namespace }, -1] - // ['namespace', 'Namespace', { Namespace }, -1] + const [, , namespaces, i] = parts.slice(1).reduce(([prev, camel, currentNamespaces, selected], next, i) => { + const underscore = [prev, next.toLowerCase()].join("_"); + const namespaces = namespace.getImportsForCPrefix(underscore); + const identifier = camel + capitalize(next); - const [, , namespaces, i] = parts - .slice(1) - .reduce(([prev, camel, currentNamespaces, selected], next, i) => { - const underscore = [prev, next.toLowerCase()].join("_"); - const namespaces = namespace.getImportsForCPrefix(underscore); - const identifier = camel + capitalize(next); + // We've found namespace(s) which matches the c_prefix + if (namespaces.length > 0) { + return [underscore, identifier, namespaces, i] as const; + } - // We've found namespace(s) which matches the c_prefix - if (namespaces.length > 0) { - return [underscore, identifier, namespaces, i] as const; - } + return [underscore, identifier, currentNamespaces, selected] as const; + }, namespaceBase); - return [underscore, identifier, currentNamespaces, selected] as const; - }, namespaceBase); + // If no namespaces are found for the function's c_prefix, we return the original reference. + if (namespaces.length === 0) { + return null; + } - // If no namespaces are found for the function's c_prefix, we return the original reference. - if (namespaces.length === 0) { - return null; - } + // ['class', 'do', 'thing'] + + const nameParts = parts.slice(i + 1); + + // 'class_do_thing' + + const functionName = nameParts.join("_"); + const functionNamespace = namespaces.find(n => n.hasSymbol(functionName.toLowerCase())); + const constNamespace = namespaces.find(n => n.hasSymbol(functionName.toUpperCase())); + const enumNamespace = namespaces.find(n => n.enum_constants.has(func.toUpperCase())); + + if (functionNamespace) { + const [member = null] = functionNamespace.getMembers(functionName.toLowerCase()); + + if (member instanceof IntrospectedFunction) { + return `${functionNamespace.name}.${member.name}`; + } + + return null; + } else if (constNamespace) { + const [member = null] = constNamespace.getMembers(functionName.toUpperCase()); + + if (member instanceof IntrospectedConstant) { + return `${constNamespace.name}.${member.name}`; + } + + return null; + } else if (enumNamespace) { + const constantInfo = enumNamespace.enum_constants.get(func.toUpperCase()); + + if (constantInfo) { + const [enumName, memberName] = constantInfo; + + const [klass = null] = enumNamespace.getMembers(enumName); + + if (klass instanceof IntrospectedEnum) { + return `${enumNamespace.name}.${klass.name}.${memberName.toUpperCase()}`; + } + } + + return null; + } else { + // ['class', 'do', 'thing'] + + const { selectedClassName, resolvedNamespace, selectedIndex } = parts.slice(i + 1).reduce( + ({ className, selectedClassName, resolvedNamespace, selectedIndex }, next, i) => { + // Class + const identifier = `${className}${capitalize(next)}`; + + const withSymbol = namespaces.find(n => n.hasSymbol(identifier)); + + if (withSymbol) { + // { className: Class, resolvedNamespace: {Namespace}, selectedIndex: 0 } + return { + className: identifier, + selectedClassName: identifier, + resolvedNamespace: withSymbol, + selectedIndex: i + } as const; + } + + return { className: identifier, selectedClassName, resolvedNamespace, selectedIndex } as const; + }, + { + className: "" as string, + selectedClassName: "" as string, + resolvedNamespace: null as IntrospectedNamespace | null, + selectedIndex: -1 + } + ); + + if (resolvedNamespace && selectedIndex >= 0) { + const nextIndex = i + selectedIndex + 1 /* (slice omits first index) */ + 1; /* (the next index) */ + const functionName = parts.slice(nextIndex).join("_"); + + const [klass] = resolveClass(resolvedNamespace, selectedClassName); + + if (klass instanceof IntrospectedBaseClass || klass instanceof IntrospectedEnum) { + return `${resolvedNamespace.name}.${klass.name}.${ + upper ? functionName.toUpperCase() : functionName + }`; + } + + return `${resolvedNamespace.name}.${selectedClassName}.${ + upper ? functionName.toUpperCase() : functionName + }`; + } + } + + return null; + } + + return `${doc}` + .replace(/[#]{0,1}([A-Z][A-z]+)\.([a-z_]+)\(\)/g, (original, identifier: string, member_name: string) => { + const resolved = formatReference(identifier, member_name, "."); + return resolved != null ? `${resolved}()` : original; + }) + .replace( + /#([A-Z][A-z]*)(([:]{1,2})([a-z\-]+)){0,1}/g, + (original, identifier: string, _: string, punc: string, member_name: string) => { + const resolved = formatReference(identifier, member_name, punc); + return resolved != null ? resolved : original; + } + ) + .replace( + /([A-Z][A-z]*)(([:]{1,2})([a-z\-]+))/g, + (original, identifier: string, _: string, punc: string, member_name: string) => { + const resolved = formatReference(identifier, member_name, punc); + return resolved != null ? resolved : original; + } + ) + .replace(/(\s)([a-z_]+)\(\)/g, (original: string, w: string, func: string) => { + const resolved = formatFunctionReference(func); + return resolved != null ? `${w}${resolved}()` : original; + }) + .replace(/%([A-Z_]+)/g, (original: string, identifier: string) => { + const resolved = formatFunctionReference(identifier.toLowerCase(), true); + return resolved != null ? `%${resolved}` : original; + }) + .replace(/#([A-Z_]+)/g, (original: string, identifier: string) => { + const resolved = formatFunctionReference(identifier.toLowerCase(), true); + return resolved != null ? `#${resolved}` : original; + }); + } - // ['class', 'do', 'thing'] + private generateMetadata(metadata: GirMetadata): MetadataJson { + return { ...metadata } as MetadataJson; + } - const nameParts = parts.slice(i + 1); + private generateParameters(parameters: IntrospectedFunctionParameter[]): ParameterJson[] { + const { namespace, options } = this; + + return parameters.map(p => ({ + kind: NodeKind.parameter, + direction: p.direction, + optional: p.isOptional, + varargs: p.isVarArgs, + name: p.name, + resoleNames: p.resolve_names, + type: generateType(p.type.resolve(namespace, options)), + ...this._generateDocAndMetadata(p) + })); + } - // 'class_do_thing' + // eslint-disable-next-line @typescript-eslint/no-unused-vars + generateCallbackType(node: IntrospectedCallback): [Json, Json] { + return [{}, {}]; + } - const functionName = nameParts.join("_"); - const functionNamespace = namespaces.find(n => n.hasSymbol(functionName.toLowerCase())); - const constNamespace = namespaces.find(n => n.hasSymbol(functionName.toUpperCase())); - const enumNamespace = namespaces.find(n => n.enum_constants.has(func.toUpperCase())); + generateCallback(node: IntrospectedCallback): CallbackJson { + const { namespace, options } = this; - if (functionNamespace) { - const [member = null] = functionNamespace.getMembers(functionName.toLowerCase()); + const parameters = this.generateParameters(node.parameters); - if (member instanceof IntrospectedFunction) { - return `${functionNamespace.name}.${member.name}`; + return { + kind: NodeKind.callback, + name: node.name, + type: this.generateCallbackType(node), + parameters, + returnType: generateType(node.return().resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } + + generateReturn( + return_type: TypeExpression, + output_parameters: IntrospectedFunctionParameter[] + ): TypeJson | TypeJson[] { + const { namespace, options } = this; + const type = return_type.resolve(namespace, options); + + if (output_parameters.length > 0) { + const exclude_first = type.equals(VoidType); + const returns = [ + ...(exclude_first ? [] : [type]), + ...output_parameters.map(op => op.type.resolve(namespace, options)) + ]; + + return returns.map(r => generateType(r)); } - return null; - } else if (constNamespace) { - const [member = null] = constNamespace.getMembers(functionName.toUpperCase()); + return generateType(type); + } + + generateEnum(node: IntrospectedEnum): EnumJson { + return { + kind: NodeKind.enum, + name: node.name, + members: Array.from(node.members.values()).map(member => member.asString(this)), + ...this._generateDocAndMetadata(node) + }; + } + + generateError(node: IntrospectedError): ErrorJson { + const { namespace } = this; + const clazz = node.asClass(); + + clazz.members = []; + clazz.members.push(...Array.from(node.functions.values())); + + const GLib = namespace.assertInstalledImport("GLib"); + const GLibError = GLib.assertClass("Error"); + + clazz.parent = GLibError.getType(); + + // Manually construct a GLib.Error constructor. + clazz.mainConstructor = new IntrospectedConstructor({ + name: "new", + parameters: [ + new IntrospectedFunctionParameter({ + name: "options", + type: NativeType.of("{ message: string, code: number}"), + direction: GirDirection.In + }) + ], + return_type: clazz.getType() + }); + + return { + ...clazz.asString(this), + kind: NodeKind.error + }; + } - if (member instanceof IntrospectedConstant) { - return `${constNamespace.name}.${member.name}`; + _generateDocAndMetadata(node: GirBase) { + const { options } = this; + + if (options.withDocs) { + return { + private: node.isPrivate, + doc: this.generateDoc(node.doc ?? "") ?? null, + metadata: this.generateMetadata(node.metadata ?? {}) ?? null + }; } - return null; - } else if (enumNamespace) { - const constantInfo = enumNamespace.enum_constants.get(func.toUpperCase()); + return { + private: false, + doc: null, + metadata: null + }; + } - if (constantInfo) { - const [enumName, memberName] = constantInfo; + generateConst(node: IntrospectedConstant): ConstJson { + const { namespace, options } = this; - const [klass = null] = enumNamespace.getMembers(enumName); + return { + kind: NodeKind.constant, + name: node.name, + type: generateType(node.type.resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } - if (klass instanceof IntrospectedEnum) { - return `${enumNamespace.name}.${klass.name}.${memberName.toUpperCase()}`; - } + private implements(node: IntrospectedClass): TypeIdentifier[] { + const { namespace, options } = this; + + if (node.interfaces.length > 0) { + return node.interfaces + .map(i => i.resolveIdentifier(namespace, options)) + .filter((i): i is TypeIdentifier => i != null); + } + + return []; + } + + private extends(node: IntrospectedBaseClass): TypeIdentifier | null { + const { namespace: ns, options } = this; + + if (node.parent) { + return node.parent.resolveIdentifier(ns, options); } return null; - } else { - // ['class', 'do', 'thing'] - - const { selectedClassName, resolvedNamespace, selectedIndex } = parts.slice(i + 1).reduce( - ({ className, selectedClassName, resolvedNamespace, selectedIndex }, next, i) => { - // Class - const identifier = `${className}${capitalize(next)}`; - - const withSymbol = namespaces.find(n => n.hasSymbol(identifier)); - - if (withSymbol) { - // { className: Class, resolvedNamespace: {Namespace}, selectedIndex: 0 } - return { - className: identifier, - selectedClassName: identifier, - resolvedNamespace: withSymbol, - selectedIndex: i - } as const; - } + } - return { className: identifier, selectedClassName, resolvedNamespace, selectedIndex } as const; - }, - { - className: "" as string, - selectedClassName: "" as string, - resolvedNamespace: null as IntrospectedNamespace | null, - selectedIndex: -1 - } - ); + generateInterface(node: IntrospectedInterface): InterfaceJson { + const { namespace } = this; + // If an interface does not list a prerequisite type, we fill it with GObject.Object + if (node.parent == null) { + const gobject = namespace.assertInstalledImport("GObject"); - if (resolvedNamespace && selectedIndex >= 0) { - const nextIndex = i + selectedIndex + 1 /* (slice omits first index) */ + 1; /* (the next index) */ - const functionName = parts.slice(nextIndex).join("_"); + // TODO Optimize GObject.Object + if (!gobject) { + throw new Error("GObject not generated, all interfaces extend from GObject.Object!"); + } - let [klass] = resolveClass(resolvedNamespace, selectedClassName); + const GObject = gobject.getClass("Object"); - if (klass instanceof IntrospectedBaseClass || klass instanceof IntrospectedEnum) { - return `${resolvedNamespace.name}.${klass.name}.${ - upper ? functionName.toUpperCase() : functionName - }`; - } + if (!GObject) { + throw new Error( + `GObject.Object could not be found while generating ${node.namespace.name}.${node.name}` + ); + } - return `${resolvedNamespace.name}.${selectedClassName}.${ - upper ? functionName.toUpperCase() : functionName - }`; + node.parent = GObject.getType(); } - } - return null; + const { name } = node; + + const Extends = this.extends(node); + + const Properties = node.props.map(v => v && v.asString(this)); + + const Methods = node.members + .filter( + m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction) + ) + .map(v => v && v.asString(this)); + const StaticMethods = node.members + .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) + .map(v => v && v.asString(this)); + const VirtualMethods = node.members + .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) + .map(v => v && v.asString(this)); + + return { + kind: NodeKind.interface, + name, + type: generateType(node.getType()), + extends: Extends ? generateType(Extends) : null, + props: Properties, + methods: Methods, + staticMethods: StaticMethods, + virtualMethods: VirtualMethods, + ...this._generateDocAndMetadata(node) + }; } - return `${doc}` - .replace( - /[#]{0,1}([A-Z][A-z]+)\.([a-z_]+)\(\)/g, - (original, identifier: string, member_name: string) => { - const resolved = formatReference(identifier, member_name, "."); - return resolved != null ? `${resolved}()` : original; - } - ) - .replace( - /#([A-Z][A-z]*)(([:]{1,2})([a-z\-]+)){0,1}/g, - (original, identifier: string, _: string, punc: string, member_name: string) => { - const resolved = formatReference(identifier, member_name, punc); - return resolved != null ? resolved : original; + generateRecord(node: IntrospectedRecord): RecordJson { + const { name } = node; + + const Extends = this.extends(node); + + const Properties = node.props.map(v => v && v.asString(this)); + + const Fields = node.fields.map(v => v && v.asString(this)); + + const Constructors = node.constructors.map(v => v && this.generateConstructorFunction(v)); + + const Methods = node.members + .filter( + m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction) + ) + .map(v => v && v.asString(this)); + const StaticMethods = node.members + .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) + .map(v => v && v.asString(this)); + const VirtualMethods = node.members + .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) + .map(v => v && v.asString(this)); + + const Callbacks = node.callbacks.map(c => c && c.asString(this)); + + return { + kind: NodeKind.record, + name, + type: generateType(node.getType()), + mainConstructor: node.mainConstructor?.asString(this) ?? null, + extends: Extends ? generateType(Extends) : null, + implements: [], + props: Properties, + fields: Fields, + constructors: Constructors, + methods: Methods, + staticMethods: StaticMethods, + virtualMethods: VirtualMethods, + callbacks: Callbacks, + ...this._generateDocAndMetadata(node) + }; + } + + generateClass(node: IntrospectedClass): ClassJson { + const Extends = this.extends(node); + const Implements = this.implements(node); + + let MainConstructor: PropertiesConstructorJson | ConstructorJson | null = null; + + const ConstructorProps = node.props.map(v => this.generateProperty(v, true)); + + if (node.mainConstructor) { + MainConstructor = this.generateConstructor(node.mainConstructor); + } else { + MainConstructor = { + kind: NodeKind.propertiesConstructor, + name: "new", + private: false, + properties: ConstructorProps.map(p => ({ + kind: NodeKind.parameter, + private: p.private, + varargs: false, + name: p.name, + type: p.type, + doc: p.doc, + metadata: p.metadata, + optional: true + })), + doc: null, + metadata: null + }; } - ) - .replace( - /([A-Z][A-z]*)(([:]{1,2})([a-z\-]+))/g, - (original, identifier: string, _: string, punc: string, member_name: string) => { - const resolved = formatReference(identifier, member_name, punc); - return resolved != null ? resolved : original; + + const Properties = node.props.map(v => v.asString(this)); + + const Fields = node.fields.map(v => v.asString(this)); + + const Constructors = node.constructors.map(v => this.generateConstructorFunction(v)); + + const Methods = node.members + .filter( + m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction) + ) + .map(v => v && v.asString(this)); + const StaticMethods = node.members + .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) + .map(v => v && v.asString(this)); + const VirtualMethods = node.members + .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) + .map(v => v && v.asString(this)); + + // TODO Move these to a cleaner place. + + const Connect = new IntrospectedClassFunction({ + name: "connect", + parent: node, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: NumberType + }); + + const ConnectAfter = new IntrospectedClassFunction({ + name: "connect_after", + parent: node, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "callback", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: NumberType + }); + + const Emit = new IntrospectedClassFunction({ + name: "emit", + parent: node, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "args", + isVarArgs: true, + type: new ArrayType(AnyType), + direction: GirDirection.In + }) + ], + return_type: VoidType + }); + + const default_signals = [] as IntrospectedClassFunction[]; + let hasConnect, hasConnectAfter, hasEmit; + + if (node.signals.length > 0) { + hasConnect = node.members.some(m => m.name === "connect"); + hasConnectAfter = node.members.some(m => m.name === "connect_after"); + hasEmit = node.members.some(m => m.name === "emit"); + + if (!hasConnect) { + default_signals.push(Connect); + } + if (!hasConnectAfter) { + default_signals.push(ConnectAfter); + } + if (!hasEmit) { + default_signals.push(Emit); + } + + hasConnect = !default_signals.some(s => s.name === "connect"); + hasConnectAfter = !default_signals.some(s => s.name === "connect_after"); + hasEmit = !default_signals.some(s => s.name === "emit"); } - ) - .replace(/(\s)([a-z_]+)\(\)/g, (original: string, w: string, func: string) => { - const resolved = formatFunctionReference(func); - return resolved != null ? `${w}${resolved}()` : original; - }) - .replace(/%([A-Z_]+)/g, (original: string, identifier: string) => { - const resolved = formatFunctionReference(identifier.toLowerCase(), true); - return resolved != null ? `%${resolved}` : original; - }) - .replace(/#([A-Z_]+)/g, (original: string, identifier: string) => { - const resolved = formatFunctionReference(identifier.toLowerCase(), true); - return resolved != null ? `#${resolved}` : original; - }); - } - - private generateMetadata(metadata: GirMetadata): MetadataJson { - return { ...metadata } as MetadataJson; - } - - private generateParameters(parameters: IntrospectedFunctionParameter[]): ParameterJson[] { - const { namespace, options } = this; - - return parameters.map(p => ({ - kind: NodeKind.parameter, - direction: p.direction, - optional: p.isOptional, - varargs: p.isVarArgs, - name: p.name, - resoleNames: p.resolve_names, - type: generateType(p.type.resolve(namespace, options)), - ...this._generateDocAndMetadata(p) - })); - } - - generateCallbackType(node: IntrospectedCallback): [Json, Json] { - return [{}, {}]; - } - - generateCallback(node: IntrospectedCallback): CallbackJson { - const { namespace, options } = this; - - const parameters = this.generateParameters(node.parameters); - - return { - kind: NodeKind.callback, - name: node.name, - type: this.generateCallbackType(node), - parameters, - returnType: generateType(node.return().resolve(namespace, options)), - ...this._generateDocAndMetadata(node) - }; - } - - generateReturn( - return_type: TypeExpression, - output_parameters: IntrospectedFunctionParameter[] - ): TypeJson | TypeJson[] { - const { namespace, options } = this; - const type = return_type.resolve(namespace, options); - - if (output_parameters.length > 0) { - const exclude_first = type.equals(VoidType); - const returns = [ - ...(exclude_first ? [] : [type]), - ...output_parameters.map(op => op.type.resolve(namespace, options)) - ]; - - return returns.map(r => generateType(r)); + + const SignalsList = [ + ...default_signals.map(s => s.asString(this)), + ...node.signals + .map(s => { + const methods = [] as Json[]; + + if (!hasConnect) methods.push(s.asString(this, IntrospectedSignalType.CONNECT)); + if (!hasConnectAfter) methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER)); + if (!hasEmit) methods.push(s.asString(this, IntrospectedSignalType.EMIT)); + + return methods; + }) + .flat() + ]; + + const Signals = SignalsList; + + return { + kind: NodeKind.class, + abstract: node.isAbstract, + type: generateType(node.getType()), + name: node.name, + mainConstructor: MainConstructor, + signals: Signals, + extends: Extends ? generateType(Extends) : null, + implements: Implements.map(i => generateType(i)), + props: Properties, + fields: Fields, + constructors: Constructors, + methods: Methods, + staticMethods: StaticMethods, + virtualMethods: VirtualMethods, + ...this._generateDocAndMetadata(node) + }; } - return generateType(type); - } - - generateEnum(node: IntrospectedEnum): EnumJson { - return { - kind: NodeKind.enum, - name: node.name, - members: Array.from(node.members.values()).map(member => member.asString(this)), - ...this._generateDocAndMetadata(node) - }; - } - - generateError(node: IntrospectedError): ErrorJson { - const { namespace } = this; - const clazz = node.asClass(); - - clazz.members = []; - clazz.members.push(...Array.from(node.functions.values())); - - const GLib = namespace.assertInstalledImport("GLib"); - const GLibError = GLib.assertClass("Error"); - - clazz.parent = GLibError.getType(); - - // Manually construct a GLib.Error constructor. - clazz.mainConstructor = new IntrospectedConstructor({ - name: "new", - parameters: [ - new IntrospectedFunctionParameter({ - name: "options", - type: NativeType.of("{ message: string, code: number}"), - direction: GirDirection.In - }) - ], - return_type: clazz.getType() - }); - - return { - ...clazz.asString(this), - kind: NodeKind.error - }; - } - - _generateDocAndMetadata(node: GirBase) { - const { options } = this; - - if (options.withDocs) { - return { - private: node.isPrivate, - doc: this.generateDoc(node.doc ?? "") ?? null, - metadata: this.generateMetadata(node.metadata ?? {}) ?? null - }; + generateField(node: Field): FieldJson { + const { namespace, options } = this; + const { name, computed } = node; + const invalid = isInvalid(name); + + const Static = node.isStatic; + const ReadOnly = node.writable; + + return { + kind: NodeKind.field, + readonly: ReadOnly, + static: Static, + computed, + type: generateType(node.type.resolve(namespace, options)), + name: invalid ? `"${name}"` : name, + ...this._generateDocAndMetadata(node) + }; } - return { - private: false, - doc: null, - metadata: null - }; - } - - generateConst(node: IntrospectedConstant): ConstJson { - const { namespace, options } = this; - - return { - kind: NodeKind.constant, - name: node.name, - type: generateType(node.type.resolve(namespace, options)), - ...this._generateDocAndMetadata(node) - }; - } - - private implements(node: IntrospectedClass): TypeIdentifier[] { - const { namespace, options } = this; - - if (node.interfaces.length > 0) { - return node.interfaces - .map(i => i.resolveIdentifier(namespace, options)) - .filter((i): i is TypeIdentifier => i != null); + generateProperty(node: GirProperty, construct: boolean = false): PropertyJson { + const { namespace, options } = this; + + const invalid = isInvalid(node.name); + const ReadOnly = node.writable || construct; + + const Name = invalid ? `"${node.name}"` : node.name; + + const Type = generateType(node.type.resolve(namespace, options)); + return { + kind: NodeKind.prop, + readonly: ReadOnly, + constructOnly: node.constructOnly, + readable: node.readable, + writable: node.writable, + static: false, + type: Type, + name: Name, + ...this._generateDocAndMetadata(node) + }; } - return []; - } + generateSignal( + node: IntrospectedSignal, + type: IntrospectedSignalType = IntrospectedSignalType.CONNECT + ): MethodJson { + switch (type) { + case IntrospectedSignalType.CONNECT: + return node.asConnect(false).asString(this); + case IntrospectedSignalType.CONNECT_AFTER: + return node.asConnect(true).asString(this); + case IntrospectedSignalType.EMIT: + return node.asEmit().asString(this); + } + } - private extends(node: IntrospectedBaseClass): TypeIdentifier | null { - const { namespace: ns, options } = this; + generateEnumMember(node: GirEnumMember): EnumMemberJson { + const invalid = isInvalid(node.name); + + let enumMember: { + name: string; + value: string | null; + }; + + if ( + node.value != null && + !Number.isNaN(Number.parseInt(node.value, 10)) && + Number.isNaN(Number.parseInt(node.name, 10)) && + node.name !== "NaN" + ) { + enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: `${node.value}` }; + } else { + enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: null }; + } - if (node.parent) { - return node.parent.resolveIdentifier(ns, options); + return { + kind: NodeKind.enumMember, + ...enumMember, + ...this._generateDocAndMetadata(node) + }; } - return null; - } + generateParameter(node: IntrospectedFunctionParameter): ParameterJson { + const { namespace, options } = this; - generateInterface(node: GirInterface): InterfaceJson { - const { namespace } = this; - // If an interface does not list a prerequisite type, we fill it with GObject.Object - if (node.parent == null) { - const gobject = namespace.assertInstalledImport("GObject"); + const type = generateType( + resolveDirectedType(node.type, node.direction)?.resolve(namespace, options) ?? + node.type.resolve(namespace, options) + ); + + return { + kind: NodeKind.parameter, + name: node.name, + type, + varargs: node.isVarArgs, + optional: node.isOptional, + ...this._generateDocAndMetadata(node) + }; + } - // TODO Optimize GObject.Object - if (!gobject) { - throw new Error("GObject not generated, all interfaces extend from GObject.Object!"); - } + generateFunction(node: IntrospectedFunction): FunctionJson { + const { namespace } = this; + // Register our identifier with the sanitized identifiers. + // We avoid doing this in fromXML because other class-level function classes + // depends on that code. + sanitizeIdentifierName(namespace.name, node.raw_name); + + const Parameters = this.generateParameters(node.parameters); + const ReturnType = this.generateReturn(node.return(), node.output_parameters); + + return { + kind: NodeKind.function, + name: node.name, + parameters: Parameters, + returnType: ReturnType, + ...this._generateDocAndMetadata(node) + }; + } - const GObject = gobject.getClass("Object"); + generateConstructorFunction(node: IntrospectedConstructor): MethodJson { + const { namespace, options } = this; - if (!GObject) { - throw new Error( - `GObject.Object could not be found while generating ${node.namespace.name}.${node.name}` - ); - } + const Parameters = this.generateParameters(node.parameters); - node.parent = GObject.getType(); + return { + kind: NodeKind.classFunction, + static: true, + name: node.name, + parameters: Parameters, + returnType: generateType(node.return().resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; } - const { name } = node; - - const Extends = this.extends(node); - - const Properties = node.props.map(v => v && v.asString(this)); - - const Methods = node.members - .filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction)) - .map(v => v && v.asString(this)); - const StaticMethods = node.members - .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) - .map(v => v && v.asString(this)); - const VirtualMethods = node.members - .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) - .map(v => v && v.asString(this)); - - return { - kind: NodeKind.interface, - name, - type: generateType(node.getType()), - extends: Extends ? generateType(Extends) : null, - props: Properties, - methods: Methods, - staticMethods: StaticMethods, - virtualMethods: VirtualMethods, - ...this._generateDocAndMetadata(node) - }; - } - - generateRecord(node: GirRecord): RecordJson { - const { name } = node; - - const Extends = this.extends(node); - - const Properties = node.props.map(v => v && v.asString(this)); - - const Fields = node.fields.map(v => v && v.asString(this)); - - const Constructors = node.constructors.map(v => v && this.generateConstructorFunction(v)); - - const Methods = node.members - .filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction)) - .map(v => v && v.asString(this)); - const StaticMethods = node.members - .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) - .map(v => v && v.asString(this)); - const VirtualMethods = node.members - .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) - .map(v => v && v.asString(this)); - - const Callbacks = node.callbacks.map(c => c && c.asString(this)); - - return { - kind: NodeKind.record, - name, - type: generateType(node.getType()), - mainConstructor: node.mainConstructor?.asString(this) ?? null, - extends: Extends ? generateType(Extends) : null, - implements: [], - props: Properties, - fields: Fields, - constructors: Constructors, - methods: Methods, - staticMethods: StaticMethods, - virtualMethods: VirtualMethods, - callbacks: Callbacks, - ...this._generateDocAndMetadata(node) - }; - } - - generateClass(node: IntrospectedClass): ClassJson { - const Extends = this.extends(node); - const Implements = this.implements(node); - - let MainConstructor: PropertiesConstructorJson | ConstructorJson | null = null; - - const ConstructorProps = node.props.map(v => this.generateProperty(v, true)); - - if (node.mainConstructor) { - MainConstructor = this.generateConstructor(node.mainConstructor); - } else { - MainConstructor = { - kind: NodeKind.propertiesConstructor, - name: "new", - private: false, - properties: ConstructorProps.map(p => ({ - kind: NodeKind.parameter, - private: p.private, - varargs: false, - name: p.name, - type: p.type, - doc: p.doc, - metadata: p.metadata, - optional: true - })), - doc: null, - metadata: null - }; + generateConstructor(node: IntrospectedConstructor): ConstructorJson { + return { + name: node.name, + kind: NodeKind.constructor, + parameters: this.generateParameters(node.parameters), + ...this._generateDocAndMetadata(node) + }; } - const Properties = node.props.map(v => v.asString(this)); - - const Fields = node.fields.map(v => v.asString(this)); - - const Constructors = node.constructors.map(v => this.generateConstructorFunction(v)); - - const Methods = node.members - .filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction)) - .map(v => v && v.asString(this)); - const StaticMethods = node.members - .filter((m): m is IntrospectedStaticClassFunction => m instanceof IntrospectedStaticClassFunction) - .map(v => v && v.asString(this)); - const VirtualMethods = node.members - .filter((m): m is IntrospectedVirtualClassFunction => m instanceof IntrospectedVirtualClassFunction) - .map(v => v && v.asString(this)); - - // TODO Move these to a cleaner place. - - const Connect = new IntrospectedClassFunction({ - name: "connect", - parent: node, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: StringType, - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "callback", - type: AnyFunctionType, - direction: GirDirection.In - }) - ], - return_type: NumberType - }); - - const ConnectAfter = new IntrospectedClassFunction({ - name: "connect_after", - parent: node, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: StringType, - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "callback", - type: AnyFunctionType, - direction: GirDirection.In - }) - ], - return_type: NumberType - }); - - const Emit = new IntrospectedClassFunction({ - name: "emit", - parent: node, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: StringType, - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "args", - isVarArgs: true, - type: new ArrayType(AnyType), - direction: GirDirection.In - }) - ], - return_type: VoidType - }); - - let default_signals = [] as IntrospectedClassFunction[]; - let hasConnect, hasConnectAfter, hasEmit; - - if (node.signals.length > 0) { - hasConnect = node.members.some(m => m.name === "connect"); - hasConnectAfter = node.members.some(m => m.name === "connect_after"); - hasEmit = node.members.some(m => m.name === "emit"); - - if (!hasConnect) { - default_signals.push(Connect); - } - if (!hasConnectAfter) { - default_signals.push(ConnectAfter); - } - if (!hasEmit) { - default_signals.push(Emit); - } - - hasConnect = !default_signals.some(s => s.name === "connect"); - hasConnectAfter = !default_signals.some(s => s.name === "connect_after"); - hasEmit = !default_signals.some(s => s.name === "emit"); + generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): ConstructorJson { + return { + name: node.name, + kind: NodeKind.constructor, + parameters: this.generateParameters( + node.fields.map( + field => + new IntrospectedFunctionParameter({ + name: field.name, + direction: GirDirection.In, + type: field.type, + isOptional: true + }) + ) + ), + ...this._generateDocAndMetadata(node) + }; } - const SignalsList = [ - ...default_signals.map(s => s.asString(this)), - ...node.signals - .map(s => { - const methods = [] as Json[]; - - if (!hasConnect) methods.push(s.asString(this, IntrospectedSignalType.CONNECT)); - if (!hasConnectAfter) methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER)); - if (!hasEmit) methods.push(s.asString(this, IntrospectedSignalType.EMIT)); - - return methods; - }) - .flat() - ]; - - const Signals = SignalsList; - - return { - kind: NodeKind.class, - abstract: node.isAbstract, - type: generateType(node.getType()), - name: node.name, - mainConstructor: MainConstructor, - signals: Signals, - extends: Extends ? generateType(Extends) : null, - implements: Implements.map(i => generateType(i)), - props: Properties, - fields: Fields, - constructors: Constructors, - methods: Methods, - staticMethods: StaticMethods, - virtualMethods: VirtualMethods, - ...this._generateDocAndMetadata(node) - }; - } - - generateField(node: Field): FieldJson { - const { namespace, options } = this; - const { name, computed } = node; - const invalid = isInvalid(name); - - const Static = node.isStatic; - const ReadOnly = node.writable; - - return { - kind: NodeKind.field, - readonly: ReadOnly, - static: Static, - computed, - type: generateType(node.type.resolve(namespace, options)), - name: invalid ? `"${name}"` : name, - ...this._generateDocAndMetadata(node) - }; - } - - generateProperty(node: GirProperty, construct: boolean = false): PropertyJson { - const { namespace, options } = this; - - const invalid = isInvalid(node.name); - const ReadOnly = node.writable || construct; - - const Name = invalid ? `"${node.name}"` : node.name; - - let Type = generateType(node.type.resolve(namespace, options)); - return { - kind: NodeKind.prop, - readonly: ReadOnly, - constructOnly: node.constructOnly, - readable: node.readable, - writable: node.writable, - static: false, - type: Type, - name: Name, - ...this._generateDocAndMetadata(node) - }; - } - - generateSignal(node: IntrospectedSignal, type: IntrospectedSignalType = IntrospectedSignalType.CONNECT): MethodJson { - switch (type) { - case IntrospectedSignalType.CONNECT: - return node.asConnect(false).asString(this); - case IntrospectedSignalType.CONNECT_AFTER: - return node.asConnect(true).asString(this); - case IntrospectedSignalType.EMIT: - return node.asEmit().asString(this); + generateClassFunction(node: IntrospectedClassFunction): MethodJson { + const parameters = node.parameters.map(p => this.generateParameter(p)); + const output_parameters = node.output_parameters; + const return_type = node.return(); + + const ReturnType = this.generateReturn(return_type, output_parameters); + + return { + kind: NodeKind.classFunction, + name: node.name, + parameters, + returnType: ReturnType, + ...this._generateDocAndMetadata(node) + }; } - } - - generateEnumMember(node: GirEnumMember): EnumMemberJson { - const invalid = isInvalid(node.name); - - let enumMember: { - name: string; - value: string | null; - }; - - if ( - node.value != null && - !Number.isNaN(Number.parseInt(node.value, 10)) && - Number.isNaN(Number.parseInt(node.name, 10)) && - node.name !== "NaN" - ) { - enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: `${node.value}` }; - } else { - enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: null }; + + generateStaticClassFunction(node: IntrospectedStaticClassFunction): StaticMethodJson { + const parameters = node.parameters.map(p => this.generateParameter(p)); + const output_parameters = node.output_parameters; + const return_type = node.return(); + + const ReturnType = this.generateReturn(return_type, output_parameters); + + return { + kind: NodeKind.staticClassFunction, + name: node.name, + parameters, + returnType: ReturnType, + ...this._generateDocAndMetadata(node) + }; } - return { - kind: NodeKind.enumMember, - ...enumMember, - ...this._generateDocAndMetadata(node) - }; - } + generateAlias(node: IntrospectedAlias): AliasJson { + const { namespace, options } = this; + const type = node.type.resolve(namespace, options); - generateParameter(node: IntrospectedFunctionParameter): ParameterJson { - const { namespace, options } = this; + const { name } = node; - let type = generateType( - resolveDirectedType(node.type, node.direction)?.resolve(namespace, options) ?? - node.type.resolve(namespace, options) - ); + return { + kind: NodeKind.alias, + name, + type: generateType(type.resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } - return { - kind: NodeKind.parameter, - name: node.name, - type, - varargs: node.isVarArgs, - optional: node.isOptional, - ...this._generateDocAndMetadata(node) - }; - } - - generateFunction(node: IntrospectedFunction): FunctionJson { - const { namespace } = this; - // Register our identifier with the sanitized identifiers. - // We avoid doing this in fromXML because other class-level function classes - // depends on that code. - sanitizeIdentifierName(namespace.name, node.raw_name); - - const Parameters = this.generateParameters(node.parameters); - const ReturnType = this.generateReturn(node.return(), node.output_parameters); - - return { - kind: NodeKind.function, - name: node.name, - parameters: Parameters, - returnType: ReturnType, - ...this._generateDocAndMetadata(node) - }; - } - - generateConstructorFunction(node: IntrospectedConstructor): MethodJson { - const { namespace, options } = this; - - const Parameters = this.generateParameters(node.parameters); - - return { - kind: NodeKind.classFunction, - static: true, - name: node.name, - parameters: Parameters, - returnType: generateType(node.return().resolve(namespace, options)), - ...this._generateDocAndMetadata(node) - }; - } - - generateConstructor(node: IntrospectedConstructor): ConstructorJson { - return { - name: node.name, - kind: NodeKind.constructor, - parameters: this.generateParameters(node.parameters), - ...this._generateDocAndMetadata(node) - }; - } - - generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): ConstructorJson { - return { - name: node.name, - kind: NodeKind.constructor, - parameters: this.generateParameters( - node.fields.map( - field => - new IntrospectedFunctionParameter({ - name: field.name, - direction: GirDirection.In, - type: field.type, - isOptional: true - }) - ) - ), - ...this._generateDocAndMetadata(node) - }; - } - - generateClassFunction(node: IntrospectedClassFunction): MethodJson { - let parameters = node.parameters.map(p => this.generateParameter(p)); - let output_parameters = node.output_parameters; - let return_type = node.return(); - - const ReturnType = this.generateReturn(return_type, output_parameters); - - return { - kind: NodeKind.classFunction, - name: node.name, - parameters, - returnType: ReturnType, - ...this._generateDocAndMetadata(node) - }; - } - - generateStaticClassFunction(node: IntrospectedStaticClassFunction): StaticMethodJson { - let parameters = node.parameters.map(p => this.generateParameter(p)); - let output_parameters = node.output_parameters; - let return_type = node.return(); - - const ReturnType = this.generateReturn(return_type, output_parameters); - - return { - kind: NodeKind.staticClassFunction, - name: node.name, - parameters, - returnType: ReturnType, - ...this._generateDocAndMetadata(node) - }; - } - - generateAlias(node: IntrospectedAlias): AliasJson { - const { namespace, options } = this; - const type = node.type.resolve(namespace, options); - - const { name } = node; - - return { - kind: NodeKind.alias, - name, - type: generateType(type.resolve(namespace, options)), - ...this._generateDocAndMetadata(node) - }; - } - - generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): VirtualMethodJson { - return { - ...this.generateClassFunction(node), - kind: NodeKind.virtualClassFunction - }; - } - - async generateNamespace(node: IntrospectedNamespace): Promise { - function shouldGenerate(node: GirBase) { - return node.emit; + generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): VirtualMethodJson { + return { + ...this.generateClassFunction(node), + kind: NodeKind.virtualClassFunction + }; } - const { name, version } = node; - - const members = Array.from(node.members.values()) - .flatMap(m => m) - .filter(shouldGenerate); - - const classes = members.filter((m): m is IntrospectedClass => m instanceof IntrospectedClass).map(m => m.asString(this)); - const interfaces = members - - .filter((m): m is GirInterface => m instanceof GirInterface) - .map(m => m.asString(this)); - const records = members.filter((m): m is GirRecord => m instanceof GirRecord).map(m => m.asString(this)); - const constants = members.filter((m): m is IntrospectedConstant => m instanceof IntrospectedConstant).map(m => m.asString(this)); - const callbacks = members - - .filter((m): m is IntrospectedCallback => m instanceof IntrospectedCallback) - .map(m => m.asString(this)); - // Functions can have overrides. - const functions = [ - ...members - - .filter((m): m is IntrospectedFunction => !(m instanceof IntrospectedCallback) && m instanceof IntrospectedFunction) - .reduce((prev, next) => { - if (!prev.has(next.name)) prev.set(next.name, next.asString(this)); - - return prev; - }, new Map()) - .values() - ]; - const errors = members.filter((m): m is IntrospectedError => m instanceof IntrospectedError).map(m => m.asString(this)); - const enums = members - - .filter((m): m is IntrospectedEnum => !(m instanceof IntrospectedError) && m instanceof IntrospectedEnum) - .map(m => m.asString(this)); - const alias = members.filter((m): m is IntrospectedAlias => m instanceof IntrospectedAlias).map(m => m.asString(this)); - - // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. - const imports = node.getImports(); - - return { - kind: NodeKind.namespace, - name, - version, - imports: Object.fromEntries(imports), - classes, - interfaces, - records, - constants, - functions, - callbacks, - errors, - enums, - alias - }; - } - - async stringifyNamespace(node: IntrospectedNamespace): Promise { - const { namespace, options } = this; - - if (options.verbose) { - console.debug(`Resolving the types of ${namespace.name}...`); + generateNamespace(node: IntrospectedNamespace): Promise { + function shouldGenerate(node: GirBase) { + return node.emit; + } + + const { name, version } = node; + + const members = Array.from(node.members.values()) + .flatMap(m => m) + .filter(shouldGenerate); + + const classes = members + .filter((m): m is IntrospectedClass => m instanceof IntrospectedClass) + .map(m => m.asString(this)); + const interfaces = members + + .filter((m): m is IntrospectedInterface => m instanceof IntrospectedInterface) + .map(m => m.asString(this)); + const records = members + .filter((m): m is IntrospectedRecord => m instanceof IntrospectedRecord) + .map(m => m.asString(this)); + const constants = members + .filter((m): m is IntrospectedConstant => m instanceof IntrospectedConstant) + .map(m => m.asString(this)); + const callbacks = members + + .filter((m): m is IntrospectedCallback => m instanceof IntrospectedCallback) + .map(m => m.asString(this)); + // Functions can have overrides. + const functions = [ + ...members + + .filter( + (m): m is IntrospectedFunction => + !(m instanceof IntrospectedCallback) && m instanceof IntrospectedFunction + ) + .reduce((prev, next) => { + if (!prev.has(next.name)) prev.set(next.name, next.asString(this)); + + return prev; + }, new Map()) + .values() + ]; + const errors = members + .filter((m): m is IntrospectedError => m instanceof IntrospectedError) + .map(m => m.asString(this)); + const enums = members + + .filter((m): m is IntrospectedEnum => !(m instanceof IntrospectedError) && m instanceof IntrospectedEnum) + .map(m => m.asString(this)); + const alias = members + .filter((m): m is IntrospectedAlias => m instanceof IntrospectedAlias) + .map(m => m.asString(this)); + + // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. + const imports = node.getImports(); + + return Promise.resolve({ + kind: NodeKind.namespace, + name, + version, + imports: Object.fromEntries(imports), + classes, + interfaces, + records, + constants, + functions, + callbacks, + errors, + enums, + alias + }); } - try { - const output = await this.generateNamespace(node); + async stringifyNamespace(node: IntrospectedNamespace): Promise { + const { namespace, options } = this; + + if (options.verbose) { + console.debug(`Resolving the types of ${namespace.name}...`); + } + + try { + const output = await this.generateNamespace(node); - if (options.verbose) { - console.debug(`Printing ${namespace.name}...`); - } + if (options.verbose) { + console.debug(`Printing ${namespace.name}...`); + } - if (!output) return null; + if (!output) return null; - return JSON.stringify(output, null, 4); - } catch (err) { - console.error(`Failed to generate namespace: ${node.name}`); - console.error(err); - return null; + return JSON.stringify(output, null, 4); + } catch (err) { + console.error(`Failed to generate namespace: ${node.name}`); + console.error(err); + return null; + } } - } } diff --git a/packages/lib/src/newlib/generics/clutter.ts b/packages/lib/src/newlib/generics/clutter.ts index 7456099fb..247066395 100644 --- a/packages/lib/src/newlib/generics/clutter.ts +++ b/packages/lib/src/newlib/generics/clutter.ts @@ -2,52 +2,52 @@ import { GenericType } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; export default { - namespace: "Clutter", - modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { - if (!inferGenerics) { - return; + namespace: "Clutter", + modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { + if (!inferGenerics) { + return; + } + + const Actor = namespace.assertClass("Actor"); + const Content = namespace.assertClass("Content"); + const LayoutManager = namespace.assertClass("LayoutManager"); + + Actor.addGeneric({ + default: LayoutManager.getType(), + constraint: LayoutManager.getType() + }); + + Actor.addGeneric({ + default: Content.getType(), + constraint: Content.getType() + }); + + Actor.props + .filter(p => p.name === "layout_manager" || p.name === "layoutManager") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("A", Content.getType()); + }); + + Actor.props + .filter(p => p.name === "content") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("B", Content.getType()); + }); + + const Clone = namespace.assertClass("Clone"); + + Clone.addGeneric({ + default: Actor.getType(), + constraint: Actor.getType() + }); + + Clone.props + .filter(p => p.name === "source") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("A", Content.getType()); + }); } - - const Actor = namespace.assertClass("Actor"); - const Content = namespace.assertClass("Content"); - const LayoutManager = namespace.assertClass("LayoutManager"); - - Actor.addGeneric({ - default: LayoutManager.getType(), - constraint: LayoutManager.getType() - }); - - Actor.addGeneric({ - default: Content.getType(), - constraint: Content.getType() - }); - - Actor.props - .filter(p => p.name === "layout_manager" || p.name === "layoutManager") - .forEach(prop => { - // TODO Automatically infer such changes. - prop.type = new GenericType("A", Content.getType()); - }); - - Actor.props - .filter(p => p.name === "content") - .forEach(prop => { - // TODO Automatically infer such changes. - prop.type = new GenericType("B", Content.getType()); - }); - - const Clone = namespace.assertClass("Clone"); - - Clone.addGeneric({ - default: Actor.getType(), - constraint: Actor.getType() - }); - - Clone.props - .filter(p => p.name === "source") - .forEach(prop => { - // TODO Automatically infer such changes. - prop.type = new GenericType("A", Content.getType()); - }); - } }; diff --git a/packages/lib/src/newlib/generics/generify.ts b/packages/lib/src/newlib/generics/generify.ts index 1dd9a0f70..821b319ad 100644 --- a/packages/lib/src/newlib/generics/generify.ts +++ b/packages/lib/src/newlib/generics/generify.ts @@ -11,37 +11,37 @@ import { GenericVisitor } from "./visitor.js"; type NamespaceModifier = (namespace: IntrospectedNamespace, inferGenerics: boolean) => void; function generifyDefinitions(registry: NSRegistry, inferGenerics: boolean, required: boolean = true) { - return (definition: { namespace: string; version?: string; modifier: NamespaceModifier }) => { - const version = definition?.version ?? registry.defaultVersionOf(definition.namespace); - - if (version) { - const ns = registry.namespace(definition.namespace, version); - - if (ns) { - definition.modifier(ns, inferGenerics); - return; - } - } - - if (required) { - console.error(`Failed to generify ${definition.namespace}`); - } - }; + return (definition: { namespace: string; version?: string; modifier: NamespaceModifier }) => { + const version = definition?.version ?? registry.defaultVersionOf(definition.namespace); + + if (version) { + const ns = registry.namespace(definition.namespace, version); + + if (ns) { + definition.modifier(ns, inferGenerics); + return; + } + } + + if (required) { + console.error(`Failed to generify ${definition.namespace}`); + } + }; } export function generify(registry: NSRegistry, inferGenerics: boolean) { - const $ = generifyDefinitions(registry, inferGenerics); + const $ = generifyDefinitions(registry, inferGenerics); - $(gio); - $(glib); + $(gio); + $(glib); - const $_ = generifyDefinitions(registry, inferGenerics, false); + const $_ = generifyDefinitions(registry, inferGenerics, false); - $_(clutter); - $_(st); - $_(meta); + $_(clutter); + $_(st); + $_(meta); - const visitor = new GenericVisitor(registry, inferGenerics); + const visitor = new GenericVisitor(registry, inferGenerics); - registry.registerTransformation(visitor); + registry.registerTransformation(visitor); } diff --git a/packages/lib/src/newlib/generics/gio.ts b/packages/lib/src/newlib/generics/gio.ts index 839d3f474..c63723d02 100644 --- a/packages/lib/src/newlib/generics/gio.ts +++ b/packages/lib/src/newlib/generics/gio.ts @@ -2,65 +2,65 @@ import { AnyType, Generic, GenericType, GenerifiedTypeIdentifier, StringType, Ty import { IntrospectedNamespace } from "../gir/namespace.js"; export default { - namespace: "Gio", - version: "2.0", - modifier: (namespace: IntrospectedNamespace) => { - const AsyncInitable = namespace.getClass("AsyncInitable"); + namespace: "Gio", + version: "2.0", + modifier: (namespace: IntrospectedNamespace) => { + const AsyncInitable = namespace.getClass("AsyncInitable"); - if (!AsyncInitable) { - throw new Error("Gio.AsyncInitable not found."); - } + if (!AsyncInitable) { + throw new Error("Gio.AsyncInitable not found."); + } - const GObject = namespace.assertInstalledImport("GObject").assertClass("Object"); + const GObject = namespace.assertInstalledImport("GObject").assertClass("Object"); - AsyncInitable.addGeneric({ - constraint: GObject.getType(), - default: GObject.getType(), - propagate: false - }); + AsyncInitable.addGeneric({ + constraint: GObject.getType(), + default: GObject.getType(), + propagate: false + }); - const ListModel = namespace.getClass("ListModel"); + const ListModel = namespace.getClass("ListModel"); - if (!ListModel) { - throw new Error("Gio.ListModel not found."); - } + if (!ListModel) { + throw new Error("Gio.ListModel not found."); + } - ListModel.addGeneric({ - default: GObject.getType(), - constraint: GObject.getType() - }); + ListModel.addGeneric({ + default: GObject.getType(), + constraint: GObject.getType() + }); - const ListStore = namespace.getClass("ListStore"); + const ListStore = namespace.getClass("ListStore"); - if (!ListStore) { - throw new Error("Gio.ListStore not found."); - } + if (!ListStore) { + throw new Error("Gio.ListStore not found."); + } - ListStore.addGeneric({ - deriveFrom: ListModel.getType(), - default: GObject.getType(), - constraint: GObject.getType() - }); + ListStore.addGeneric({ + deriveFrom: ListModel.getType(), + default: GObject.getType(), + constraint: GObject.getType() + }); - const Settings = namespace.assertClass("Settings"); + const Settings = namespace.assertClass("Settings"); - Settings.members = Settings.members.map(m => { - if (m.name === "get_value" || m.name === "get_default_value" || m.name === "get_user_value") { - m.generics.push(new Generic(new GenericType("T"), AnyType, undefined, StringType)); - const returnType = m.return().deepUnwrap(); + Settings.members = Settings.members.map(m => { + if (m.name === "get_value" || m.name === "get_default_value" || m.name === "get_user_value") { + m.generics.push(new Generic(new GenericType("T"), AnyType, undefined, StringType)); + const returnType = m.return().deepUnwrap(); - if (returnType instanceof TypeIdentifier && returnType.is("GLib", "Variant")) { - return m.copy({ - returnType: m - .return() - .rewrap(new GenerifiedTypeIdentifier("Variant", "GLib", [new GenericType("T")])) - }); - } + if (returnType instanceof TypeIdentifier && returnType.is("GLib", "Variant")) { + return m.copy({ + returnType: m + .return() + .rewrap(new GenerifiedTypeIdentifier("Variant", "GLib", [new GenericType("T")])) + }); + } - return m; - } + return m; + } - return m; - }); - } + return m; + }); + } }; diff --git a/packages/lib/src/newlib/generics/glib.ts b/packages/lib/src/newlib/generics/glib.ts index cabd05e0c..afffb251e 100644 --- a/packages/lib/src/newlib/generics/glib.ts +++ b/packages/lib/src/newlib/generics/glib.ts @@ -2,21 +2,21 @@ import { AnyType, StringType } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; export default { - namespace: "GLib", - version: "2.0", - modifier: (namespace: IntrospectedNamespace) => { - const HashTable = namespace.getClass("HashTable"); + namespace: "GLib", + version: "2.0", + modifier: (namespace: IntrospectedNamespace) => { + const HashTable = namespace.getClass("HashTable"); - if (!HashTable) { - throw new Error("GLib.HashTable not found."); - } + if (!HashTable) { + throw new Error("GLib.HashTable not found."); + } - HashTable.addGeneric({ - default: StringType - }); + HashTable.addGeneric({ + default: StringType + }); - HashTable.addGeneric({ - default: AnyType - }); - } + HashTable.addGeneric({ + default: AnyType + }); + } }; diff --git a/packages/lib/src/newlib/generics/meta.ts b/packages/lib/src/newlib/generics/meta.ts index b6bd4b2cf..2007381cf 100644 --- a/packages/lib/src/newlib/generics/meta.ts +++ b/packages/lib/src/newlib/generics/meta.ts @@ -2,26 +2,26 @@ import { GenerifiedTypeIdentifier } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; export default { - namespace: "Meta", - modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { - if (!inferGenerics) { - return; - } + namespace: "Meta", + modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { + if (!inferGenerics) { + return; + } - // Connect BackgroundActor to BackgroundContent + // Connect BackgroundActor to BackgroundContent - const LayoutManager = namespace.assertInstalledImport("Clutter").assertClass("LayoutManager"); + const LayoutManager = namespace.assertInstalledImport("Clutter").assertClass("LayoutManager"); - const BackgroundContent = namespace.assertClass("BackgroundContent"); - const BackgroundActor = namespace.assertClass("BackgroundActor"); + const BackgroundContent = namespace.assertClass("BackgroundContent"); + const BackgroundActor = namespace.assertClass("BackgroundActor"); - const parent = BackgroundActor.parent; + const parent = BackgroundActor.parent; - if (parent) { - BackgroundActor.parent = new GenerifiedTypeIdentifier(parent.name, parent.namespace, [ - LayoutManager.getType(), - BackgroundContent.getType() - ]); + if (parent) { + BackgroundActor.parent = new GenerifiedTypeIdentifier(parent.name, parent.namespace, [ + LayoutManager.getType(), + BackgroundContent.getType() + ]); + } } - } }; diff --git a/packages/lib/src/newlib/generics/st.ts b/packages/lib/src/newlib/generics/st.ts index 8e435bcdd..4ab9ae7cb 100644 --- a/packages/lib/src/newlib/generics/st.ts +++ b/packages/lib/src/newlib/generics/st.ts @@ -2,111 +2,109 @@ import { GenericType, GenerifiedTypeIdentifier } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; export default { - namespace: "St", - version: "1.0", - modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { - if (!inferGenerics) { - return; + namespace: "St", + version: "1.0", + modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { + if (!inferGenerics) { + return; + } + + const Bin = namespace.assertClass("Bin"); + const Button = namespace.assertClass("Button"); + const ScrollView = namespace.assertClass("ScrollView"); + const ScrollBar = namespace.assertClass("ScrollBar"); + const Widget = namespace.assertClass("Widget"); + // TODO: Create a way to propagate this generic to child classes. + const Viewport = namespace.assertClass("Viewport"); + const StBoxLayout = namespace.assertClass("BoxLayout"); + + const Clutter = namespace.assertInstalledImport("Clutter"); + + const Actor = Clutter.assertClass("Actor"); + const Content = Clutter.assertClass("Content"); + const Container = Clutter.assertClass("Container"); + const LayoutManager = Clutter.assertClass("LayoutManager"); + const ClutterBoxLayout = Clutter.assertClass("BoxLayout"); + + Widget.addGeneric({ + deriveFrom: Actor.getType(), + default: LayoutManager.getType(), + constraint: LayoutManager.getType() + }); + + Widget.addGeneric({ + deriveFrom: Actor.getType(), + default: Content.getType(), + constraint: Content.getType() + }); + + Viewport.addGeneric({ + deriveFrom: Widget.getType(), + default: LayoutManager.getType(), + constraint: LayoutManager.getType() + }); + + Viewport.addGeneric({ + deriveFrom: Widget.getType(), + default: Content.getType(), + constraint: Content.getType() + }); + + Container.addGeneric({ + default: Actor.getType(), + constraint: Actor.getType() + }); + + StBoxLayout.addGeneric({ + deriveFrom: Container.getType(), + default: Actor.getType(), + constraint: Actor.getType() + }); + + if (StBoxLayout.parent) { + StBoxLayout.parent = new GenerifiedTypeIdentifier(StBoxLayout.parent.name, StBoxLayout.parent.namespace, [ + ClutterBoxLayout.getType() + ]); + } + + Bin.addGeneric({ + default: Actor.getType(), + constraint: Actor.getType() + }); + + Button.addGeneric({ + deriveFrom: Bin.getType(), + default: Actor.getType(), + constraint: Actor.getType() + }); + + const get_hscroll_bar = ScrollView.members.find(member => member.name === "get_hscroll_bar"); + const get_vscroll_bar = ScrollView.members.find(member => member.name === "get_vscroll_bar"); + + if (get_hscroll_bar) { + const fixed_get_h = get_hscroll_bar?.copy({ returnType: ScrollBar.getType() }); + + const index = ScrollView.members.indexOf(get_hscroll_bar); + ScrollView.members.splice(index, 1, fixed_get_h); + } + + if (get_vscroll_bar) { + const fixed_get_v = get_vscroll_bar?.copy({ returnType: ScrollBar.getType() }); + const index = ScrollView.members.indexOf(get_vscroll_bar); + ScrollView.members.splice(index, 1, fixed_get_v); + } + + ScrollView.addGeneric({ + deriveFrom: Bin.getType(), + default: Actor.getType(), + constraint: Actor.getType() + }); + + Bin.props + .filter(p => p.name === "child") + .forEach(prop => { + // TODO Automatically infer such changes. + prop.type = new GenericType("A", Actor.getType()); + }); } - - const Bin = namespace.assertClass("Bin"); - const Button = namespace.assertClass("Button"); - const ScrollView = namespace.assertClass("ScrollView"); - const ScrollBar = namespace.assertClass("ScrollBar"); - const Widget = namespace.assertClass("Widget"); - // TODO: Create a way to propagate this generic to child classes. - const Viewport = namespace.assertClass("Viewport"); - const StBoxLayout = namespace.assertClass("BoxLayout"); - - const Clutter = namespace.assertInstalledImport("Clutter"); - - const Actor = Clutter.assertClass("Actor"); - const Content = Clutter.assertClass("Content"); - const Container = Clutter.assertClass("Container"); - const LayoutManager = Clutter.assertClass("LayoutManager"); - const ClutterBoxLayout = Clutter.assertClass("BoxLayout"); - - Widget.addGeneric({ - deriveFrom: Actor.getType(), - default: LayoutManager.getType(), - constraint: LayoutManager.getType() - }); - - Widget.addGeneric({ - deriveFrom: Actor.getType(), - default: Content.getType(), - constraint: Content.getType() - }); - - Viewport.addGeneric({ - deriveFrom: Widget.getType(), - default: LayoutManager.getType(), - constraint: LayoutManager.getType() - }); - - Viewport.addGeneric({ - deriveFrom: Widget.getType(), - default: Content.getType(), - constraint: Content.getType() - }); - - Container.addGeneric({ - default: Actor.getType(), - constraint: Actor.getType() - }); - - StBoxLayout.addGeneric({ - deriveFrom: Container.getType(), - default: Actor.getType(), - constraint: Actor.getType() - }); - - if (StBoxLayout.parent) { - StBoxLayout.parent = new GenerifiedTypeIdentifier( - StBoxLayout.parent.name, - StBoxLayout.parent.namespace, - [ClutterBoxLayout.getType()] - ); - } - - Bin.addGeneric({ - default: Actor.getType(), - constraint: Actor.getType() - }); - - Button.addGeneric({ - deriveFrom: Bin.getType(), - default: Actor.getType(), - constraint: Actor.getType() - }); - - const get_hscroll_bar = ScrollView.members.find(member => member.name === "get_hscroll_bar"); - const get_vscroll_bar = ScrollView.members.find(member => member.name === "get_vscroll_bar"); - - if (get_hscroll_bar) { - const fixed_get_h = get_hscroll_bar?.copy({ returnType: ScrollBar.getType() }); - - const index = ScrollView.members.indexOf(get_hscroll_bar); - ScrollView.members.splice(index, 1, fixed_get_h); - } - - if (get_vscroll_bar) { - const fixed_get_v = get_vscroll_bar?.copy({ returnType: ScrollBar.getType() }); - const index = ScrollView.members.indexOf(get_vscroll_bar); - ScrollView.members.splice(index, 1, fixed_get_v); - } - - ScrollView.addGeneric({ - deriveFrom: Bin.getType(), - default: Actor.getType(), - constraint: Actor.getType() - }); - - Bin.props - .filter(p => p.name === "child") - .forEach(prop => { - // TODO Automatically infer such changes. - prop.type = new GenericType("A", Actor.getType()); - }); - } }; diff --git a/packages/lib/src/newlib/generics/visitor.ts b/packages/lib/src/newlib/generics/visitor.ts index 33b2c9121..1ab844e03 100644 --- a/packages/lib/src/newlib/generics/visitor.ts +++ b/packages/lib/src/newlib/generics/visitor.ts @@ -1,19 +1,12 @@ +import { ClosureType, GenericType, Generic, TypeIdentifier, GenerifiedTypeIdentifier, ThisType } from "../gir.js"; +import { IntrospectedClass, IntrospectedBaseClass, IntrospectedInterface } from "../gir/class.js"; import { - ClosureType, - GenericType, - Generic, - TypeIdentifier, - GenerifiedTypeIdentifier, - ThisType -} from "../gir.js"; -import { IntrospectedClass, IntrospectedBaseClass, GirInterface } from "../gir/class.js"; -import { - IntrospectedCallback, - IntrospectedFunctionParameter, - IntrospectedFunction, - IntrospectedClassFunction, - IntrospectedStaticClassFunction, - IntrospectedVirtualClassFunction + IntrospectedCallback, + IntrospectedFunctionParameter, + IntrospectedFunction, + IntrospectedClassFunction, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction } from "../gir/function.js"; import { GenericNameGenerator } from "../gir/generics.js"; import { NSRegistry } from "../gir/registry.js"; @@ -21,348 +14,350 @@ import { resolveTypeIdentifier } from "../gir/util.js"; import { GirVisitor } from "../visitor.js"; export class GenericVisitor extends GirVisitor { - registry: NSRegistry; - inferGenerics: boolean; - - constructor(registry: NSRegistry, inferGenerics: boolean) { - super(); + registry: NSRegistry; + inferGenerics: boolean; - this.registry = registry; - this.inferGenerics = inferGenerics; - } + constructor(registry: NSRegistry, inferGenerics: boolean) { + super(); - visitCallback = (node: IntrospectedCallback) => { - if (!this.inferGenerics) { - return node; + this.registry = registry; + this.inferGenerics = inferGenerics; } - const shouldGenerify = node.parameters.some(p => { - const type = p.type.unwrap(); - return type instanceof TypeIdentifier && type.is("GObject", "Object"); - }); - - if (shouldGenerify) { - const generateName = GenericNameGenerator.new(); - - let generics = [] as Generic[]; - - const GenerifiedParameters = node.parameters.map(p => { - const type = p.type.unwrap(); - - if (type instanceof TypeIdentifier && type.is("GObject", "Object")) { - const Identifier = generateName(); - const generic = new GenericType(Identifier, type); - generics.push(new Generic(generic, type)); - - return p.copy({ - type: p.type.rewrap(generic) - }); + visitCallback = (node: IntrospectedCallback) => { + if (!this.inferGenerics) { + return node; } - return p; - }); - - const generified = node.copy({ - parameters: GenerifiedParameters - }); - - generified.generics = generics; - - return generified; - } + const shouldGenerify = node.parameters.some(p => { + const type = p.type.unwrap(); + return type instanceof TypeIdentifier && type.is("GObject", "Object"); + }); - return node; - }; + if (shouldGenerify) { + const generateName = GenericNameGenerator.new(); - visitClass = (node: IntrospectedClass) => { - return this.visitBaseClass(node); - }; + const generics = [] as Generic[]; - visitInterface = (node: GirInterface) => { - return this.visitBaseClass(node); - }; + const GenerifiedParameters = node.parameters.map(p => { + const type = p.type.unwrap(); - visitBaseClass = (_node: T): T => { - const node = _node.copy() as T; + if (type instanceof TypeIdentifier && type.is("GObject", "Object")) { + const Identifier = generateName(); + const generic = new GenericType(Identifier, type); + generics.push(new Generic(generic, type)); - const { namespace } = _node; + return p.copy({ + type: p.type.rewrap(generic) + }); + } - const resolvedParent = node.parent ? resolveTypeIdentifier(namespace, node.parent) : null; - let derivatives = node.generics.filter(generic => generic.parent != null); + return p; + }); - if (node instanceof IntrospectedClass) { - const resolvedInterfaces = node.interfaces - .map(i => resolveTypeIdentifier(namespace, i)) - .filter((c): c is IntrospectedBaseClass => c != null); + const generified = node.copy({ + parameters: GenerifiedParameters + }); - node.interfaces = node.interfaces.map(iface => { - const generic = derivatives.filter(d => d.parent?.is(iface.namespace, iface.name)); + generified.generics = generics; - if (generic.length > 0) { - return new GenerifiedTypeIdentifier( - iface.name, - iface.namespace, - generic.map(g => g.type) - ); + return generified; } - const resolved = resolvedInterfaces.find(i => i.getType().equals(iface)); - - if (resolved) { - if (resolved.generics.length === 1) { - const generic = resolved.generics[0]; - - if (generic.propagate) { - const constrainedGeneric = node.generics.find( - d => generic.constraint && d.constraint?.equals(generic.constraint) - ); - - if (constrainedGeneric) { - return new GenerifiedTypeIdentifier(iface.name, iface.namespace, [constrainedGeneric.type]); - } - - if ( - !generic.defaultType?.equals(node.getType()) && - !generic.constraint?.equals(node.getType()) - ) { - node.addGeneric({ - constraint: generic.constraint ?? undefined, - default: generic.defaultType ?? undefined, - deriveFrom: resolved.getType() - }); - - const firstGeneric = node.generics[node.generics.length - 1]; - - return new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ - firstGeneric.type - ]); - } - } - - return new GenerifiedTypeIdentifier(iface.name, iface.namespace, [node.getType()]); - } + return node; + }; + + visitClass = (node: IntrospectedClass) => { + return this.visitBaseClass(node); + }; + + visitInterface = (node: IntrospectedInterface) => { + return this.visitBaseClass(node); + }; + + visitBaseClass = (_node: T): T => { + const node = _node.copy() as T; + + const { namespace } = _node; + + const resolvedParent = node.parent ? resolveTypeIdentifier(namespace, node.parent) : null; + const derivatives = node.generics.filter(generic => generic.parent != null); + + if (node instanceof IntrospectedClass) { + const resolvedInterfaces = node.interfaces + .map(i => resolveTypeIdentifier(namespace, i)) + .filter((c): c is IntrospectedBaseClass => c != null); + + node.interfaces = node.interfaces.map(iface => { + const generic = derivatives.filter(d => d.parent?.is(iface.namespace, iface.name)); + + if (generic.length > 0) { + return new GenerifiedTypeIdentifier( + iface.name, + iface.namespace, + generic.map(g => g.type) + ); + } + + const resolved = resolvedInterfaces.find(i => i.getType().equals(iface)); + + if (resolved) { + if (resolved.generics.length === 1) { + const generic = resolved.generics[0]; + + if (generic.propagate) { + const constrainedGeneric = node.generics.find( + d => generic.constraint && d.constraint?.equals(generic.constraint) + ); + + if (constrainedGeneric) { + return new GenerifiedTypeIdentifier(iface.name, iface.namespace, [ + constrainedGeneric.type + ]); + } + + if ( + !generic.defaultType?.equals(node.getType()) && + !generic.constraint?.equals(node.getType()) + ) { + node.addGeneric({ + constraint: generic.constraint ?? undefined, + default: generic.defaultType ?? undefined, + deriveFrom: resolved.getType() + }); + + const firstGeneric = node.generics[node.generics.length - 1]; + + return new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + firstGeneric.type + ]); + } + } + + return new GenerifiedTypeIdentifier(iface.name, iface.namespace, [node.getType()]); + } + } + + return iface; + }); } - return iface; - }); - } + if (node.parent) { + const parentType = node.parent; - if (node.parent) { - const parentType = node.parent; - - const generic = derivatives.filter(d => d.parent?.is(parentType.namespace, parentType.name)); - - if (node.parent instanceof GenerifiedTypeIdentifier) { - // Do nothing - } else if (generic.length > 0) { - node.parent = new GenerifiedTypeIdentifier( - parentType.name, - parentType.namespace, - generic.map(g => g.type) - ); - } else { - const resolved = resolvedParent; - - if (resolved?.generics.length === 1) { - const [generic] = resolved.generics; - - if (generic.propagate) { - const constrainedGeneric = node.generics.find( - d => generic.constraint && d.constraint?.equals(generic.constraint) - ); - - if (constrainedGeneric) { - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ - constrainedGeneric.type - ]); - } else { - if ( - !generic.defaultType?.equals(node.getType()) && - !generic.constraint?.equals(node.getType()) - ) { - node.addGeneric({ - constraint: generic.constraint ?? undefined, - default: generic.defaultType ?? undefined, - deriveFrom: resolved.getType() - }); + const generic = derivatives.filter(d => d.parent?.is(parentType.namespace, parentType.name)); - const firstGeneric = node.generics[node.generics.length - 1]; - - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ - firstGeneric.type - ]); - } else if ( - [...node.resolveParents()].some( - c => generic.defaultType && c.identifier.equals(generic.defaultType) - ) - ) { - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ - node.getType() - ]); - } + if (node.parent instanceof GenerifiedTypeIdentifier) { + // Do nothing + } else if (generic.length > 0) { + node.parent = new GenerifiedTypeIdentifier( + parentType.name, + parentType.namespace, + generic.map(g => g.type) + ); + } else { + const resolved = resolvedParent; + + if (resolved?.generics.length === 1) { + const [generic] = resolved.generics; + + if (generic.propagate) { + const constrainedGeneric = node.generics.find( + d => generic.constraint && d.constraint?.equals(generic.constraint) + ); + + if (constrainedGeneric) { + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + constrainedGeneric.type + ]); + } else { + if ( + !generic.defaultType?.equals(node.getType()) && + !generic.constraint?.equals(node.getType()) + ) { + node.addGeneric({ + constraint: generic.constraint ?? undefined, + default: generic.defaultType ?? undefined, + deriveFrom: resolved.getType() + }); + + const firstGeneric = node.generics[node.generics.length - 1]; + + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + firstGeneric.type + ]); + } else if ( + [...node.resolveParents()].some( + c => generic.defaultType && c.identifier.equals(generic.defaultType) + ) + ) { + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.getType() + ]); + } + } + } else if ( + [...node.resolveParents()].some( + c => generic.defaultType && c.identifier.equals(generic.defaultType) + ) + ) { + node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.getType() + ]); + } + } } - } else if ( - [...node.resolveParents()].some( - c => generic.defaultType && c.identifier.equals(generic.defaultType) - ) - ) { - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ - node.getType() - ]); - } } - } - } - return node; - }; - - visitParameter = (node: IntrospectedFunctionParameter) => { - const { inferGenerics } = this; - - const member = node.parent; - - const unwrapped = node.type.unwrap(); - // TODO I need a better system for this, but handling Gio.AsyncReadyCallback is the most common. - - if (inferGenerics && unwrapped instanceof ClosureType) { - const internal = unwrapped.type.unwrap(); - - if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { - if (member instanceof IntrospectedFunction && member.parameters.length >= 2) { - const generified = node.copy({ - type: node.type.rewrap( - new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parameters[0].type]) - ) - }); - - return generified; - } else if (member instanceof IntrospectedStaticClassFunction) { - const generified = node.copy({ - type: node.type.rewrap( - new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parent.getType()]) - ) - }); - - return generified; - } else if (member instanceof IntrospectedClassFunction) { - const generified = node.copy({ - type: node.type.rewrap( - new GenerifiedTypeIdentifier(internal.name, internal.namespace, [ThisType]) - ) - }); - - return generified; + return node; + }; + + visitParameter = (node: IntrospectedFunctionParameter) => { + const { inferGenerics } = this; + + const member = node.parent; + + const unwrapped = node.type.unwrap(); + // TODO I need a better system for this, but handling Gio.AsyncReadyCallback is the most common. + + if (inferGenerics && unwrapped instanceof ClosureType) { + const internal = unwrapped.type.unwrap(); + + if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { + if (member instanceof IntrospectedFunction && member.parameters.length >= 2) { + const generified = node.copy({ + type: node.type.rewrap( + new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parameters[0].type]) + ) + }); + + return generified; + } else if (member instanceof IntrospectedStaticClassFunction) { + const generified = node.copy({ + type: node.type.rewrap( + new GenerifiedTypeIdentifier(internal.name, internal.namespace, [member.parent.getType()]) + ) + }); + + return generified; + } else if (member instanceof IntrospectedClassFunction) { + const generified = node.copy({ + type: node.type.rewrap( + new GenerifiedTypeIdentifier(internal.name, internal.namespace, [ThisType]) + ) + }); + + return generified; + } + } } - } - } - - return node; - }; - - visitFunction = (node: IntrospectedFunction) => { - if (!this.inferGenerics) { - return node; - } - - const unwrapped = node.return_type.unwrap(); - const shouldGenerify = unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "Object"); - if (shouldGenerify) { - const genericReturnType = new GenericType("T", unwrapped); + return node; + }; - const copied = node.copy({ - return_type: genericReturnType - }); + visitFunction = (node: IntrospectedFunction) => { + if (!this.inferGenerics) { + return node; + } - copied.generics.push(new Generic(genericReturnType, unwrapped)); + const unwrapped = node.return_type.unwrap(); + const shouldGenerify = unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "Object"); - return copied; - } + if (shouldGenerify) { + const genericReturnType = new GenericType("T", unwrapped); - return node; - }; + const copied = node.copy({ + return_type: genericReturnType + }); - private generifyStandaloneClassFunction = (node: IntrospectedClassFunction) => { - const unwrapped = node.return().unwrap(); + copied.generics.push(new Generic(genericReturnType, unwrapped)); - if (node.parent.getType().is("GObject", "Object")) { - return node; - } + return copied; + } - if (unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "Object")) { - const genericReturnType = new GenericType("T", unwrapped); + return node; + }; - const copied = node.copy({ - returnType: genericReturnType - }); + private generifyStandaloneClassFunction = (node: IntrospectedClassFunction) => { + const unwrapped = node.return().unwrap(); - copied.generics.push(new Generic(genericReturnType, unwrapped, unwrapped)); + if (node.parent.getType().is("GObject", "Object")) { + return node; + } - return copied; - } + if (unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "Object")) { + const genericReturnType = new GenericType("T", unwrapped); - return node; - }; + const copied = node.copy({ + returnType: genericReturnType + }); - visitStaticClassFunction = (node: IntrospectedStaticClassFunction) => { - if (this.inferGenerics) { - return this.generifyStandaloneClassFunction(node); - } + copied.generics.push(new Generic(genericReturnType, unwrapped, unwrapped)); - return node; - }; - - visitClassFunction = (node: IntrospectedClassFunction) => { - if (node.parent instanceof IntrospectedBaseClass) { - const clazz = node.parent; + return copied; + } - if (clazz.generics.length > 0) { - let returnType = node.return(); + return node; + }; - for (const generic of clazz.generics) { - if (generic.defaultType?.equals(node.return().deepUnwrap())) { - returnType = node.return().rewrap(generic.type); - break; - } + visitStaticClassFunction = (node: IntrospectedStaticClassFunction) => { + if (this.inferGenerics) { + return this.generifyStandaloneClassFunction(node); } - return node.copy({ - parameters: node.parameters.map(p => { - for (const generic of clazz.generics) { - if (generic.defaultType?.equals(p.type.deepUnwrap())) { - return p.copy({ - type: p.type.rewrap(generic.type) - }); - } - } - - return p; - }), - outputParameters: node.output_parameters.map(p => { - for (const generic of clazz.generics) { - if (generic.defaultType?.equals(p.type.unwrap())) { - return p.copy({ - type: p.type.rewrap(generic.type) + return node; + }; + + visitClassFunction = (node: IntrospectedClassFunction) => { + if (node.parent instanceof IntrospectedBaseClass) { + const clazz = node.parent; + + if (clazz.generics.length > 0) { + let returnType = node.return(); + + for (const generic of clazz.generics) { + if (generic.defaultType?.equals(node.return().deepUnwrap())) { + returnType = node.return().rewrap(generic.type); + break; + } + } + + return node.copy({ + parameters: node.parameters.map(p => { + for (const generic of clazz.generics) { + if (generic.defaultType?.equals(p.type.deepUnwrap())) { + return p.copy({ + type: p.type.rewrap(generic.type) + }); + } + } + + return p; + }), + outputParameters: node.output_parameters.map(p => { + for (const generic of clazz.generics) { + if (generic.defaultType?.equals(p.type.unwrap())) { + return p.copy({ + type: p.type.rewrap(generic.type) + }); + } + } + + return p; + }), + returnType }); - } } + } - return p; - }), - returnType - }); - } - } - - if (this.inferGenerics) { - return this.generifyStandaloneClassFunction(node); - } + if (this.inferGenerics) { + return this.generifyStandaloneClassFunction(node); + } - return node; - }; + return node; + }; - visitVirtualClassFunction = (node: IntrospectedVirtualClassFunction) => { - return this.visitClassFunction(node); - }; + visitVirtualClassFunction = (node: IntrospectedVirtualClassFunction) => { + return this.visitClassFunction(node); + }; } diff --git a/packages/lib/src/newlib/gir.ts b/packages/lib/src/newlib/gir.ts index 2b25e05f8..86fb9867e 100644 --- a/packages/lib/src/newlib/gir.ts +++ b/packages/lib/src/newlib/gir.ts @@ -3,538 +3,535 @@ import { GirProperty, Field } from "./gir/property.js"; import { GenerationOptions } from "./types.js"; import { sanitizeIdentifierName } from "./gir/util.js"; -export {IntrospectedBase as GirBase, Options as GirOptions, Metadata as GirMetadata} from './gir/base.js'; +export { IntrospectedBase as GirBase, Options as GirOptions, Metadata as GirMetadata } from "./gir/base.js"; export abstract class TypeExpression { - isPointer = false; + isPointer = false; - abstract equals(type: TypeExpression): boolean; - abstract unwrap(): TypeExpression; + abstract equals(type: TypeExpression): boolean; + abstract unwrap(): TypeExpression; - deepUnwrap(): TypeExpression { - return this.unwrap(); - } + deepUnwrap(): TypeExpression { + return this.unwrap(); + } - abstract rewrap(type: TypeExpression): TypeExpression; - abstract resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression; + abstract rewrap(type: TypeExpression): TypeExpression; + abstract resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression; - abstract print(namespace: IntrospectedNamespace, options: GenerationOptions): string; - rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return this.print(namespace, options); - } + abstract print(namespace: IntrospectedNamespace, options: GenerationOptions): string; + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return this.print(namespace, options); + } } export class TypeIdentifier extends TypeExpression { - readonly name: string; - readonly namespace: string; + readonly name: string; + readonly namespace: string; - constructor(name: string, namespace: string) { - super(); - this.name = name; - this.namespace = namespace; - } + constructor(name: string, namespace: string) { + super(); + this.name = name; + this.namespace = namespace; + } - equals(type: TypeExpression): boolean { - return type instanceof TypeIdentifier && type.name === this.name && type.namespace === this.namespace; - } + equals(type: TypeExpression): boolean { + return type instanceof TypeIdentifier && type.name === this.name && type.namespace === this.namespace; + } - is(namespace: string, name: string) { - return this.namespace === namespace && this.name === name; - } + is(namespace: string, name: string) { + return this.namespace === namespace && this.name === name; + } - unwrap() { - return this; - } + unwrap() { + return this; + } - rewrap(type: TypeExpression): TypeExpression { - return type; - } + rewrap(type: TypeExpression): TypeExpression { + return type; + } - protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { - const type = this; - let name: string = sanitizeIdentifierName(null, type.name); - let ns_name = type.namespace; + protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { + const name: string = sanitizeIdentifierName(null, this.name); + const ns_name = this.namespace; - let ns = namespace.assertInstalledImport(ns_name); + const ns = namespace.assertInstalledImport(ns_name); - if (ns.hasSymbol(name)) { - const c = ns.getClass(name); + if (ns.hasSymbol(name)) { + const c = ns.getClass(name); - // Some records are structs for other class types. - // GirRecord.prototype.getType resolves this relationship. - if (c) return c.getType(); + // Some records are structs for other class types. + // GirRecord.prototype.getType resolves this relationship. + if (c) return c.getType(); - return new TypeIdentifier(name, ns_name); - } + return new TypeIdentifier(name, ns_name); + } - // Handle "class callback" types (they're in a definition-merged module) - let [cb, corrected_name] = ns.findClassCallback(name); - let resolved_name: string | null = null; + // Handle "class callback" types (they're in a definition-merged module) + let [cb, corrected_name] = ns.findClassCallback(name); + let resolved_name: string | null = null; - if (!cb) { - resolved_name = ns.resolveSymbolFromTypeName(name); - } + if (!cb) { + resolved_name = ns.resolveSymbolFromTypeName(name); + } - let c_resolved_name: string | null = null; + let c_resolved_name: string | null = null; - if (!c_resolved_name) { - c_resolved_name = ns.resolveSymbolFromTypeName(`${ns_name}${name}`); - } + if (!c_resolved_name) { + c_resolved_name = ns.resolveSymbolFromTypeName(`${ns_name}${name}`); + } - if (!cb && !resolved_name && !c_resolved_name) { - // Don't warn if a missing import is at fault, this will be dealt with later. - if (namespace.name === ns_name) { - console.error(`Attempting to fall back on c:type inference for ${ns_name}.${name}.`); - } + if (!cb && !resolved_name && !c_resolved_name) { + // Don't warn if a missing import is at fault, this will be dealt with later. + if (namespace.name === ns_name) { + console.error(`Attempting to fall back on c:type inference for ${ns_name}.${name}.`); + } - [cb, corrected_name] = ns.findClassCallback(`${ns_name}${name}`); + [cb, corrected_name] = ns.findClassCallback(`${ns_name}${name}`); - if (cb) { - console.error( - `Falling back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` - ); - } - } + if (cb) { + console.error( + `Falling back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` + ); + } + } - if (cb) { - if (options.verbose) { - console.debug(`Callback found: ${cb}.${corrected_name}`); - } + if (cb) { + if (options.verbose) { + console.debug(`Callback found: ${cb}.${corrected_name}`); + } - return new TypeIdentifier(corrected_name, cb); - } else if (resolved_name) { - return new TypeIdentifier(resolved_name, ns_name); - } else if (c_resolved_name) { - console.error( - `Fell back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` - ); + return new TypeIdentifier(corrected_name, cb); + } else if (resolved_name) { + return new TypeIdentifier(resolved_name, ns_name); + } else if (c_resolved_name) { + console.error( + `Fell back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` + ); - return new TypeIdentifier(c_resolved_name, ns_name); - } else if (namespace.name === ns_name) { - console.error(`Unable to resolve type ${type.name} in same namespace ${ns_name}!`); - return null; - } + return new TypeIdentifier(c_resolved_name, ns_name); + } else if (namespace.name === ns_name) { + console.error(`Unable to resolve type ${this.name} in same namespace ${ns_name}!`); + return null; + } - console.error(`Type ${type.namespace}.${type.name} could not be resolved in ${namespace.name}`); - return null; - } + console.error(`Type ${this.namespace}.${this.name} could not be resolved in ${namespace.name}`); + return null; + } - resolveIdentifier(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { - return this._resolve(namespace, options); - } + resolveIdentifier(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { + return this._resolve(namespace, options); + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const resolved = this._resolve(namespace, options); + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + const resolved = this._resolve(namespace, options); - // Generally if we can't resolve a type it is not introspectable, - // thus we annotate it as "never". - return resolved ?? NeverType; - } + // Generally if we can't resolve a type it is not introspectable, + // thus we annotate it as "never". + return resolved ?? NeverType; + } - static new({ name, namespace }: { name: string; namespace: string }) { - return new TypeIdentifier(name, namespace); - } + static new({ name, namespace }: { name: string; namespace: string }) { + return new TypeIdentifier(name, namespace); + } - print(namespace: IntrospectedNamespace, _options: GenerationOptions): string { - if (namespace.name === this.namespace) { - return `${this.name}`; - } else { - return `${this.namespace}.${this.name}`; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + if (namespace.name === this.namespace) { + return `${this.name}`; + } else { + return `${this.namespace}.${this.name}`; + } } - } } export class GenerifiedTypeIdentifier extends TypeIdentifier { - generics: TypeExpression[]; + generics: TypeExpression[]; - constructor(name: string, namespace: string, generics: TypeExpression[] = []) { - super(name, namespace); - this.generics = generics; - } + constructor(name: string, namespace: string, generics: TypeExpression[] = []) { + super(name, namespace); + this.generics = generics; + } - print(namespace: IntrospectedNamespace, _options: GenerationOptions): string { - const Generics = this.generics.map(generic => generic.print(namespace, _options)).join(", "); + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + const Generics = this.generics.map(generic => generic.print(namespace, options)).join(", "); - if (namespace.name === this.namespace) { - return `${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; - } else { - return `${this.namespace}.${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + if (namespace.name === this.namespace) { + return `${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + } else { + return `${this.namespace}.${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + } } - } - _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { - const iden = super._resolve(namespace, options); + _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { + const iden = super._resolve(namespace, options); - if (iden) { - return new GenerifiedTypeIdentifier(iden.name, iden.namespace, [...this.generics]); - } + if (iden) { + return new GenerifiedTypeIdentifier(iden.name, iden.namespace, [...this.generics]); + } - return iden; - } + return iden; + } } export class NativeType extends TypeExpression { - readonly expression: (options?: GenerationOptions) => string; + readonly expression: (options?: GenerationOptions) => string; - constructor(expression: ((options?: GenerationOptions) => string) | string) { - super(); + constructor(expression: ((options?: GenerationOptions) => string) | string) { + super(); - this.expression = typeof expression === "string" ? () => expression : expression; - } + this.expression = typeof expression === "string" ? () => expression : expression; + } - rewrap(type: TypeExpression): TypeExpression { - return type; - } + rewrap(type: TypeExpression): TypeExpression { + return type; + } - resolve(_namespace: IntrospectedNamespace, _options: GenerationOptions): TypeExpression { - return this; - } + resolve(): TypeExpression { + return this; + } - print(_namespace: IntrospectedNamespace, options: GenerationOptions) { - return this.expression(options); - } + print(_namespace: IntrospectedNamespace, options: GenerationOptions) { + return this.expression(options); + } - equals(type: TypeExpression, options?: GenerationOptions): boolean { - return type instanceof NativeType && this.expression(options) === type.expression(options); - } + equals(type: TypeExpression, options?: GenerationOptions): boolean { + return type instanceof NativeType && this.expression(options) === type.expression(options); + } - unwrap(): TypeExpression { - return this; - } + unwrap(): TypeExpression { + return this; + } - static withGenerator(generator: (options?: GenerationOptions) => string): TypeExpression { - return new NativeType(generator); - } + static withGenerator(generator: (options?: GenerationOptions) => string): TypeExpression { + return new NativeType(generator); + } - static of(nativeType: string) { - return new NativeType(nativeType); - } + static of(nativeType: string) { + return new NativeType(nativeType); + } } export class OrType extends TypeExpression { - readonly types: ReadonlyArray; + readonly types: ReadonlyArray; - constructor(type: TypeExpression, ...types: TypeExpression[]) { - super(); - this.types = [type, ...types]; - } + constructor(type: TypeExpression, ...types: TypeExpression[]) { + super(); + this.types = [type, ...types]; + } - rewrap(type: TypeExpression): TypeExpression { - return type; - } + rewrap(type: TypeExpression): TypeExpression { + return type; + } - unwrap(): TypeExpression { - return this; - } + unwrap(): TypeExpression { + return this; + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const [type, ...types] = this.types; + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + const [type, ...types] = this.types; - return new OrType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); - } + return new OrType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); + } - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `(${this.types.map(t => t.print(namespace, options)).join(" | ")})`; - } + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return `(${this.types.map(t => t.print(namespace, options)).join(" | ")})`; + } - rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `${this.types.map(t => t.print(namespace, options)).join(" | ")}`; - } + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return `${this.types.map(t => t.print(namespace, options)).join(" | ")}`; + } - equals(type: TypeExpression) { - if (type instanceof OrType) { - return this.types.every(t => type.types.some(type => type.equals(t))); - } else { - return false; + equals(type: TypeExpression) { + if (type instanceof OrType) { + return this.types.every(t => type.types.some(type => type.equals(t))); + } else { + return false; + } } - } } export class TupleType extends OrType { - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `[${this.types.map(t => t.print(namespace, options)).join(", ")}]`; - } + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return `[${this.types.map(t => t.print(namespace, options)).join(", ")}]`; + } - rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return this.print(namespace, options); - } + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return this.print(namespace, options); + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const [type, ...types] = this.types; + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + const [type, ...types] = this.types; - return new TupleType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); - } + return new TupleType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); + } - equals(type: TypeExpression) { - if (type instanceof TupleType) { - return this.types.length === type.types.length && this.types.every((t, i) => type.types[i].equals(t)); - } else { - return false; + equals(type: TypeExpression) { + if (type instanceof TupleType) { + return this.types.length === type.types.length && this.types.every((t, i) => type.types[i].equals(t)); + } else { + return false; + } } - } } export class BinaryType extends OrType { - constructor(primary: TypeExpression, secondary: TypeExpression) { - super(primary, secondary); - } + constructor(primary: TypeExpression, secondary: TypeExpression) { + super(primary, secondary); + } - unwrap(): TypeExpression { - return this; - } + unwrap(): TypeExpression { + return this; + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { - return new BinaryType(this.a.resolve(namespace, options), this.b.resolve(namespace, options)); - } + resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { + return new BinaryType(this.a.resolve(namespace, options), this.b.resolve(namespace, options)); + } - is(_namespace: string | null, _name: string) { - return false; - } + is() { + return false; + } - get a() { - return this.types[0]; - } + get a() { + return this.types[0]; + } - get b() { - return this.types[1]; - } + get b() { + return this.types[1]; + } } export class FunctionType extends TypeExpression { - parameterTypes: { [name: string]: TypeExpression }; - returnType: TypeExpression; - - constructor(parameters: { [name: string]: TypeExpression }, returnType: TypeExpression) { - super(); - - this.parameterTypes = parameters; - this.returnType = returnType; - } - - equals(type: TypeExpression): boolean { - if (type instanceof FunctionType) { - return ( - Object.values(this.parameterTypes).every(t => - Object.values(type.parameterTypes).some(tp => t.equals(tp)) - ) && - Object.values(type.parameterTypes).every(t => - Object.values(this.parameterTypes).some(tp => t.equals(tp)) - ) && - this.returnType.equals(type.returnType) - ); - } - - return false; - } - - rewrap(type: TypeExpression): TypeExpression { - return type; - } - - unwrap(): TypeExpression { - return this; - } - - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - return new FunctionType( - Object.fromEntries( - Object.entries(this.parameterTypes).map(([k, p]) => { - return [k, p.resolve(namespace, options)]; - }) - ), - this.returnType.resolve(namespace, options) - ); - } - - rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - const Parameters = Object.entries(this.parameterTypes) - .map(([k, v]) => { - return `${k}: ${v.rootPrint(namespace, options)}`; - }) - .join(", "); - - return `(${Parameters}) => ${this.returnType.print(namespace, options)}`; - } - - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `(${this.rootPrint(namespace, options)})`; - } + parameterTypes: { [name: string]: TypeExpression }; + returnType: TypeExpression; + + constructor(parameters: { [name: string]: TypeExpression }, returnType: TypeExpression) { + super(); + + this.parameterTypes = parameters; + this.returnType = returnType; + } + + equals(type: TypeExpression): boolean { + if (type instanceof FunctionType) { + return ( + Object.values(this.parameterTypes).every(t => + Object.values(type.parameterTypes).some(tp => t.equals(tp)) + ) && + Object.values(type.parameterTypes).every(t => + Object.values(this.parameterTypes).some(tp => t.equals(tp)) + ) && + this.returnType.equals(type.returnType) + ); + } + + return false; + } + + rewrap(type: TypeExpression): TypeExpression { + return type; + } + + unwrap(): TypeExpression { + return this; + } + + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + return new FunctionType( + Object.fromEntries( + Object.entries(this.parameterTypes).map(([k, p]) => { + return [k, p.resolve(namespace, options)]; + }) + ), + this.returnType.resolve(namespace, options) + ); + } + + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { + const Parameters = Object.entries(this.parameterTypes) + .map(([k, v]) => { + return `${k}: ${v.rootPrint(namespace, options)}`; + }) + .join(", "); + + return `(${Parameters}) => ${this.returnType.print(namespace, options)}`; + } + + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return `(${this.rootPrint(namespace, options)})`; + } } export class Generic { - private _deriveFrom: TypeIdentifier | null; - private _genericType: GenericType; - private _defaultType: TypeExpression | null; - private _constraint: TypeExpression | null; - private _propagate: boolean; - - constructor( - genericType: GenericType, - defaultType?: TypeExpression, - deriveFrom?: TypeIdentifier, - constraint?: TypeExpression, - propagate = true - ) { - this._genericType = genericType; - this._defaultType = defaultType ?? null; - this._deriveFrom = deriveFrom ?? null; - this._constraint = constraint ?? null; - this._propagate = propagate; - } - - unwrap() { - return this.type; - } - - get propagate() { - return this._propagate; - } - - get type() { - return this._genericType; - } - - get defaultType() { - return this._defaultType; - } - - get constraint() { - return this._constraint; - } - - get parent() { - return this._deriveFrom; - } + private _deriveFrom: TypeIdentifier | null; + private _genericType: GenericType; + private _defaultType: TypeExpression | null; + private _constraint: TypeExpression | null; + private _propagate: boolean; + + constructor( + genericType: GenericType, + defaultType?: TypeExpression, + deriveFrom?: TypeIdentifier, + constraint?: TypeExpression, + propagate = true + ) { + this._genericType = genericType; + this._defaultType = defaultType ?? null; + this._deriveFrom = deriveFrom ?? null; + this._constraint = constraint ?? null; + this._propagate = propagate; + } + + unwrap() { + return this.type; + } + + get propagate() { + return this._propagate; + } + + get type() { + return this._genericType; + } + + get defaultType() { + return this._defaultType; + } + + get constraint() { + return this._constraint; + } + + get parent() { + return this._deriveFrom; + } } export class GenerifiedType extends TypeExpression { - type: TypeExpression; - generic: GenericType; - - constructor(type: TypeExpression, generic: GenericType) { - super(); + type: TypeExpression; + generic: GenericType; - this.type = type; - this.generic = generic; - } + constructor(type: TypeExpression, generic: GenericType) { + super(); - resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { - return new GenerifiedType( - this.type.resolve(namespace, options), - this.generic.resolve(namespace, options) - ); - } + this.type = type; + this.generic = generic; + } - unwrap() { - return this.type; - } + resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { + return new GenerifiedType(this.type.resolve(namespace, options), this.generic.resolve()); + } - rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions) { - return `${this.type.print(namespace, options)}<${this.generic.print(namespace, options)}>`; - } + unwrap() { + return this.type; + } - print(namespace: IntrospectedNamespace, options: GenerationOptions) { - return `${this.type.print(namespace, options)}<${this.generic.print(namespace, options)}>`; - } + rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions) { + return `${this.type.print(namespace, options)}<${this.generic.print()}>`; + } - equals(type: TypeExpression): boolean { - if (type instanceof GenerifiedType) { - return type.type.equals(this.type) && type.generic.equals(this.generic); + print(namespace: IntrospectedNamespace, options: GenerationOptions) { + return `${this.type.print(namespace, options)}<${this.generic.print()}>`; } - return false; - } + equals(type: TypeExpression): boolean { + if (type instanceof GenerifiedType) { + return type.type.equals(this.type) && type.generic.equals(this.generic); + } + + return false; + } - rewrap(type: TypeExpression): TypeExpression { - return new GenerifiedType(this.type.rewrap(type), this.generic); - } + rewrap(type: TypeExpression): TypeExpression { + return new GenerifiedType(this.type.rewrap(type), this.generic); + } } export class GenericType extends TypeExpression { - identifier: string; - replacedType?: TypeExpression; - - constructor(identifier: string, replacedType?: TypeExpression) { - super(); - this.identifier = identifier; - this.replacedType = replacedType; - } + identifier: string; + replacedType?: TypeExpression; - equals(type: TypeExpression): boolean { - if (type instanceof GenericType) { - return type.identifier === this.identifier; + constructor(identifier: string, replacedType?: TypeExpression) { + super(); + this.identifier = identifier; + this.replacedType = replacedType; } - return false; - } + equals(type: TypeExpression): boolean { + if (type instanceof GenericType) { + return type.identifier === this.identifier; + } + + return false; + } - unwrap(): TypeExpression { - return this; - } + unwrap(): TypeExpression { + return this; + } - rewrap(type: TypeExpression): TypeExpression { - return type; - } + rewrap(type: TypeExpression): TypeExpression { + return type; + } - resolve(_namespace: IntrospectedNamespace, _options: GenerationOptions): GenericType { - return this; - } + resolve(): GenericType { + return this; + } - print(_namespace: IntrospectedNamespace, _options: GenerationOptions): string { - return `${this.identifier}`; - } + print(): string { + return `${this.identifier}`; + } } export class NullableType extends BinaryType { - constructor(type: TypeExpression) { - super(type, NullType); - } + constructor(type: TypeExpression) { + super(type, NullType); + } - unwrap() { - return this.type; - } + unwrap() { + return this.type; + } - rewrap(type: TypeExpression): TypeExpression { - return new NullableType(this.type.rewrap(type)); - } + rewrap(type: TypeExpression): TypeExpression { + return new NullableType(this.type.rewrap(type)); + } - get type() { - return this.a; - } + get type() { + return this.a; + } } export class PromiseType extends TypeExpression { - type: TypeExpression; - - constructor(type: TypeExpression) { - super(); - this.type = type; - } + type: TypeExpression; - equals(type: TypeExpression): boolean { - return type instanceof PromiseType && type.type.equals(this.type); - } + constructor(type: TypeExpression) { + super(); + this.type = type; + } - unwrap() { - return this.type; - } + equals(type: TypeExpression): boolean { + return type instanceof PromiseType && type.type.equals(this.type); + } - rewrap(type: TypeExpression): TypeExpression { - return new PromiseType(this.type.rewrap(type)); - } + unwrap() { + return this.type; + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - return new PromiseType(this.type.resolve(namespace, options)); - } + rewrap(type: TypeExpression): TypeExpression { + return new PromiseType(this.type.rewrap(type)); + } - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - // TODO: Optimize this check. - if (!namespace.hasSymbol("Promise")) { - return `Promise<${this.type.print(namespace, options)}>`; + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + return new PromiseType(this.type.resolve(namespace, options)); } - return `globalThis.Promise<${this.type.print(namespace, options)}>`; - } + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + // TODO: Optimize this check. + if (!namespace.hasSymbol("Promise")) { + return `Promise<${this.type.print(namespace, options)}>`; + } + + return `globalThis.Promise<${this.type.print(namespace, options)}>`; + } } /** @@ -550,11 +547,11 @@ export class PromiseType extends TypeExpression { * used as truthy. */ export enum ConflictType { - PROPERTY_NAME_CONFLICT = 1, - FIELD_NAME_CONFLICT, - FUNCTION_NAME_CONFLICT, - ACCESSOR_PROPERTY_CONFLICT, - PROPERTY_ACCESSOR_CONFLICT + PROPERTY_NAME_CONFLICT = 1, + FIELD_NAME_CONFLICT, + FUNCTION_NAME_CONFLICT, + ACCESSOR_PROPERTY_CONFLICT, + PROPERTY_ACCESSOR_CONFLICT } /** @@ -569,174 +566,174 @@ export enum ConflictType { * resolve the conflicts so the typing stays sound. */ export class TypeConflict extends TypeExpression { - readonly conflictType: ConflictType; - readonly type: TypeExpression; - - constructor(type: TypeExpression, conflictType: ConflictType) { - super(); - this.type = type; - this.conflictType = conflictType; - } - - rewrap(type: TypeExpression) { - return new TypeConflict(this.type.rewrap(type), this.conflictType); - } - - unwrap() { - return this.type; - } - - // TODO: This constant "true" is a remnant of the Anyified type. - equals(_type: TypeExpression) { - return true; - } - - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - throw new Error( - `Type conflict was not resolved for ${this.type - .resolve(namespace, options) - .print(namespace, options)} in ${namespace}` - ); - } - - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - throw new Error( - `Type conflict was not resolved for ${this.type - .resolve(namespace, options) - .print(namespace, options)} in ${namespace}` - ); - } + readonly conflictType: ConflictType; + readonly type: TypeExpression; + + constructor(type: TypeExpression, conflictType: ConflictType) { + super(); + this.type = type; + this.conflictType = conflictType; + } + + rewrap(type: TypeExpression) { + return new TypeConflict(this.type.rewrap(type), this.conflictType); + } + + unwrap() { + return this.type; + } + + // TODO: This constant "true" is a remnant of the Anyified type. + equals() { + return true; + } + + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + throw new Error( + `Type conflict was not resolved for ${this.type.resolve(namespace, options).print(namespace, options)} in ${ + namespace.name + }` + ); + } + + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + throw new Error( + `Type conflict was not resolved for ${this.type.resolve(namespace, options).print(namespace, options)} in ${ + namespace.name + }` + ); + } } export class ClosureType extends TypeExpression { - type: TypeExpression; - user_data: number | null = null; - - constructor(type: TypeExpression) { - super(); - this.type = type; - } + type: TypeExpression; + user_data: number | null = null; - equals(type: TypeExpression): boolean { - if (type instanceof ClosureType) { - const closureType = type; - return this.type.equals(closureType.type); + constructor(type: TypeExpression) { + super(); + this.type = type; } - return false; - } + equals(type: TypeExpression): boolean { + if (type instanceof ClosureType) { + const closureType = type; + return this.type.equals(closureType.type); + } - deepUnwrap(): TypeExpression { - return this.type; - } + return false; + } - rewrap(type: TypeExpression): TypeExpression { - const closure = new ClosureType(this.type.rewrap(type)); + deepUnwrap(): TypeExpression { + return this.type; + } - closure.user_data = this.user_data; + rewrap(type: TypeExpression): TypeExpression { + const closure = new ClosureType(this.type.rewrap(type)); - return closure; - } + closure.user_data = this.user_data; - unwrap(): TypeExpression { - return this; - } + return closure; + } + + unwrap(): TypeExpression { + return this; + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { - const { user_data, type } = this; + resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { + const { user_data, type } = this; - return ClosureType.new({ - user_data, - type: type.resolve(namespace, options) - }); - } + return ClosureType.new({ + user_data, + type: type.resolve(namespace, options) + }); + } - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return this.type.print(namespace, options); - } + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + return this.type.print(namespace, options); + } - static new({ type, user_data = null }: { type: TypeExpression; user_data?: number | null }) { - const vt = new ClosureType(type); - vt.user_data = user_data; - return vt; - } + static new({ type, user_data = null }: { type: TypeExpression; user_data?: number | null }) { + const vt = new ClosureType(type); + vt.user_data = user_data; + return vt; + } } export class ArrayType extends TypeExpression { - type: TypeExpression; - arrayDepth: number = 1; - length: number | null = null; + type: TypeExpression; + arrayDepth: number = 1; + length: number | null = null; + + constructor(type: TypeExpression) { + super(); + this.type = type; + } - constructor(type: TypeExpression) { - super(); - this.type = type; - } + deepUnwrap(): TypeExpression { + return this.type; + } - deepUnwrap(): TypeExpression { - return this.type; - } + unwrap(): TypeExpression { + return this; + } - unwrap(): TypeExpression { - return this; - } + rewrap(type: TypeExpression): TypeExpression { + const array = new ArrayType(this.type.rewrap(type)); - rewrap(type: TypeExpression): TypeExpression { - const array = new ArrayType(this.type.rewrap(type)); + array.arrayDepth = this.arrayDepth; + array.length = this.length; - array.arrayDepth = this.arrayDepth; - array.length = this.length; + return array; + } - return array; - } + equals(type: TypeExpression) { + if (type instanceof ArrayType) { + const arrayType: ArrayType = type; - equals(type: TypeExpression) { - if (type instanceof ArrayType) { - const arrayType: ArrayType = type; + return arrayType.type.equals(this.type) && type.arrayDepth === this.arrayDepth; + } - return arrayType.type.equals(this.type) && type.arrayDepth === this.arrayDepth; + return false; } - return false; - } + resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { + const { type, arrayDepth, length } = this; + return ArrayType.new({ + type: type.resolve(namespace, options), + arrayDepth, + length + }); + } - resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const { type, arrayDepth, length } = this; - return ArrayType.new({ - type: type.resolve(namespace, options), - arrayDepth, - length - }); - } + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + const depth = this.arrayDepth; + let typeSuffix: string = ""; - print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - const depth = this.arrayDepth; - let typeSuffix: string = ""; + if (depth === 0) { + typeSuffix = ""; + } else if (depth === 1) { + typeSuffix = "[]"; + } else { + typeSuffix = "".padStart(2 * depth, "[]"); + } - if (depth === 0) { - typeSuffix = ""; - } else if (depth === 1) { - typeSuffix = "[]"; - } else { - typeSuffix = "".padStart(2 * depth, "[]"); + return `${this.type.print(namespace, options)}${typeSuffix}`; } - return `${this.type.print(namespace, options)}${typeSuffix}`; - } - - static new({ - type, - arrayDepth = 1, - length = null - }: { - type: TypeExpression; - length?: number | null; - arrayDepth?: number; - }) { - const vt = new ArrayType(type); - vt.length = length; - vt.arrayDepth = arrayDepth; - return vt; - } + static new({ + type, + arrayDepth = 1, + length = null + }: { + type: TypeExpression; + length?: number | null; + arrayDepth?: number; + }) { + const vt = new ArrayType(type); + vt.length = length; + vt.arrayDepth = arrayDepth; + return vt; + } } export const GTypeType = new TypeIdentifier("GType", "GObject"); diff --git a/packages/lib/src/newlib/gir/alias.ts b/packages/lib/src/newlib/gir/alias.ts index 1dc9da106..b1ebd03b5 100644 --- a/packages/lib/src/newlib/gir/alias.ts +++ b/packages/lib/src/newlib/gir/alias.ts @@ -1,5 +1,5 @@ -import { TypeExpression } from "../gir.js"; -import {IntrospectedBase as IntrospectedBase, Options} from './base.js'; +import { TypeExpression } from "../gir.js"; +import { IntrospectedBase as IntrospectedBase, Options } from "./base.js"; import { GirAliasElement } from "../../index.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; @@ -9,66 +9,66 @@ import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; export class IntrospectedAlias extends IntrospectedBase { - readonly type: TypeExpression; - readonly generics: GenericDescriptor[]; + readonly type: TypeExpression; + readonly generics: GenericDescriptor[]; - constructor({ - name, - type, - generics = [], - ...args - }: Options<{ - name: string; - type: TypeExpression; - generics?: GenericDescriptor[]; - }>) { - super(name, { ...args }); + constructor({ + name, + type, + generics = [], + ...args + }: Options<{ + name: string; + type: TypeExpression; + generics?: GenericDescriptor[]; + }>) { + super(name, { ...args }); - this.type = type; - this.generics = generics; - } - - accept(visitor: GirVisitor): IntrospectedAlias { - const node = this.copy({ - type: visitor.visitType?.(this.type) - }); + this.type = type; + this.generics = generics; + } - return visitor.visitAlias?.(node) ?? node; - } + accept(visitor: GirVisitor): IntrospectedAlias { + const node = this.copy({ + type: visitor.visitType?.(this.type) + }); - copy(options?: { parent?: undefined; type?: TypeExpression }): IntrospectedAlias { - const { name, type } = this; + return visitor.visitAlias?.(node) ?? node; + } - return new IntrospectedAlias({ name, type: options?.type ?? type })._copyBaseProperties(this); - } + copy(options?: { parent?: undefined; type?: TypeExpression }): IntrospectedAlias { + const { name, type } = this; - asString>(generator: T): ReturnType { - return generator.generateAlias(this); - } + return new IntrospectedAlias({ name, type: options?.type ?? type })._copyBaseProperties(this); + } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - m: GirAliasElement - ): IntrospectedAlias | null { - if (!m.$.name) { - console.error(`Alias in ${modName} lacks name.`); - return null; + asString>(generator: T): ReturnType { + return generator.generateAlias(this) as ReturnType; } - const alias = new IntrospectedAlias({ - name: sanitizeIdentifierName(ns.name, m.$.name), - type: getAliasType(modName, ns, m), - isIntrospectable: isIntrospectable(m) - }); + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + m: GirAliasElement + ): IntrospectedAlias | null { + if (!m.$.name) { + console.error(`Alias in ${modName} lacks name.`); + return null; + } - if (options.loadDocs) { - alias.doc = parseDoc(m); - alias.metadata = parseMetadata(m); - } + const alias = new IntrospectedAlias({ + name: sanitizeIdentifierName(ns.name, m.$.name), + type: getAliasType(modName, ns, m), + isIntrospectable: isIntrospectable(m) + }); + + if (options.loadDocs) { + alias.doc = parseDoc(m); + alias.metadata = parseMetadata(m); + } - return alias; - } + return alias; + } } diff --git a/packages/lib/src/newlib/gir/base.ts b/packages/lib/src/newlib/gir/base.ts index f3a1b9dcd..e7e548de7 100644 --- a/packages/lib/src/newlib/gir/base.ts +++ b/packages/lib/src/newlib/gir/base.ts @@ -8,16 +8,16 @@ export interface Metadata { deprecatedVersion?: string; deprecatedDoc?: string; introducedVersion?: string; - } - - export interface BaseOptions { +} + +export interface BaseOptions { isPrivate?: boolean; isIntrospectable?: boolean; - } - - export type Options = BaseOptions & T; - - export abstract class IntrospectedBase { +} + +export type Options = BaseOptions & T; + +export abstract class IntrospectedBase { name: string; doc?: string | null; metadata?: Metadata; @@ -27,14 +27,14 @@ export interface Metadata { private _commentWarning?: string; private _isPrivate: boolean; private _isIntrospectable: boolean; - + constructor(name: string, options: BaseOptions = {}) { - this.name = name; - - this._isPrivate = options.isPrivate ?? false; - this._isIntrospectable = options.isIntrospectable ?? true; + this.name = name; + + this._isPrivate = options.isPrivate ?? false; + this._isIntrospectable = options.isIntrospectable ?? true; } - + /** * Set a warning to be emitted with this node. Often used to note type * conflicts or potential differences from GJS code. @@ -42,61 +42,65 @@ export interface Metadata { * @param warning */ setWarning(warning: string) { - this._commentWarning = warning; + this._commentWarning = warning; } - + getWarning(): string | undefined { - return this._commentWarning; + return this._commentWarning; } - + get isIntrospectable() { - return this._isIntrospectable; + return this._isIntrospectable; } - + get isPrivate() { - return this._isPrivate; + return this._isPrivate; } - + setPrivate(priv: boolean) { - this._isPrivate = priv; + this._isPrivate = priv; } - + noEmit() { - this._emit = false; + this._emit = false; } - + get emit() { - return this._emit; + return this._emit; } - + protected _copyBaseProperties(from: this): this { - this.doc = from.doc; - this.metadata = from.metadata; - this.deprecated = from.deprecated; - this.resolve_names = from.resolve_names; - - // Whether this node should be emitted. - this._emit = from._emit; - this._isPrivate = from._isPrivate; - this._isIntrospectable = from.isIntrospectable; - - return this; + this.doc = from.doc; + this.metadata = from.metadata; + this.deprecated = from.deprecated; + this.resolve_names = from.resolve_names; + + // Whether this node should be emitted. + this._emit = from._emit; + this._isPrivate = from._isPrivate; + this._isIntrospectable = from.isIntrospectable; + + return this; } - + abstract copy(options?: { parent?: IntrospectedBase }): IntrospectedBase; - + abstract accept(visitor: GirVisitor): IntrospectedBase; - + static fromXML( - _modName: string, - _ns: IntrospectedNamespace, - _options: LoadOptions, - _parent: IntrospectedBase | null, - _gir: object + // eslint-disable-next-line @typescript-eslint/no-unused-vars + modName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + ns: IntrospectedNamespace, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + options: LoadOptions, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + parent: IntrospectedBase | null, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + gir: object ): IntrospectedBase | null { - throw new Error("GirBase cannot be instantiated"); + throw new Error("GirBase cannot be instantiated"); } - - abstract asString, K extends any>(generator: T): K | null; - } - \ No newline at end of file + + abstract asString, K>(generator: T): K | null; +} diff --git a/packages/lib/src/newlib/gir/class.ts b/packages/lib/src/newlib/gir/class.ts index 9d35c0df0..e1ba01b15 100644 --- a/packages/lib/src/newlib/gir/class.ts +++ b/packages/lib/src/newlib/gir/class.ts @@ -1,46 +1,44 @@ import { - - NativeType, - TypeIdentifier, - - NeverType, - ArrayType, - ClosureType, - BinaryType, - PromiseType, - VoidType, - TupleType, - BooleanType, - Generic, - GenericType, - GenerifiedTypeIdentifier, - AnyType, - ConflictType, - TypeConflict + NativeType, + TypeIdentifier, + NeverType, + ArrayType, + ClosureType, + BinaryType, + PromiseType, + VoidType, + TupleType, + BooleanType, + Generic, + GenericType, + GenerifiedTypeIdentifier, + AnyType, + ConflictType, + TypeConflict } from "../gir.js"; -import { TypeExpression } from "../gir.js"; -import {IntrospectedBase} from './base.js'; +import { TypeExpression } from "../gir.js"; +import { IntrospectedBase } from "./base.js"; import { GirInterfaceElement, GirClassElement, GirRecordElement, GirDirection, GirUnionElement } from "../../index.js"; import { - IntrospectedClassFunction, - IntrospectedVirtualClassFunction, - IntrospectedStaticClassFunction, - IntrospectedCallback, - IntrospectedFunction, - IntrospectedConstructor, - IntrospectedFunctionParameter, - IntrospectedDirectAllocationConstructor + IntrospectedClassFunction, + IntrospectedVirtualClassFunction, + IntrospectedStaticClassFunction, + IntrospectedCallback, + IntrospectedFunction, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedDirectAllocationConstructor } from "./function.js"; import { GirProperty, Field } from "./property.js"; -import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; +import { IntrospectedNamespace } from "./namespace.js"; import { - sanitizeIdentifierName, - parseTypeIdentifier, - isSubtypeOf, - resolveTypeIdentifier, - parseDoc, - parseMetadata + sanitizeIdentifierName, + parseTypeIdentifier, + isSubtypeOf, + resolveTypeIdentifier, + parseDoc, + parseMetadata } from "./util.js"; import { IntrospectedSignal } from "./signal.js"; import { FormatGenerator } from "../generators/generator.js"; @@ -50,1569 +48,1609 @@ import { GenericNameGenerator } from "./generics.js"; import { findMap } from "../util.js"; export enum FilterBehavior { - DELETE, - PRESERVE + DELETE, + PRESERVE } export function filterConflicts( - ns: IntrospectedNamespace, - c: IntrospectedBaseClass, - elements: T[], - behavior = FilterBehavior.PRESERVE + ns: IntrospectedNamespace, + c: IntrospectedBaseClass, + elements: T[], + behavior = FilterBehavior.PRESERVE ): T[] { - const filtered = [...elements.filter(p => p && p.name)]; - const prev = [] as T[]; - const thisType = c.getType(); - for (const next of filtered) { - const field_conflicts = c.findParentMap(resolved_parent => { - return findMap([...resolved_parent.fields], p => { - if (p.name && p.name == next.name) { - if (next instanceof GirProperty) { - return ConflictType.ACCESSOR_PROPERTY_CONFLICT; - } - - if ( - next instanceof Field && - !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) - ) { - return ConflictType.FIELD_NAME_CONFLICT; - } - } + const filtered = [...elements.filter(p => p && p.name)]; + const prev = [] as T[]; + const thisType = c.getType(); + for (const next of filtered) { + const field_conflicts = c.findParentMap(resolved_parent => { + return findMap([...resolved_parent.fields], p => { + if (p.name && p.name == next.name) { + if (next instanceof GirProperty) { + return ConflictType.ACCESSOR_PROPERTY_CONFLICT; + } - return undefined; - }); - }); - - const prop_conflicts = !field_conflicts - ? c.findParentMap(resolved_parent => { - return findMap([...resolved_parent.props], p => { - if (p.name && p.name == next.name) { - if (next instanceof Field) { - return ConflictType.PROPERTY_ACCESSOR_CONFLICT; - } - - if ( - next instanceof GirProperty && - !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) - ) { - console.log( - `>> Conflict in ${next.parent?.name}.${next.name} with ${p.parent?.name}.${p.name}.` - ); - return ConflictType.PROPERTY_NAME_CONFLICT; - } - } + if ( + next instanceof Field && + !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) + ) { + return ConflictType.FIELD_NAME_CONFLICT; + } + } - return undefined; - }); - }) - : undefined; - - let function_conflicts = - !field_conflicts && !prop_conflicts - ? c.findParentMap(resolved_parent => - findMap([...resolved_parent.constructors, ...resolved_parent.members], p => { - if (p.name && p.name == next.name) { - if ( - !(next instanceof IntrospectedClassFunction) || - isConflictingFunction(ns, thisType, next, resolved_parent.getType(), p) - ) { - return ConflictType.FUNCTION_NAME_CONFLICT; + return undefined; + }); + }); + + const prop_conflicts = !field_conflicts + ? c.findParentMap(resolved_parent => { + return findMap([...resolved_parent.props], p => { + if (p.name && p.name == next.name) { + if (next instanceof Field) { + return ConflictType.PROPERTY_ACCESSOR_CONFLICT; + } + + if ( + next instanceof GirProperty && + !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) + ) { + console.log( + `>> Conflict in ${next.parent?.name}.${next.name} with ${p.parent?.name}.${p.name}.` + ); + return ConflictType.PROPERTY_NAME_CONFLICT; + } + } + + return undefined; + }); + }) + : undefined; + + const function_conflicts = + !field_conflicts && !prop_conflicts + ? c.findParentMap(resolved_parent => + findMap([...resolved_parent.constructors, ...resolved_parent.members], p => { + if (p.name && p.name == next.name) { + if ( + !(next instanceof IntrospectedClassFunction) || + isConflictingFunction(ns, thisType, next, resolved_parent.getType(), p) + ) { + return ConflictType.FUNCTION_NAME_CONFLICT; + } + } + + return undefined; + }) + ) + : undefined; + const conflict = field_conflicts || prop_conflicts || function_conflicts; + if (conflict) { + if (behavior === FilterBehavior.PRESERVE) { + if (next instanceof Field || next instanceof GirProperty) { + prev.push( + next.copy({ + type: new TypeConflict(next.type, conflict) + }) as T + ); + } else { + prev.push(next); } - } - - return undefined; - }) - ) - : undefined; - const conflict = field_conflicts || prop_conflicts || function_conflicts; - if (conflict) { - if (behavior === FilterBehavior.PRESERVE) { - if (next instanceof Field || next instanceof GirProperty) { - prev.push( - next.copy({ - type: new TypeConflict(next.type, conflict) - }) as T - ); + } } else { - prev.push(next); + prev.push(next); } - } - } else { - prev.push(next); } - } - return prev; + return prev; } function isConflictingFunction( - namespace: IntrospectedNamespace, - childThis: TypeIdentifier, - child: IntrospectedFunction | IntrospectedClassFunction | IntrospectedConstructor, - parentThis: TypeIdentifier, - parent: IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor + namespace: IntrospectedNamespace, + childThis: TypeIdentifier, + child: IntrospectedFunction | IntrospectedClassFunction | IntrospectedConstructor, + parentThis: TypeIdentifier, + parent: IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor ) { - if (child instanceof IntrospectedConstructor && parent instanceof IntrospectedConstructor) { + if (child instanceof IntrospectedConstructor && parent instanceof IntrospectedConstructor) { + return ( + child.parameters.length > parent.parameters.length || + !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || + child.parameters.some( + (p, i) => !isSubtypeOf(namespace, childThis, parentThis, p.type, parent.parameters[i].type) + ) + ); + } else if (child instanceof IntrospectedConstructor || parent instanceof IntrospectedConstructor) { + return true; + } + + // This occurs if two functions of the same name are passed but they + // are different types (e.g. GirStaticClassFunction vs GirClassFunction) + if (Object.getPrototypeOf(child) !== Object.getPrototypeOf(parent)) { + return false; + } + return ( - child.parameters.length > parent.parameters.length || - !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || - child.parameters.some( - (p, i) => !isSubtypeOf(namespace, childThis, parentThis, p.type, parent.parameters[i].type) - ) + child.parameters.length > parent.parameters.length || + child.output_parameters.length !== parent.output_parameters.length || + !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || + child.parameters.some( + (np, i) => !isSubtypeOf(namespace, childThis, parentThis, np.type, parent.parameters[i].type) + ) || + child.output_parameters.some( + (np, i) => !isSubtypeOf(namespace, childThis, parentThis, np.type, parent.output_parameters[i].type) + ) ); - } else if (child instanceof IntrospectedConstructor || parent instanceof IntrospectedConstructor) { - return true; - } - - // This occurs if two functions of the same name are passed but they - // are different types (e.g. GirStaticClassFunction vs GirClassFunction) - if (Object.getPrototypeOf(child) !== Object.getPrototypeOf(parent)) { - return false; - } - - return ( - child.parameters.length > parent.parameters.length || - child.output_parameters.length !== parent.output_parameters.length || - !isSubtypeOf(namespace, childThis, parentThis, child.return(), parent.return()) || - child.parameters.some( - (np, i) => !isSubtypeOf(namespace, childThis, parentThis, np.type, parent.parameters[i].type) - ) || - child.output_parameters.some( - (np, i) => !isSubtypeOf(namespace, childThis, parentThis, np.type, parent.output_parameters[i].type) - ) - ); } export function filterFunctionConflict< - T extends IntrospectedStaticClassFunction | IntrospectedVirtualClassFunction | IntrospectedClassFunction | IntrospectedConstructor + T extends + | IntrospectedStaticClassFunction + | IntrospectedVirtualClassFunction + | IntrospectedClassFunction + | IntrospectedConstructor >(ns: IntrospectedNamespace, base: IntrospectedBaseClass, elements: T[], conflict_ids: string[]) { - const nextType = base.getType(); - return elements - .filter(m => m.name) - .reduce((prev, next) => { - // TODO This should catch most of them. - let msg: string | null = null; - let conflicts = - conflict_ids.includes(next.name) || - base.someParent(resolved_parent => { - const parentType = resolved_parent.getType(); - return [...resolved_parent.constructors, ...resolved_parent.members].some(p => { - if (p.name && p.name == next.name) { - let conflicting = isConflictingFunction(ns, nextType, next, parentType, p); - - if (conflicting) { - msg = `// Conflicted with ${resolved_parent.namespace.name}.${resolved_parent.name}.${p.name}`; - return true; - } - return conflicting; + const nextType = base.getType(); + return elements + .filter(m => m.name) + .reduce((prev, next) => { + // TODO This should catch most of them. + let msg: string | null = null; + let conflicts = + conflict_ids.includes(next.name) || + base.someParent(resolved_parent => { + const parentType = resolved_parent.getType(); + return [...resolved_parent.constructors, ...resolved_parent.members].some(p => { + if (p.name && p.name == next.name) { + const conflicting = isConflictingFunction(ns, nextType, next, parentType, p); + + if (conflicting) { + msg = `// Conflicted with ${resolved_parent.namespace.name}.${resolved_parent.name}.${p.name}`; + return true; + } + return conflicting; + } + return false; + }); + }); + + const field_conflicts = base.someParent(resolved_parent => + [...resolved_parent.props, ...resolved_parent.fields].some(p => p.name && p.name == next.name) + ); + + const isGObject = base.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); + + if (isGObject) { + conflicts = conflicts || ["connect", "connect_after", "emit"].includes(next.name); } - return false; - }); - }); - - let field_conflicts = base.someParent(resolved_parent => - [...resolved_parent.props, ...resolved_parent.fields].some(p => p.name && p.name == next.name) - ); - - const isGObject = base.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); - - if (isGObject) { - conflicts = conflicts || ["connect", "connect_after", "emit"].includes(next.name); - } - if (conflicts) { - let never: IntrospectedConstructor | IntrospectedFunction | IntrospectedStaticClassFunction | IntrospectedVirtualClassFunction; - - const never_param = new IntrospectedFunctionParameter({ - name: "args", - direction: GirDirection.In, - isVarArgs: true, - type: new ArrayType(NeverType) - }); - - const neverOptions = { - name: next.name, - parameters: [never_param], - return_type: AnyType - }; - - if (next instanceof IntrospectedConstructor) { - never = new IntrospectedConstructor(neverOptions); - } else if (next instanceof IntrospectedStaticClassFunction) { - never = new IntrospectedStaticClassFunction({ ...neverOptions, parent: next.parent }); - } else if (next instanceof IntrospectedVirtualClassFunction && next.parent instanceof IntrospectedClass) { - never = new IntrospectedVirtualClassFunction({ ...neverOptions, parent: next.parent }); - } else if (next instanceof IntrospectedClassFunction) { - never = new IntrospectedClassFunction({ ...neverOptions, parent: next.parent }); - } else { - throw new Error(`Unknown function type ${Object.getPrototypeOf(next)?.name} encountered.`); - } + if (conflicts) { + let never: + | IntrospectedConstructor + | IntrospectedFunction + | IntrospectedStaticClassFunction + | IntrospectedVirtualClassFunction; + + const never_param = new IntrospectedFunctionParameter({ + name: "args", + direction: GirDirection.In, + isVarArgs: true, + type: new ArrayType(NeverType) + }); + + const neverOptions = { + name: next.name, + parameters: [never_param], + return_type: AnyType + }; + + if (next instanceof IntrospectedConstructor) { + never = new IntrospectedConstructor(neverOptions); + } else if (next instanceof IntrospectedStaticClassFunction) { + never = new IntrospectedStaticClassFunction({ ...neverOptions, parent: next.parent }); + } else if ( + next instanceof IntrospectedVirtualClassFunction && + next.parent instanceof IntrospectedClass + ) { + never = new IntrospectedVirtualClassFunction({ ...neverOptions, parent: next.parent }); + } else if (next instanceof IntrospectedClassFunction) { + never = new IntrospectedClassFunction({ ...neverOptions, parent: next.parent }); + } else { + const parent = Object.getPrototypeOf(next as (...args: unknown[]) => unknown) as + | ((...args: unknown[]) => unknown) + | null + | undefined; + throw new Error(`Unknown function type ${parent?.name} encountered.`); + } - if (msg) never.setWarning(msg); + if (msg) never.setWarning(msg); - prev.push(next, never as T); - } else if (field_conflicts) { - console.error(`Omitting ${next.name} due to field conflict.`); - } else { - prev.push(next); - } + prev.push(next, never as T); + } else if (field_conflicts) { + console.error(`Omitting ${next.name} due to field conflict.`); + } else { + prev.push(next); + } - return prev; - }, [] as T[]); + return prev; + }, [] as T[]); } export function promisifyFunctions(functions: IntrospectedClassFunction[]) { - return functions - .map(node => { - if (node.parameters.length > 0) { - const last_param = node.parameters[node.parameters.length - 1]; - - if (last_param) { - const last_param_unwrapped = last_param.type.unwrap(); - - if (last_param_unwrapped instanceof ClosureType) { - const internal = last_param_unwrapped.type; - if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { - const parent = node.parent; - const interfaceParent = node.interfaceParent; - - if (parent instanceof IntrospectedBaseClass) { - let async_res = ( - node instanceof IntrospectedStaticClassFunction - ? [ - ...parent.constructors, - ...parent.members.filter(m => m instanceof IntrospectedStaticClassFunction) - ] - : [ - ...(interfaceParent instanceof GirInterface ? [...interfaceParent.members] : []), - ...parent.members.filter(m => !(m instanceof IntrospectedStaticClassFunction)) - ] - ).find( - m => - m.name === `${node.name.replace(/_async$/, "")}_finish` || - m.name === `${node.name}_finish` - ); - - if (async_res) { - const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); - const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); - const output_parameters = - async_res instanceof IntrospectedConstructor ? [] : async_res.output_parameters; - - let async_return = new PromiseType(async_res.return()); - - if (output_parameters.length > 0) { - const raw_return = async_res.return(); - if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { - const [output_type, ...output_types] = output_parameters.map(op => op.type); - async_return = new PromiseType(new TupleType(output_type, ...output_types)); - } else { - const [...output_types] = output_parameters.map(op => op.type); - async_return = new PromiseType(new TupleType(raw_return, ...output_types)); + return functions + .map(node => { + if (node.parameters.length > 0) { + const last_param = node.parameters[node.parameters.length - 1]; + + if (last_param) { + const last_param_unwrapped = last_param.type.unwrap(); + + if (last_param_unwrapped instanceof ClosureType) { + const internal = last_param_unwrapped.type; + if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { + const parent = node.parent; + const interfaceParent = node.interfaceParent; + + if (parent instanceof IntrospectedBaseClass) { + const async_res = ( + node instanceof IntrospectedStaticClassFunction + ? [ + ...parent.constructors, + ...parent.members.filter( + m => m instanceof IntrospectedStaticClassFunction + ) + ] + : [ + ...(interfaceParent instanceof IntrospectedInterface + ? [...interfaceParent.members] + : []), + ...parent.members.filter( + m => !(m instanceof IntrospectedStaticClassFunction) + ) + ] + ).find( + m => + m.name === `${node.name.replace(/_async$/, "")}_finish` || + m.name === `${node.name}_finish` + ); + + if (async_res) { + const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); + const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); + const output_parameters = + async_res instanceof IntrospectedConstructor ? [] : async_res.output_parameters; + + let async_return = new PromiseType(async_res.return()); + + if (output_parameters.length > 0) { + const raw_return = async_res.return(); + if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { + const [output_type, ...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(output_type, ...output_types)); + } else { + const [...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(raw_return, ...output_types)); + } + } + + return [ + node.copy({ + parameters: async_parameters, + returnType: async_return + }), + node.copy({ + parameters: sync_parameters + }), + node.copy({ + returnType: new BinaryType(async_return, node.return()) + }) + ]; + } + } + } } - } - - return [ - node.copy({ - parameters: async_parameters, - returnType: async_return - }), - node.copy({ - parameters: sync_parameters - }), - node.copy({ - returnType: new BinaryType(async_return, node.return()) - }) - ]; } - } } - } - } - } - return node; - }) - .flat(1); + return node; + }) + .flat(1); } export const enum ClassInjectionMember { - MEMBER = "member", - CONSTRUCTOR = "_constructor", - PROPERTY = "prop", - FIELD = "field", - MAIN_CONSTRUCTOR = "constructor" + MEMBER = "member", + CONSTRUCTOR = "_constructor", + PROPERTY = "prop", + FIELD = "field", + MAIN_CONSTRUCTOR = "constructor" } export interface ClassDefinition { - parent: TypeIdentifier; - interfaces: TypeIdentifier[]; - mainConstructor: IntrospectedConstructor; - constructors: IntrospectedConstructor[]; - members: IntrospectedClassFunction[]; - props: GirProperty[]; - fields: Field[]; - callbacks: IntrospectedCallback[]; + parent: TypeIdentifier; + interfaces: TypeIdentifier[]; + mainConstructor: IntrospectedConstructor; + constructors: IntrospectedConstructor[]; + members: IntrospectedClassFunction[]; + props: GirProperty[]; + fields: Field[]; + callbacks: IntrospectedCallback[]; } export interface ResolutionNode { - identifier: TypeIdentifier; - node: IntrospectedBaseClass; + identifier: TypeIdentifier; + node: IntrospectedBaseClass; } export interface InterfaceResolution extends ResolutionNode, Iterable { - extends(): InterfaceResolution | ClassResolution | undefined; - node: GirInterface; + extends(): InterfaceResolution | ClassResolution | undefined; + node: IntrospectedInterface; } export interface ClassResolution extends ResolutionNode, Iterable { - extends(): ClassResolution | undefined; - implements(): InterfaceResolution[]; - node: IntrospectedClass; + extends(): ClassResolution | undefined; + implements(): InterfaceResolution[]; + node: IntrospectedClass; } export interface RecordResolution extends ResolutionNode, Iterable { - extends(): RecordResolution | undefined; - node: GirRecord; + extends(): RecordResolution | undefined; + node: IntrospectedRecord; } export abstract class IntrospectedBaseClass extends IntrospectedBase { - namespace: IntrospectedNamespace; - indexSignature?: string; - parent: TypeIdentifier | null; - - mainConstructor: null | IntrospectedConstructor | IntrospectedDirectAllocationConstructor; - constructors: IntrospectedConstructor[]; - members: IntrospectedClassFunction[]; - props: GirProperty[]; - fields: Field[]; - callbacks: IntrospectedCallback[]; - - // Generics support - generics: Generic[] = []; - - constructor( - options: { - name: string; - namespace: IntrospectedNamespace; - isIntrospectable?: boolean; - } & Partial - ) { - const { - name, - namespace, - parent = null, - mainConstructor = null, - constructors = [], - members = [], - props = [], - fields = [], - callbacks = [], - ...args - } = options; - - super(name, { ...args }); - - this.namespace = namespace; - this.parent = parent; - - this.mainConstructor = mainConstructor?.copy() ?? null; - this.constructors = [...constructors.map(c => c.copy())]; - this.members = [...members.map(m => m.copy({ parent: this }))]; - this.props = [...props.map(p => p.copy({ parent: this }))]; - this.fields = [...fields.map(f => f.copy({ parent: this }))]; - this.callbacks = [...callbacks.map(c => c.copy())]; - } - - abstract accept(visitor: GirVisitor): IntrospectedBaseClass; - - abstract copy(options?: { - parent?: undefined; - constructors?: IntrospectedConstructor[]; - members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; - }): IntrospectedBaseClass; - - getGenericName = GenericNameGenerator.new(); - - abstract resolveParents(): RecordResolution | InterfaceResolution | ClassResolution; - abstract someParent(predicate: (b: IntrospectedBaseClass) => boolean): boolean; - abstract findParent(predicate: (b: IntrospectedBaseClass) => boolean): IntrospectedBaseClass | undefined; - abstract findParentMap(predicate: (b: IntrospectedBaseClass) => K | undefined): K | undefined; - - addGeneric(definition: { - deriveFrom?: TypeIdentifier; - default?: TypeExpression; - constraint?: TypeExpression; - propagate?: boolean; - }) { - const param = new Generic( - new GenericType(this.getGenericName(), definition.constraint), - definition.default, - definition.deriveFrom, - definition.constraint, - definition.propagate - ); + namespace: IntrospectedNamespace; + indexSignature?: string; + parent: TypeIdentifier | null; + + mainConstructor: null | IntrospectedConstructor | IntrospectedDirectAllocationConstructor; + constructors: IntrospectedConstructor[]; + members: IntrospectedClassFunction[]; + props: GirProperty[]; + fields: Field[]; + callbacks: IntrospectedCallback[]; + + // Generics support + generics: Generic[] = []; + + constructor( + options: { + name: string; + namespace: IntrospectedNamespace; + isIntrospectable?: boolean; + } & Partial + ) { + const { + name, + namespace, + parent = null, + mainConstructor = null, + constructors = [], + members = [], + props = [], + fields = [], + callbacks = [], + ...args + } = options; + + super(name, { ...args }); + + this.namespace = namespace; + this.parent = parent; + + this.mainConstructor = mainConstructor?.copy() ?? null; + this.constructors = [...constructors.map(c => c.copy())]; + this.members = [...members.map(m => m.copy({ parent: this }))]; + this.props = [...props.map(p => p.copy({ parent: this }))]; + this.fields = [...fields.map(f => f.copy({ parent: this }))]; + this.callbacks = [...callbacks.map(c => c.copy())]; + } - this.generics.push(param); - } + abstract accept(visitor: GirVisitor): IntrospectedBaseClass; + + abstract copy(options?: { + parent?: undefined; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; + props?: GirProperty[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; + }): IntrospectedBaseClass; + + getGenericName = GenericNameGenerator.new(); + + abstract resolveParents(): RecordResolution | InterfaceResolution | ClassResolution; + abstract someParent(predicate: (b: IntrospectedBaseClass) => boolean): boolean; + abstract findParent(predicate: (b: IntrospectedBaseClass) => boolean): IntrospectedBaseClass | undefined; + abstract findParentMap(predicate: (b: IntrospectedBaseClass) => K | undefined): K | undefined; + + addGeneric(definition: { + deriveFrom?: TypeIdentifier; + default?: TypeExpression; + constraint?: TypeExpression; + propagate?: boolean; + }) { + const param = new Generic( + new GenericType(this.getGenericName(), definition.constraint), + definition.default, + definition.deriveFrom, + definition.constraint, + definition.propagate + ); + + this.generics.push(param); + } - getType(): TypeIdentifier { - return new TypeIdentifier(this.name, this.namespace.name); - } + getType(): TypeIdentifier { + return new TypeIdentifier(this.name, this.namespace.name); + } - static fromXML( - _modName: string, - _ns: IntrospectedNamespace, - _options: LoadOptions, - _parent, - _klass: GirClassElement | GirInterfaceElement | GirRecordElement - ): IntrospectedBaseClass { - throw new Error("fromXML is not implemented on GirBaseClass"); - } + static fromXML( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + modName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + ns: IntrospectedNamespace, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + options: LoadOptions, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + parent, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + klass: GirClassElement | GirInterfaceElement | GirRecordElement + ): IntrospectedBaseClass { + throw new Error("fromXML is not implemented on GirBaseClass"); + } - abstract asString(generator: FormatGenerator): T; + abstract asString(generator: FormatGenerator): T; } export class IntrospectedClass extends IntrospectedBaseClass { - signals: IntrospectedSignal[] = []; - interfaces: TypeIdentifier[] = []; - isAbstract: boolean = false; - mainConstructor: null | IntrospectedConstructor = null; - private _staticDefinition: string | null = null; - - constructor(name: string, namespace: IntrospectedNamespace) { - super({ name, namespace }); - } - - accept(visitor: GirVisitor): IntrospectedClass { - const node = this.copy({ - signals: this.signals.map(s => s.accept(visitor)), - constructors: this.constructors.map(c => c.accept(visitor)), - members: this.members.map(m => m.accept(visitor)), - props: this.props.map(p => p.accept(visitor)), - fields: this.fields.map(f => f.accept(visitor)), - callbacks: this.callbacks.map(c => c.accept(visitor)) - }); - return visitor.visitClass?.(node) ?? node; - } - - hasInstanceSymbol(s: IntrospectedBase): boolean { - return ( - this.members.some(p => s.name === p.name && !(p instanceof IntrospectedStaticClassFunction)) || - this.props.some(p => s.name === p.name) || - this.fields.some(p => s.name === p.name) - ); - } - - someParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): boolean { - const resolution = this.resolveParents(); - const parent = resolution.extends(); - - if (parent) { - if (predicate(parent.node)) return true; - - const some = parent.node.someParent(predicate); + signals: IntrospectedSignal[] = []; + interfaces: TypeIdentifier[] = []; + isAbstract: boolean = false; + mainConstructor: null | IntrospectedConstructor = null; + private _staticDefinition: string | null = null; + + constructor(name: string, namespace: IntrospectedNamespace) { + super({ name, namespace }); + } - if (some) return some; + accept(visitor: GirVisitor): IntrospectedClass { + const node = this.copy({ + signals: this.signals.map(s => s.accept(visitor)), + constructors: this.constructors.map(c => c.accept(visitor)), + members: this.members.map(m => m.accept(visitor)), + props: this.props.map(p => p.accept(visitor)), + fields: this.fields.map(f => f.accept(visitor)), + callbacks: this.callbacks.map(c => c.accept(visitor)) + }); + return visitor.visitClass?.(node) ?? node; } - return ( - resolution - .implements() - .map(i => i.node) - .some(n => predicate(n)) || resolution.implements().some(i => i.node.someParent(predicate)) - ); - } + hasInstanceSymbol(s: IntrospectedBase): boolean { + return ( + this.members.some(p => s.name === p.name && !(p instanceof IntrospectedStaticClassFunction)) || + this.props.some(p => s.name === p.name) || + this.fields.some(p => s.name === p.name) + ); + } - findParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): IntrospectedClass | GirInterface | undefined { - const resolution = this.resolveParents(); + someParent(predicate: (p: IntrospectedClass | IntrospectedInterface) => boolean): boolean { + const resolution = this.resolveParents(); + const parent = resolution.extends(); - const parent = resolution.extends(); + if (parent) { + if (predicate(parent.node)) return true; - if (parent) { - if (predicate(parent.node)) return this; + const some = parent.node.someParent(predicate); - const found = parent.node.findParent(predicate); + if (some) return some; + } - if (found) return found; + return ( + resolution + .implements() + .map(i => i.node) + .some(n => predicate(n)) || resolution.implements().some(i => i.node.someParent(predicate)) + ); } - const interfaces = resolution.implements().map(i => i.node); - return interfaces.find(n => predicate(n)) || interfaces.find(n => n.findParent(predicate)); - } - - findParentMap(predicate: (p: IntrospectedClass | GirInterface) => K | undefined): K | undefined { - const resolution = this.resolveParents(); + findParent( + predicate: (p: IntrospectedClass | IntrospectedInterface) => boolean + ): IntrospectedClass | IntrospectedInterface | undefined { + const resolution = this.resolveParents(); - const parent = resolution.extends(); + const parent = resolution.extends(); - if (parent) { - let found = predicate(parent.node); + if (parent) { + if (predicate(parent.node)) return this; - if (found !== undefined) return found; + const found = parent.node.findParent(predicate); - found = parent.node.findParentMap(predicate); + if (found) return found; + } - if (found !== undefined) return found; + const interfaces = resolution.implements().map(i => i.node); + return interfaces.find(n => predicate(n)) || interfaces.find(n => n.findParent(predicate)); } - const interfaces = resolution.implements().map(i => i.node); + findParentMap(predicate: (p: IntrospectedClass | IntrospectedInterface) => K | undefined): K | undefined { + const resolution = this.resolveParents(); + + const parent = resolution.extends(); - const result = findMap(interfaces, i => predicate(i)); - if (result !== undefined) return result; + if (parent) { + let found = predicate(parent.node); - return findMap(interfaces, i => i.findParentMap(predicate)); - } + if (found !== undefined) return found; - implementedProperties(potentialConflicts: IntrospectedBase[] = []) { - const resolution = this.resolveParents(); - const implemented_on_parent = [...(resolution.extends() ?? [])] - .map(r => r.implements()) - .flat() - .map(i => i.identifier); - const properties = new Map(); + found = parent.node.findParentMap(predicate); - const validateProp = (prop: GirProperty) => - !this.hasInstanceSymbol(prop) && - !properties.has(prop.name) && - potentialConflicts.every(p => prop.name !== p.name); + if (found !== undefined) return found; + } - for (const implemented of resolution.implements()) { - if (implemented.node instanceof IntrospectedClass) continue; + const interfaces = resolution.implements().map(i => i.node); - if (implemented_on_parent.some(p => p.equals(implemented.identifier))) continue; + const result = findMap(interfaces, i => predicate(i)); + if (result !== undefined) return result; - for (const prop of implemented.node.props) { - if (!validateProp(prop)) { - continue; - } - properties.set(prop.name, prop.copy({ parent: this })); - } + return findMap(interfaces, i => i.findParentMap(predicate)); } - for (const implemented of resolution.implements()) { - [...implemented].forEach(e => { - if (e.node instanceof IntrospectedClass) return; + implementedProperties(potentialConflicts: IntrospectedBase[] = []) { + const resolution = this.resolveParents(); + const implemented_on_parent = [...(resolution.extends() ?? [])] + .map(r => r.implements()) + .flat() + .map(i => i.identifier); + const properties = new Map(); - if (implemented_on_parent.some(p => p.equals(e.identifier))) return; + const validateProp = (prop: GirProperty) => + !this.hasInstanceSymbol(prop) && + !properties.has(prop.name) && + potentialConflicts.every(p => prop.name !== p.name); - for (const prop of e.node.props) { - if (!validateProp(prop)) { - continue; - } + for (const implemented of resolution.implements()) { + if (implemented.node instanceof IntrospectedClass) continue; - properties.set(prop.name, prop.copy({ parent: this })); + if (implemented_on_parent.some(p => p.equals(implemented.identifier))) continue; + + for (const prop of implemented.node.props) { + if (!validateProp(prop)) { + continue; + } + properties.set(prop.name, prop.copy({ parent: this })); + } } - }); - } - return [...properties.values()]; - } - - implementedMethods(potentialConflicts: IntrospectedBase[] = []) { - const resolution = this.resolveParents(); - const implemented_on_parent = [...(resolution.extends() ?? [])].map(r => r.implements()).flat(); - const methods = new Map(); - - const validateMethod = (method: IntrospectedClassFunction) => - !(method instanceof IntrospectedStaticClassFunction) && - !this.hasInstanceSymbol(method) && - !methods.has(method.name) && - potentialConflicts.every(m => method.name !== m.name); - - for (const implemented of resolution.implements()) { - if (implemented.node instanceof IntrospectedClass) continue; - - if ( - implemented_on_parent.find(p => p.identifier.equals(implemented.identifier))?.node?.generics - ?.length === 0 - ) - continue; - for (const member of implemented.node.members) { - if (!validateMethod(member)) continue; - methods.set(member.name, member); - } - } + for (const implemented of resolution.implements()) { + [...implemented].forEach(e => { + if (e.node instanceof IntrospectedClass) return; - for (const implemented of resolution.implements()) { - [...implemented].forEach(e => { - if (e.node instanceof IntrospectedClass) return; + if (implemented_on_parent.some(p => p.equals(e.identifier))) return; - if (implemented_on_parent.find(p => p.identifier.equals(e.identifier))?.node.generics.length === 0) - return; - for (const member of e.node.members) { - if (!validateMethod(member)) continue; + for (const prop of e.node.props) { + if (!validateProp(prop)) { + continue; + } - methods.set(member.name, member); + properties.set(prop.name, prop.copy({ parent: this })); + } + }); } - }); - } - return [...methods.values()].map(f => { - const mapping = new Map(); - if (f.parent instanceof IntrospectedBaseClass) { - const inter = this.interfaces.find(i => i.equals(f.parent.getType())); + return [...properties.values()]; + } - if (inter instanceof GenerifiedTypeIdentifier) { - f.parent.generics.forEach((g, i) => { - if (inter.generics.length > i) { - mapping.set(g.type.identifier, inter.generics[i]); + implementedMethods(potentialConflicts: IntrospectedBase[] = []) { + const resolution = this.resolveParents(); + const implemented_on_parent = [...(resolution.extends() ?? [])].map(r => r.implements()).flat(); + const methods = new Map(); + + const validateMethod = (method: IntrospectedClassFunction) => + !(method instanceof IntrospectedStaticClassFunction) && + !this.hasInstanceSymbol(method) && + !methods.has(method.name) && + potentialConflicts.every(m => method.name !== m.name); + + for (const implemented of resolution.implements()) { + if (implemented.node instanceof IntrospectedClass) continue; + + if ( + implemented_on_parent.find(p => p.identifier.equals(implemented.identifier))?.node?.generics?.length === + 0 + ) + continue; + for (const member of implemented.node.members) { + if (!validateMethod(member)) continue; + methods.set(member.name, member); } - }); } - } - const unwrapped = f.return().deepUnwrap(); - let modifiedReturn = f.return(); + for (const implemented of resolution.implements()) { + [...implemented].forEach(e => { + if (e.node instanceof IntrospectedClass) return; - if (unwrapped instanceof GenericType && mapping.has(unwrapped.identifier)) { - let mapped = mapping.get(unwrapped.identifier); + if (implemented_on_parent.find(p => p.identifier.equals(e.identifier))?.node.generics.length === 0) + return; + for (const member of e.node.members) { + if (!validateMethod(member)) continue; - if (mapped) { - modifiedReturn = f.return().rewrap(mapped); + methods.set(member.name, member); + } + }); } - // Handles the case where a class implements an interface and thus copies its virtual methods. - } else if (unwrapped.equals(this.getType())) { - modifiedReturn = f.return().rewrap(this.getType()); - } - - return f.copy({ - parent: this, - interfaceParent: f.parent, - parameters: f.parameters.map(p => { - const t = p.type.deepUnwrap(); - if (t instanceof GenericType && mapping.has(t.identifier)) { - const iden = mapping.get(t.identifier); - - if (iden) { - return p.copy({ type: p.type.rewrap(iden) }); + + return [...methods.values()].map(f => { + const mapping = new Map(); + if (f.parent instanceof IntrospectedBaseClass) { + const inter = this.interfaces.find(i => i.equals(f.parent.getType())); + + if (inter instanceof GenerifiedTypeIdentifier) { + f.parent.generics.forEach((g, i) => { + if (inter.generics.length > i) { + mapping.set(g.type.identifier, inter.generics[i]); + } + }); + } } - } - return p; - }), - outputParameters: f.output_parameters.map(p => { - const t = p.type.deepUnwrap(); - if (t instanceof GenericType && mapping.has(t.identifier)) { - const iden = mapping.get(t.identifier); + const unwrapped = f.return().deepUnwrap(); + let modifiedReturn = f.return(); + + if (unwrapped instanceof GenericType && mapping.has(unwrapped.identifier)) { + const mapped = mapping.get(unwrapped.identifier); - if (iden) { - return p.copy({ type: p.type.rewrap(iden) }); + if (mapped) { + modifiedReturn = f.return().rewrap(mapped); + } + // Handles the case where a class implements an interface and thus copies its virtual methods. + } else if (unwrapped.equals(this.getType())) { + modifiedReturn = f.return().rewrap(this.getType()); } - } - return p; - }), - returnType: modifiedReturn - }); - }); - } + return f.copy({ + parent: this, + interfaceParent: f.parent, + parameters: f.parameters.map(p => { + const t = p.type.deepUnwrap(); + if (t instanceof GenericType && mapping.has(t.identifier)) { + const iden = mapping.get(t.identifier); + + if (iden) { + return p.copy({ type: p.type.rewrap(iden) }); + } + } - resolveParents(): ClassResolution { - let { namespace, parent, interfaces } = this; + return p; + }), + outputParameters: f.output_parameters.map(p => { + const t = p.type.deepUnwrap(); + if (t instanceof GenericType && mapping.has(t.identifier)) { + const iden = mapping.get(t.identifier); - return { - *[Symbol.iterator]() { - let current = this.extends(); + if (iden) { + return p.copy({ type: p.type.rewrap(iden) }); + } + } - while (current !== undefined) { - yield current; - current = current.extends(); - } - }, - implements() { - const z = interfaces - .map(i => resolveTypeIdentifier(namespace, i)) - .filter((i): i is GirInterface => i instanceof GirInterface) - .map(i => i.resolveParents()); - - return z; - }, - extends() { - let parentType = parent; - let resolved_parent = parentType && resolveTypeIdentifier(namespace, parentType); - if (resolved_parent instanceof IntrospectedClass) return resolved_parent.resolveParents(); - return undefined; - }, - node: this, - identifier: this.getType() - }; - } - - copy( - options: { - parent?: undefined; - signals?: IntrospectedSignal[]; - constructors?: IntrospectedConstructor[]; - members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; - } = {} - ): IntrospectedClass { - const { - name, - namespace, - parent, - interfaces, - members, - constructors, - props, - fields, - callbacks, - isAbstract, - mainConstructor, - signals, - generics, - _staticDefinition - } = this; - - const clazz = new IntrospectedClass(name, namespace); - - clazz._copyBaseProperties(this); - - if (parent) { - clazz.parent = parent; + return p; + }), + returnType: modifiedReturn + }); + }); } - clazz._staticDefinition = _staticDefinition; - clazz.signals = (options.signals ?? signals).map(s => s.copy()); - clazz.interfaces = [...interfaces]; - clazz.props = (options.props ?? props).map(p => p.copy()); - clazz.fields = (options.fields ?? fields).map(f => f.copy()); - clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); - clazz.isAbstract = isAbstract; - clazz.mainConstructor = mainConstructor; - clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); - clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); - clazz.generics = [...generics]; - - // Ensure the generic iteration resumes - clazz.getGenericName = GenericNameGenerator.at(this.getGenericName()); - - return clazz; - } - - get staticDefinition() { - return this._staticDefinition; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - klass: GirClassElement - ): IntrospectedClass { - const name = sanitizeIdentifierName(ns.name, klass.$.name); - - if (options.verbose) { - console.debug(` >> GirClass: Parsing definition ${klass.$.name} (${name})...`); - } + resolveParents(): ClassResolution { + const { namespace, parent, interfaces } = this; - const clazz = new IntrospectedClass(name, ns); + return { + *[Symbol.iterator]() { + let current = this.extends(); - if (options.loadDocs) { - clazz.doc = parseDoc(klass); - clazz.metadata = parseMetadata(klass); + while (current !== undefined) { + yield current; + current = current.extends(); + } + }, + implements() { + const z = interfaces + .map(i => resolveTypeIdentifier(namespace, i)) + .filter((i): i is IntrospectedInterface => i instanceof IntrospectedInterface) + .map(i => i.resolveParents()); + + return z; + }, + extends() { + const parentType = parent; + const resolved_parent = parentType && resolveTypeIdentifier(namespace, parentType); + if (resolved_parent instanceof IntrospectedClass) return resolved_parent.resolveParents(); + return undefined; + }, + node: this, + identifier: this.getType() + }; } - if (klass.$["glib:type-name"]) { - clazz.resolve_names.push(klass.$["glib:type-name"]); + copy( + options: { + parent?: undefined; + signals?: IntrospectedSignal[]; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; + props?: GirProperty[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; + } = {} + ): IntrospectedClass { + const { + name, + namespace, + parent, + interfaces, + members, + constructors, + props, + fields, + callbacks, + isAbstract, + mainConstructor, + signals, + generics, + _staticDefinition + } = this; + + const clazz = new IntrospectedClass(name, namespace); + + clazz._copyBaseProperties(this); + + if (parent) { + clazz.parent = parent; + } - ns.registerResolveName(klass.$["glib:type-name"], ns.name, name); + clazz._staticDefinition = _staticDefinition; + clazz.signals = (options.signals ?? signals).map(s => s.copy()); + clazz.interfaces = [...interfaces]; + clazz.props = (options.props ?? props).map(p => p.copy()); + clazz.fields = (options.fields ?? fields).map(f => f.copy()); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.isAbstract = isAbstract; + clazz.mainConstructor = mainConstructor; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); + clazz.generics = [...generics]; + + // Ensure the generic iteration resumes + clazz.getGenericName = GenericNameGenerator.at(this.getGenericName()); + + return clazz; } - if (klass.$["glib:type-struct"]) { - clazz.resolve_names.push(); - - ns.registerResolveName(klass.$["glib:type-struct"], ns.name, name); + get staticDefinition() { + return this._staticDefinition; } - if (klass.$["c:type"]) { - clazz.resolve_names.push(klass.$["c:type"]); + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + klass: GirClassElement + ): IntrospectedClass { + const name = sanitizeIdentifierName(ns.name, klass.$.name); + + if (options.verbose) { + console.debug(` >> GirClass: Parsing definition ${klass.$.name} (${name})...`); + } - ns.registerResolveName(klass.$["c:type"], ns.name, name); - } + const clazz = new IntrospectedClass(name, ns); - const typeStruct = klass.$["glib:type-struct"]; - if (typeStruct) { - clazz.registerStaticDefinition(typeStruct); + if (options.loadDocs) { + clazz.doc = parseDoc(klass); + clazz.metadata = parseMetadata(klass); + } - clazz.resolve_names.push(typeStruct); + if (klass.$["glib:type-name"]) { + clazz.resolve_names.push(klass.$["glib:type-name"]); - ns.registerResolveName(typeStruct, ns.name, name); - } + ns.registerResolveName(klass.$["glib:type-name"], ns.name, name); + } - try { - // Setup parent type if this is an interface or class. - if (klass.$.parent) { - clazz.parent = parseTypeIdentifier(modName, klass.$.parent); - } - - if (klass.$.abstract) { - clazz.isAbstract = true; - } - - if (Array.isArray(klass.constructor)) { - clazz.constructors.push( - ...klass.constructor.map(constructor => - IntrospectedConstructor.fromXML(modName, ns, options, clazz, constructor) - ) - ); - } + if (klass.$["glib:type-struct"]) { + clazz.resolve_names.push(); - if (klass["glib:signal"]) { - clazz.signals.push( - ...klass["glib:signal"].map(signal => IntrospectedSignal.fromXML(modName, ns, options, clazz, signal)) - ); - } - - // Properties - if (klass.property) { - klass.property.forEach(prop => { - const property = GirProperty.fromXML(modName, ns, options, clazz, prop); - switch (options.propertyCase) { - case "both": - clazz.props.push(property); - - const camelCase = property.toCamelCase(); - - // Ensure we don't duplicate properties like 'show' - if (property.name !== camelCase.name) { - clazz.props.push(camelCase); - } - - break; - case "camel": - clazz.props.push(property.toCamelCase()); - break; - case "underscore": - clazz.props.push(property); - break; - } - }); - } + ns.registerResolveName(klass.$["glib:type-struct"], ns.name, name); + } - // Instance Methods - if (klass.method) { - clazz.members.push( - ...klass.method.map(method => IntrospectedClassFunction.fromXML(modName, ns, options, clazz, method)) - ); - } - - // Fields - if (klass.field) { - klass.field - .filter(field => !("callback" in field)) - .forEach(field => { - const f = Field.fromXML(modName, ns, options, null, field); - - clazz.fields.push(f); - }); - } - - if (klass.implements) { - klass.implements.forEach(implementee => { - const name = implementee.$.name; - const type = parseTypeIdentifier(modName, name); - - // Sometimes namespaces will implicitly import - // other namespaces like Atk via interface implements. - if (type && type.namespace && type.namespace !== modName && !ns.hasImport(type.namespace)) { - ns.addImport(type.namespace); - } - - if (type) { - clazz.interfaces.push(type); - } - }); - } - - // Callback Types - if (klass.callback) { - clazz.callbacks.push( - ...klass.callback.map(callback => { - if (options.verbose) { - console.debug(`Adding callback ${callback.$.name} for ${modName}`); + if (klass.$["c:type"]) { + clazz.resolve_names.push(klass.$["c:type"]); + + ns.registerResolveName(klass.$["c:type"], ns.name, name); + } + + const typeStruct = klass.$["glib:type-struct"]; + if (typeStruct) { + clazz.registerStaticDefinition(typeStruct); + + clazz.resolve_names.push(typeStruct); + + ns.registerResolveName(typeStruct, ns.name, name); + } + + try { + // Setup parent type if this is an interface or class. + if (klass.$.parent) { + clazz.parent = parseTypeIdentifier(modName, klass.$.parent); } - return IntrospectedCallback.fromXML(modName, ns, options, clazz, callback); - }) - ); - } - - // Virtual Methods - if (klass["virtual-method"]) { - clazz.members.push( - ...klass["virtual-method"].map(method => - IntrospectedVirtualClassFunction.fromXML(modName, ns, options, clazz, method) - ) - ); - } + if (klass.$.abstract) { + clazz.isAbstract = true; + } - // Static methods (functions) - if (klass.function) { - clazz.members.push( - ...klass.function.map(func => IntrospectedStaticClassFunction.fromXML(modName, ns, options, clazz, func)) - ); - } - } catch (e) { - console.error(`Failed to parse class: ${clazz.name} in ${ns.name}.`); - console.error(e); - } + if (Array.isArray(klass.constructor)) { + clazz.constructors.push( + ...klass.constructor.map(constructor => + IntrospectedConstructor.fromXML(modName, ns, options, clazz, constructor) + ) + ); + } - return clazz; - } - registerStaticDefinition(typeStruct: string) { - this._staticDefinition = typeStruct; - } + if (klass["glib:signal"]) { + clazz.signals.push( + ...klass["glib:signal"].map(signal => + IntrospectedSignal.fromXML(modName, ns, options, clazz, signal) + ) + ); + } - asString>(generator: T): ReturnType { - return generator.generateClass(this); - } -} + // Properties + if (klass.property) { + klass.property.forEach(prop => { + const property = GirProperty.fromXML(modName, ns, options, clazz, prop); + switch (options.propertyCase) { + case "both": + clazz.props.push(property); + + const camelCase = property.toCamelCase(); + + // Ensure we don't duplicate properties like 'show' + if (property.name !== camelCase.name) { + clazz.props.push(camelCase); + } + + break; + case "camel": + clazz.props.push(property.toCamelCase()); + break; + case "underscore": + clazz.props.push(property); + break; + } + }); + } -export class GirRecord extends IntrospectedBaseClass { - private _isForeign: boolean = false; - private _structFor: TypeIdentifier | null = null; - private _isSimple: boolean | null = null; - private _isSimpleWithoutPointers: string | null = null; + // Instance Methods + if (klass.method) { + clazz.members.push( + ...klass.method.map(method => + IntrospectedClassFunction.fromXML(modName, ns, options, clazz, method) + ) + ); + } - isForeign(): boolean { - return this._isForeign; - } + // Fields + if (klass.field) { + klass.field + .filter(field => !("callback" in field)) + .forEach(field => { + const f = Field.fromXML(modName, ns, options, null, field); - getType(): TypeIdentifier { - if (this._structFor) { - return this._structFor; - } + clazz.fields.push(f); + }); + } - return new TypeIdentifier(this.name, this.namespace.name); - } + if (klass.implements) { + klass.implements.forEach(implementee => { + const name = implementee.$.name; + const type = parseTypeIdentifier(modName, name); - someParent(predicate: (p: GirRecord) => boolean): boolean { - const resolution = this.resolveParents(); - const parent = resolution.extends(); + // Sometimes namespaces will implicitly import + // other namespaces like Atk via interface implements. + if (type && type.namespace && type.namespace !== modName && !ns.hasImport(type.namespace)) { + ns.addImport(type.namespace); + } - return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); - } + if (type) { + clazz.interfaces.push(type); + } + }); + } - findParent(predicate: (p: GirRecord) => boolean): GirRecord | undefined { - const resolution = this.resolveParents(); + // Callback Types + if (klass.callback) { + clazz.callbacks.push( + ...klass.callback.map(callback => { + if (options.verbose) { + console.debug(`Adding callback ${callback.$.name} for ${modName}`); + } - const parent = resolution.extends(); + return IntrospectedCallback.fromXML(modName, ns, options, clazz, callback); + }) + ); + } - if (parent) { - if (predicate(parent.node)) return parent.node; + // Virtual Methods + if (klass["virtual-method"]) { + clazz.members.push( + ...klass["virtual-method"].map(method => + IntrospectedVirtualClassFunction.fromXML(modName, ns, options, clazz, method) + ) + ); + } - const found = parent.node.findParent(predicate); + // Static methods (functions) + if (klass.function) { + clazz.members.push( + ...klass.function.map(func => + IntrospectedStaticClassFunction.fromXML(modName, ns, options, clazz, func) + ) + ); + } + } catch (e) { + console.error(`Failed to parse class: ${clazz.name} in ${ns.name}.`); + console.error(e); + } - if (found) return found; + return clazz; + } + registerStaticDefinition(typeStruct: string) { + this._staticDefinition = typeStruct; } - return undefined; - } - - findParentMap(predicate: (p: GirRecord) => K | undefined): K | undefined { - const resolution = this.resolveParents(); + asString>(generator: T): ReturnType { + return generator.generateClass(this) as ReturnType; + } +} - const parent = resolution.extends(); +export class IntrospectedRecord extends IntrospectedBaseClass { + private _isForeign: boolean = false; + private _structFor: TypeIdentifier | null = null; + private _isSimple: boolean | null = null; + private _isSimpleWithoutPointers: string | null = null; - if (parent) { - const result = predicate(parent.node); + isForeign(): boolean { + return this._isForeign; + } - if (result !== undefined) return result; + getType(): TypeIdentifier { + if (this._structFor) { + return this._structFor; + } - return parent.node.findParentMap(predicate); + return new TypeIdentifier(this.name, this.namespace.name); } - return undefined; - } + someParent(predicate: (p: IntrospectedRecord) => boolean): boolean { + const resolution = this.resolveParents(); + const parent = resolution.extends(); - accept(visitor: GirVisitor): GirRecord { - const node = this.copy({ - constructors: this.constructors.map(c => c.accept(visitor)), - members: this.members.map(m => m.accept(visitor)), - props: this.props.map(p => p.accept(visitor)), - fields: this.fields.map(f => f.accept(visitor)), - callbacks: this.callbacks.map(c => c.accept(visitor)) - }); + return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); + } + + findParent(predicate: (p: IntrospectedRecord) => boolean): IntrospectedRecord | undefined { + const resolution = this.resolveParents(); - return visitor.visitRecord?.(node) ?? node; - } + const parent = resolution.extends(); - resolveParents(): RecordResolution { - let { namespace, parent } = this; + if (parent) { + if (predicate(parent.node)) return parent.node; - return { - *[Symbol.iterator]() { - let current = this.extends(); + const found = parent.node.findParent(predicate); - while (current !== undefined) { - yield current; - current = current.extends(); + if (found) return found; } - }, - extends() { - let parentType = parent; - let resolved_parent = parentType ? resolveTypeIdentifier(namespace, parentType) : undefined; - if (resolved_parent instanceof GirRecord) return resolved_parent.resolveParents(); return undefined; - }, - node: this, - identifier: this.getType() - }; - } - - copy( - options: { - parent?: undefined; - constructors?: IntrospectedConstructor[]; - members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; - } = {} - ): GirRecord { - const { - name, - namespace, - parent, - members, - constructors, - _isForeign, - _structFor, - props, - fields, - callbacks, - generics, - mainConstructor - } = this; - - const clazz = new GirRecord({ name, namespace }); - - clazz._copyBaseProperties(this); - - if (parent) { - clazz.parent = parent; } - clazz._structFor = _structFor; - clazz._isForeign = _isForeign; - clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); - clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); - clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); - clazz.mainConstructor = mainConstructor?.copy() ?? null; - clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); - clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); - clazz.generics = [...generics]; - - return clazz; - } - - static foreign(name: string, namespace: IntrospectedNamespace): GirRecord { - const foreignRecord = new GirRecord({ name, namespace }); - foreignRecord._isForeign = true; - return foreignRecord; - } - - static fromXML( - modName: string, - namespace: IntrospectedNamespace, - options: LoadOptions, - klass: GirRecordElement | GirUnionElement - ): GirRecord { - if (!klass.$.name) { - throw new Error(`Invalid GIR File: No name provided for union.`); - } + findParentMap(predicate: (p: IntrospectedRecord) => K | undefined): K | undefined { + const resolution = this.resolveParents(); - const name = sanitizeIdentifierName(namespace.name, klass.$.name); + const parent = resolution.extends(); - if (options.verbose) { - console.debug(` >> GirRecord: Parsing definition ${klass.$.name} (${name})...`); - } + if (parent) { + const result = predicate(parent.node); - const clazz = new GirRecord({ name, namespace }); + if (result !== undefined) return result; - clazz.setPrivate( - klass.$.name.startsWith("_") || - ("disguised" in klass.$ && klass.$.disguised === "1") || - // Don't generate records for structs - (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) - ); + return parent.node.findParentMap(predicate); + } - if (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) { - clazz.noEmit(); + return undefined; + } - // This let's us replace these references when generating. - clazz._structFor = parseTypeIdentifier(modName, klass.$["glib:is-gtype-struct-for"]); - } else { - if (klass.$["glib:type-name"]) { - clazz.resolve_names.push(klass.$["glib:type-name"]); + accept(visitor: GirVisitor): IntrospectedRecord { + const node = this.copy({ + constructors: this.constructors.map(c => c.accept(visitor)), + members: this.members.map(m => m.accept(visitor)), + props: this.props.map(p => p.accept(visitor)), + fields: this.fields.map(f => f.accept(visitor)), + callbacks: this.callbacks.map(c => c.accept(visitor)) + }); - namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); - } + return visitor.visitRecord?.(node) ?? node; + } - if (klass.$["glib:type-struct"]) { - clazz.resolve_names.push(); + resolveParents(): RecordResolution { + const { namespace, parent } = this; - namespace.registerResolveName(klass.$["glib:type-struct"], namespace.name, name); - } + return { + *[Symbol.iterator]() { + let current = this.extends(); - if (klass.$["c:type"]) { - clazz.resolve_names.push(klass.$["c:type"]); + while (current !== undefined) { + yield current; + current = current.extends(); + } + }, + extends() { + const parentType = parent; + const resolved_parent = parentType ? resolveTypeIdentifier(namespace, parentType) : undefined; + if (resolved_parent instanceof IntrospectedRecord) return resolved_parent.resolveParents(); + + return undefined; + }, + node: this, + identifier: this.getType() + }; + } + + copy( + options: { + parent?: undefined; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; + props?: GirProperty[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; + } = {} + ): IntrospectedRecord { + const { + name, + namespace, + parent, + members, + constructors, + _isForeign, + _structFor, + props, + fields, + callbacks, + generics, + mainConstructor + } = this; + + const clazz = new IntrospectedRecord({ name, namespace }); + + clazz._copyBaseProperties(this); + + if (parent) { + clazz.parent = parent; + } - namespace.registerResolveName(klass.$["c:type"], namespace.name, name); - } + clazz._structFor = _structFor; + clazz._isForeign = _isForeign; + clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); + clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.mainConstructor = mainConstructor?.copy() ?? null; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); + clazz.generics = [...generics]; + + return clazz; } - if (options.loadDocs) { - clazz.doc = parseDoc(klass); - clazz.metadata = parseMetadata(klass); + static foreign(name: string, namespace: IntrospectedNamespace): IntrospectedRecord { + const foreignRecord = new IntrospectedRecord({ name, namespace }); + foreignRecord._isForeign = true; + return foreignRecord; } - try { - // Instance Methods - if (klass.method) { - clazz.members.push( - ...klass.method.map(method => IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method)) - ); - } + static fromXML( + modName: string, + namespace: IntrospectedNamespace, + options: LoadOptions, + klass: GirRecordElement | GirUnionElement + ): IntrospectedRecord { + if (!klass.$.name) { + throw new Error("Invalid GIR File: No name provided for union."); + } - // Constructors - if (Array.isArray(klass.constructor)) { - klass.constructor.forEach(constructor => { - const c = IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor); + const name = sanitizeIdentifierName(namespace.name, klass.$.name); - clazz.constructors.push(c); - }); - } - - // Static methods (functions) - if (klass.function) { - clazz.members.push( - ...klass.function.map(func => - IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func) - ) + if (options.verbose) { + console.debug(` >> GirRecord: Parsing definition ${klass.$.name} (${name})...`); + } + + const clazz = new IntrospectedRecord({ name, namespace }); + + clazz.setPrivate( + klass.$.name.startsWith("_") || + ("disguised" in klass.$ && klass.$.disguised === "1") || + // Don't generate records for structs + (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) ); - } - // Is this a foreign type? (don't allow construction if foreign) + if (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) { + clazz.noEmit(); - clazz._isForeign = "foreign" in klass.$ && klass.$.foreign === "1"; + // This let's us replace these references when generating. + clazz._structFor = parseTypeIdentifier(modName, klass.$["glib:is-gtype-struct-for"]); + } else { + if (klass.$["glib:type-name"]) { + clazz.resolve_names.push(klass.$["glib:type-name"]); - // Fields (for "non-class" records) - if (klass.field) { - clazz.fields.push( - ...klass.field - .filter(field => !("callback" in field)) - .map(field => Field.fromXML(modName, namespace, options, null, field)) - ); - } - } catch (e) { - console.error(`Failed to parse record: ${clazz.name}.`); - console.error(e); - } + namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); + } - return clazz; - } + if (klass.$["c:type"]) { + clazz.resolve_names.push(klass.$["c:type"]); - /** - * Calculate if a type expression is "simple" without pointers - */ - isSimpleTypeWithoutPointers(typeContainer: TypeExpression): boolean { - if (!this.isSimpleType(typeContainer)) { - return false; - } + namespace.registerResolveName(klass.$["c:type"], namespace.name, name); + } + } - if (typeContainer.isPointer) { - return false; - } + if (options.loadDocs) { + clazz.doc = parseDoc(klass); + clazz.metadata = parseMetadata(klass); + } - // Primitive types can be directly allocated. - if (typeContainer instanceof NativeType) { - return true; - } + try { + // Instance Methods + if (klass.method) { + clazz.members.push( + ...klass.method.map(method => + IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method) + ) + ); + } - if (typeContainer instanceof ArrayType) { - if (typeContainer.type.equals(this.getType())) { - return true; - } + // Constructors + if (Array.isArray(klass.constructor)) { + klass.constructor.forEach(constructor => { + const c = IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor); - return this.isSimpleTypeWithoutPointers(typeContainer.type); - } + clazz.constructors.push(c); + }); + } - if (typeContainer instanceof TypeIdentifier) { - const type = typeContainer; + // Static methods (functions) + if (klass.function) { + clazz.members.push( + ...klass.function.map(func => + IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func) + ) + ); + } - const child_ns = this.namespace.assertInstalledImport(type.namespace); + // Is this a foreign type? (don't allow construction if foreign) - const alias = child_ns.getAlias(type.name); - if (alias) { - return this.isSimpleTypeWithoutPointers(alias.type); - } + clazz._isForeign = "foreign" in klass.$ && klass.$.foreign === "1"; - const child = child_ns.getClass(type.name); - if (child === this) { - return false; - } + // Fields (for "non-class" records) + if (klass.field) { + clazz.fields.push( + ...klass.field + .filter(field => !("callback" in field)) + .map(field => Field.fromXML(modName, namespace, options, null, field)) + ); + } + } catch (e) { + console.error(`Failed to parse record: ${clazz.name}.`); + console.error(e); + } - if (child instanceof GirRecord) { - return child.isSimpleWithoutPointers() !== null; - } + return clazz; } - return false; - } + /** + * Calculate if a type expression is "simple" without pointers + */ + isSimpleTypeWithoutPointers(typeContainer: TypeExpression): boolean { + if (!this.isSimpleType(typeContainer)) { + return false; + } - /** - * Calculate if a type expression is "simple" - */ - isSimpleType(typeContainer: TypeExpression): boolean { - // Primitive types can be directly allocated. - if (typeContainer instanceof NativeType) { - return true; - } + if (typeContainer.isPointer) { + return false; + } - if (typeContainer instanceof ArrayType) { - if (typeContainer.type.equals(this.getType())) { - return true; - } + // Primitive types can be directly allocated. + if (typeContainer instanceof NativeType) { + return true; + } - return this.isSimpleType(typeContainer.type); - } + if (typeContainer instanceof ArrayType) { + if (typeContainer.type.equals(this.getType())) { + return true; + } - if (typeContainer instanceof TypeIdentifier) { - const type = typeContainer; + return this.isSimpleTypeWithoutPointers(typeContainer.type); + } - const child_ns = this.namespace.assertInstalledImport(type.namespace); + if (typeContainer instanceof TypeIdentifier) { + const type = typeContainer; - const alias = child_ns.getAlias(type.name); - if (alias) { - return this.isSimpleType(alias.type); - } + const child_ns = this.namespace.assertInstalledImport(type.namespace); - const child = child_ns.getClass(type.name); - if (child === this) { - return false; - } + const alias = child_ns.getAlias(type.name); + if (alias) { + return this.isSimpleTypeWithoutPointers(alias.type); + } - if (child instanceof GirRecord) { - return child.isSimple(); - } - } + const child = child_ns.getClass(type.name); + if (child === this) { + return false; + } - return false; - } - - /** - * Check if a record is "simple" and can be constructed by GJS - */ - isSimple() { - // Records with no fields are not - // constructable. - if (this.fields.length === 0) { - return false; - } + if (child instanceof IntrospectedRecord) { + return child.isSimpleWithoutPointers() !== null; + } + } - // Because we may have to recursively check - // if types are instantiable we cache whether - // or not a given Record is simple. - if (this._isSimple !== null) { - return this._isSimple; + return false; } - const isSimple = this.fields.every(f => this.isSimpleType(f.type)); + /** + * Calculate if a type expression is "simple" + */ + isSimpleType(typeContainer: TypeExpression): boolean { + // Primitive types can be directly allocated. + if (typeContainer instanceof NativeType) { + return true; + } - this._isSimple = isSimple; + if (typeContainer instanceof ArrayType) { + if (typeContainer.type.equals(this.getType())) { + return true; + } - return isSimple; - } + return this.isSimpleType(typeContainer.type); + } - isSimpleWithoutPointers() { - // Records which are "simple without pointers" is a subset of - // "simple" records. - if (!this.isSimple()) { - return null; - ("not simple"); - } + if (typeContainer instanceof TypeIdentifier) { + const type = typeContainer; - // Because we may have to recursively check - // if types are instantiable we cache whether - // or not a given Record is simple. - if (this._isSimpleWithoutPointers !== null) { - return this._isSimpleWithoutPointers; - } + const child_ns = this.namespace.assertInstalledImport(type.namespace); - const isSimpleWithoutPointers = this.fields.find(f => { - return !this.isSimpleTypeWithoutPointers(f.type); - }); + const alias = child_ns.getAlias(type.name); + if (alias) { + return this.isSimpleType(alias.type); + } - if (!isSimpleWithoutPointers) this._isSimpleWithoutPointers = `all fields good`; - else this._isSimpleWithoutPointers = null; + const child = child_ns.getClass(type.name); + if (child === this) { + return false; + } - return this._isSimpleWithoutPointers; - } + if (child instanceof IntrospectedRecord) { + return child.isSimple(); + } + } - asString>(generator: T): ReturnType { - return generator.generateRecord(this); - } -} + return false; + } -export class GirComplexRecord extends GirRecord { - isSimple() { - return false; - } -} + /** + * Check if a record is "simple" and can be constructed by GJS + */ + isSimple() { + // Records with no fields are not + // constructable. + if (this.fields.length === 0) { + return false; + } -export class GirInterface extends IntrospectedBaseClass { - noParent = false; - mainConstructor: null | IntrospectedConstructor = null; - - copy( - options: { - parent?: undefined; - noParent?: boolean; - constructors?: IntrospectedConstructor[]; - members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; - } = {} - ): GirInterface { - const { - name, - namespace, - parent, - noParent, - members, - constructors, - props, - fields, - callbacks, - mainConstructor, - generics - } = this; - - const clazz = new GirInterface({ name, namespace }); - - clazz._copyBaseProperties(this); - - clazz.noParent = noParent; - - if (parent) { - clazz.parent = parent; - } + // Because we may have to recursively check + // if types are instantiable we cache whether + // or not a given Record is simple. + if (this._isSimple !== null) { + return this._isSimple; + } - clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); - clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); - clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); - clazz.mainConstructor = mainConstructor?.copy() ?? null; - clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); - clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); - clazz.generics = [...generics]; + const isSimple = this.fields.every(f => this.isSimpleType(f.type)); - return clazz; - } + this._isSimple = isSimple; - someParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): boolean { - const resolution = this.resolveParents(); - const parent = resolution.extends(); + return isSimple; + } - return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); - } + isSimpleWithoutPointers() { + // Records which are "simple without pointers" is a subset of + // "simple" records. + if (!this.isSimple()) { + return null; + ("not simple"); + } - findParent(predicate: (p: IntrospectedClass | GirInterface) => boolean): GirInterface | IntrospectedClass | undefined { - const resolution = this.resolveParents(); + // Because we may have to recursively check + // if types are instantiable we cache whether + // or not a given Record is simple. + if (this._isSimpleWithoutPointers !== null) { + return this._isSimpleWithoutPointers; + } - const parent = resolution.extends(); + const isSimpleWithoutPointers = this.fields.find(f => { + return !this.isSimpleTypeWithoutPointers(f.type); + }); - if (parent) { - if (predicate(parent.node)) return parent.node; + if (!isSimpleWithoutPointers) this._isSimpleWithoutPointers = "all fields good"; + else this._isSimpleWithoutPointers = null; - const found = parent.node.findParent(predicate); + return this._isSimpleWithoutPointers; + } - if (found) return found; + asString>(generator: T): ReturnType { + return generator.generateRecord(this) as ReturnType; } +} - return undefined; - } +export class GirComplexRecord extends IntrospectedRecord { + isSimple() { + return false; + } +} - findParentMap(predicate: (p: IntrospectedClass | GirInterface) => K | undefined): K | undefined { - const resolution = this.resolveParents(); +export class IntrospectedInterface extends IntrospectedBaseClass { + noParent = false; + mainConstructor: null | IntrospectedConstructor = null; + + copy( + options: { + parent?: undefined; + noParent?: boolean; + constructors?: IntrospectedConstructor[]; + members?: IntrospectedClassFunction[]; + props?: GirProperty[]; + fields?: Field[]; + callbacks?: IntrospectedCallback[]; + } = {} + ): IntrospectedInterface { + const { + name, + namespace, + parent, + noParent, + members, + constructors, + props, + fields, + callbacks, + mainConstructor, + generics + } = this; + + const clazz = new IntrospectedInterface({ name, namespace }); + + clazz._copyBaseProperties(this); + + clazz.noParent = noParent; + + if (parent) { + clazz.parent = parent; + } - const parent = resolution.extends(); + clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); + clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.mainConstructor = mainConstructor?.copy() ?? null; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); + clazz.generics = [...generics]; - if (parent) { - const result = predicate(parent.node); + return clazz; + } - if (result !== undefined) return result; + someParent(predicate: (p: IntrospectedClass | IntrospectedInterface) => boolean): boolean { + const resolution = this.resolveParents(); + const parent = resolution.extends(); - return parent.node.findParentMap(predicate); + return !!parent && (predicate(parent.node) || parent.node.someParent(predicate)); } - return undefined; - } + findParent( + predicate: (p: IntrospectedClass | IntrospectedInterface) => boolean + ): IntrospectedInterface | IntrospectedClass | undefined { + const resolution = this.resolveParents(); - resolveParents(): InterfaceResolution { - let { namespace, parent } = this; - return { - *[Symbol.iterator]() { - let current = this.extends(); + const parent = resolution.extends(); - while (current !== undefined) { - yield current; - current = current.extends(); + if (parent) { + if (predicate(parent.node)) return parent.node; + + const found = parent.node.findParent(predicate); + + if (found) return found; } - }, - extends() { - if (!parent) return undefined; - const resolved = resolveTypeIdentifier(namespace, parent); - if (resolved && (resolved instanceof IntrospectedClass || resolved instanceof GirInterface)) - return resolved.resolveParents(); - return undefined; - }, - node: this, - identifier: this.getType() - }; - } - - accept(visitor: GirVisitor): GirInterface { - const node = this.copy({ - constructors: this.constructors.map(c => c.accept(visitor)), - members: this.members.map(m => m.accept(visitor)), - props: this.props.map(p => p.accept(visitor)), - fields: this.fields.map(f => f.accept(visitor)), - callbacks: this.callbacks.map(c => c.accept(visitor)) - }); - - return visitor.visitInterface?.(node) ?? node; - } - - static fromXML( - modName: string, - namespace: IntrospectedNamespace, - options: LoadOptions, - klass: GirInterfaceElement - ): GirInterface { - const name = sanitizeIdentifierName(namespace.name, klass.$.name); - if (options.verbose) { - console.debug(` >> GirInterface: Parsing definition ${klass.$.name} (${name})...`); + return undefined; } - const clazz = new GirInterface({ name, namespace }); + findParentMap(predicate: (p: IntrospectedClass | IntrospectedInterface) => K | undefined): K | undefined { + const resolution = this.resolveParents(); - if (options.loadDocs) { - clazz.doc = parseDoc(klass); - clazz.metadata = parseMetadata(klass); - } + const parent = resolution.extends(); - if (klass.$["glib:type-name"]) { - clazz.resolve_names.push(klass.$["glib:type-name"]); + if (parent) { + const result = predicate(parent.node); - namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); + if (result !== undefined) return result; + + return parent.node.findParentMap(predicate); + } + + return undefined; } - if (klass.$["glib:type-struct"]) { - clazz.resolve_names.push(); + resolveParents(): InterfaceResolution { + const { namespace, parent } = this; + return { + *[Symbol.iterator]() { + let current = this.extends(); - namespace.registerResolveName(klass.$["glib:type-struct"], namespace.name, name); + while (current !== undefined) { + yield current; + current = current.extends(); + } + }, + extends() { + if (!parent) return undefined; + const resolved = resolveTypeIdentifier(namespace, parent); + if (resolved && (resolved instanceof IntrospectedClass || resolved instanceof IntrospectedInterface)) + return resolved.resolveParents(); + return undefined; + }, + node: this, + identifier: this.getType() + }; } - if (klass.$["c:type"]) { - clazz.resolve_names.push(klass.$["c:type"]); + accept(visitor: GirVisitor): IntrospectedInterface { + const node = this.copy({ + constructors: this.constructors.map(c => c.accept(visitor)), + members: this.members.map(m => m.accept(visitor)), + props: this.props.map(p => p.accept(visitor)), + fields: this.fields.map(f => f.accept(visitor)), + callbacks: this.callbacks.map(c => c.accept(visitor)) + }); - namespace.registerResolveName(klass.$["c:type"], namespace.name, name); + return visitor.visitInterface?.(node) ?? node; } - try { - // Setup the "parent" (prerequisite) for this interface. - if (klass.prerequisite && klass.prerequisite[0]) { - const [prerequisite] = klass.prerequisite; + static fromXML( + modName: string, + namespace: IntrospectedNamespace, + options: LoadOptions, + klass: GirInterfaceElement + ): IntrospectedInterface { + const name = sanitizeIdentifierName(namespace.name, klass.$.name); - clazz.parent = parseTypeIdentifier(modName, prerequisite.$.name); - } + if (options.verbose) { + console.debug(` >> GirInterface: Parsing definition ${klass.$.name} (${name})...`); + } + + const clazz = new IntrospectedInterface({ name, namespace }); - if (Array.isArray(klass.constructor)) { - for (let constructor of klass.constructor) { - clazz.constructors.push(IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor)); + if (options.loadDocs) { + clazz.doc = parseDoc(klass); + clazz.metadata = parseMetadata(klass); } - } - - // Properties - if (klass.property) { - clazz.props.push( - ...klass.property - - .map(prop => GirProperty.fromXML(modName, namespace, options, clazz, prop)) - .map(prop => { - switch (options.propertyCase) { - case "both": - const camelCase = prop.toCamelCase(); - - // Ensure we don't duplicate properties like 'show' - if (prop.name !== camelCase.name) { - return [prop, prop.toCamelCase()]; - } - - return [prop]; - case "camel": - return [prop.toCamelCase()]; - case "underscore": - return [prop]; - } - }) - .flat(1) - ); - } - // Instance Methods - if (klass.method) { - for (let method of klass.method) { - const m = IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method); + if (klass.$["glib:type-name"]) { + clazz.resolve_names.push(klass.$["glib:type-name"]); - clazz.members.push(m); + namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); } - } - // Virtual Methods - if (klass["virtual-method"]) { - for (let method of klass["virtual-method"]) { - clazz.members.push(IntrospectedVirtualClassFunction.fromXML(modName, namespace, options, clazz, method)); + if (klass.$["glib:type-struct"]) { + clazz.resolve_names.push(); + + namespace.registerResolveName(klass.$["glib:type-struct"], namespace.name, name); } - } - // Callback Types - if (klass.callback) { - for (let callback of klass.callback) { - if (options.verbose) { - console.debug(`Adding callback ${callback.$.name} for ${modName}`); - } + if (klass.$["c:type"]) { + clazz.resolve_names.push(klass.$["c:type"]); - clazz.callbacks.push(IntrospectedCallback.fromXML(modName, namespace, options, clazz, callback)); + namespace.registerResolveName(klass.$["c:type"], namespace.name, name); } - } - // Static methods (functions) - if (klass.function) { - for (let func of klass.function) { - clazz.members.push(IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func)); + try { + // Setup the "parent" (prerequisite) for this interface. + if (klass.prerequisite && klass.prerequisite[0]) { + const [prerequisite] = klass.prerequisite; + + if (prerequisite.$.name) { + clazz.parent = parseTypeIdentifier(modName, prerequisite.$.name); + } + } + + if (Array.isArray(klass.constructor)) { + for (const constructor of klass.constructor) { + clazz.constructors.push( + IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor) + ); + } + } + + // Properties + if (klass.property) { + clazz.props.push( + ...klass.property + + .map(prop => GirProperty.fromXML(modName, namespace, options, clazz, prop)) + .map(prop => { + switch (options.propertyCase) { + case "both": + const camelCase = prop.toCamelCase(); + + // Ensure we don't duplicate properties like 'show' + if (prop.name !== camelCase.name) { + return [prop, prop.toCamelCase()]; + } + + return [prop]; + case "camel": + return [prop.toCamelCase()]; + case "underscore": + return [prop]; + } + }) + .flat(1) + ); + } + + // Instance Methods + if (klass.method) { + for (const method of klass.method) { + const m = IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method); + + clazz.members.push(m); + } + } + + // Virtual Methods + if (klass["virtual-method"]) { + for (const method of klass["virtual-method"]) { + clazz.members.push( + IntrospectedVirtualClassFunction.fromXML(modName, namespace, options, clazz, method) + ); + } + } + + // Callback Types + if (klass.callback) { + for (const callback of klass.callback) { + if (options.verbose) { + console.debug(`Adding callback ${callback.$.name} for ${modName}`); + } + + clazz.callbacks.push(IntrospectedCallback.fromXML(modName, namespace, options, clazz, callback)); + } + } + + // Static methods (functions) + if (klass.function) { + for (const func of klass.function) { + clazz.members.push( + IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func) + ); + } + } + } catch (e) { + console.error(`Failed to parse interface: ${clazz.name}.`); + console.error(e); } - } - } catch (e) { - console.error(`Failed to parse interface: ${clazz.name}.`); - console.error(e); + return clazz; } - return clazz; - } - asString>(generator: T): ReturnType { - return generator.generateInterface(this); - } + asString>(generator: T): ReturnType { + return generator.generateInterface(this) as ReturnType; + } } diff --git a/packages/lib/src/newlib/gir/const.ts b/packages/lib/src/newlib/gir/const.ts index 3143da872..8f2211a7e 100644 --- a/packages/lib/src/newlib/gir/const.ts +++ b/packages/lib/src/newlib/gir/const.ts @@ -1,5 +1,5 @@ -import { TypeExpression } from "../gir.js"; -import {IntrospectedBase} from './base.js'; +import { TypeExpression } from "../gir.js"; +import { IntrospectedBase } from "./base.js"; import { GirConstantElement } from "../../index.js"; import { IntrospectedNamespace } from "./namespace.js"; @@ -9,70 +9,70 @@ import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; export class IntrospectedConstant extends IntrospectedBase { - type: TypeExpression; - value: string | null; - - constructor({ - name, - type, - value - }: { - name: string; type: TypeExpression; value: string | null; - isIntrospectable?: boolean; - }) { - super(name); - - this.type = type; - this.value = value; - } - accept(visitor: GirVisitor): IntrospectedConstant { - const node = this.copy({ - type: visitor.visitType?.(this.type) - }); + constructor({ + name, + type, + value + }: { + name: string; + type: TypeExpression; + value: string | null; + isIntrospectable?: boolean; + }) { + super(name); - return visitor.visitConst?.(node) ?? node; - } + this.type = type; + this.value = value; + } - copy( - options: { - parent?: undefined; - type?: TypeExpression; - } = {} - ): IntrospectedConstant { - const { type, name, value } = this; + accept(visitor: GirVisitor): IntrospectedConstant { + const node = this.copy({ + type: visitor.visitType?.(this.type) + }); - return new IntrospectedConstant({ - name, - type: options.type ?? type, - value - })._copyBaseProperties(this); - } + return visitor.visitConst?.(node) ?? node; + } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - constant: GirConstantElement - ): IntrospectedConstant { - const c = new IntrospectedConstant({ - name: sanitizeIdentifierName(ns.name, constant.$.name), - type: getType(modName, ns, constant), - value: constant.$.value ?? null - }); + copy( + options: { + parent?: undefined; + type?: TypeExpression; + } = {} + ): IntrospectedConstant { + const { type, name, value } = this; - if (options.loadDocs) { - c.doc = parseDoc(constant); - c.metadata = parseMetadata(constant); + return new IntrospectedConstant({ + name, + type: options.type ?? type, + value + })._copyBaseProperties(this); } - return c; - } + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + constant: GirConstantElement + ): IntrospectedConstant { + const c = new IntrospectedConstant({ + name: sanitizeIdentifierName(ns.name, constant.$.name), + type: getType(modName, ns, constant), + value: constant.$.value ?? null + }); - asString>(generator: T): ReturnType { - return generator.generateConst(this); - } + if (options.loadDocs) { + c.doc = parseDoc(constant); + c.metadata = parseMetadata(constant); + } + + return c; + } + + asString>(generator: T): ReturnType { + return generator.generateConst(this) as ReturnType; + } } diff --git a/packages/lib/src/newlib/gir/enum.ts b/packages/lib/src/newlib/gir/enum.ts index e61e7b1f2..e1a7f34c7 100644 --- a/packages/lib/src/newlib/gir/enum.ts +++ b/packages/lib/src/newlib/gir/enum.ts @@ -1,9 +1,9 @@ -import { NumberType, TypeIdentifier } from "../gir.js"; +import { NumberType, TypeIdentifier } from "../gir.js"; -import { IntrospectedBase } from './base.js'; -import { GirMemberElement, GirEnumElement, GirBitfieldElement } from "../../index.js"; +import { IntrospectedBase } from "./base.js"; +import { GirMemberElement, GirEnumElement, GirBitfieldElement } from "../../index.js"; -import { GirComplexRecord, GirRecord } from "./class.js"; +import { GirComplexRecord, IntrospectedRecord } from "./class.js"; import { Field } from "./property.js"; import { IntrospectedStaticClassFunction } from "./function.js"; import { IntrospectedNamespace } from "./namespace.js"; @@ -13,246 +13,245 @@ import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; export class IntrospectedEnum extends IntrospectedBase { - members = new Map(); - flags: boolean = false; - namespace: IntrospectedNamespace; - ns: string; - - constructor(name: string, namespace: IntrospectedNamespace, options: { isIntrospectable?: boolean } = {}) { - super(sanitizeIdentifierName(namespace.name, name)); - this.namespace = namespace; - this.ns = namespace.name; - } - - copy({ - members - }: { - parent?: undefined; - members?: Map; - } = {}): IntrospectedEnum { - const { namespace, name, flags } = this; - - const en = new IntrospectedEnum(name, namespace); - - for (const [key, member] of (members ?? this.members).entries()) { - en.members.set(key, member.copy()); + members = new Map(); + flags: boolean = false; + namespace: IntrospectedNamespace; + ns: string; + + constructor(name: string, namespace: IntrospectedNamespace, options: { isIntrospectable?: boolean } = {}) { + super(sanitizeIdentifierName(namespace.name, name), options); + this.namespace = namespace; + this.ns = namespace.name; } - en.flags = flags; + copy({ + members + }: { + parent?: undefined; + members?: Map; + } = {}): IntrospectedEnum { + const { namespace, name, flags } = this; - en._copyBaseProperties(this); + const en = new IntrospectedEnum(name, namespace); - return en; - } + for (const [key, member] of (members ?? this.members).entries()) { + en.members.set(key, member.copy()); + } - accept(visitor: GirVisitor): IntrospectedEnum { - const node = this.copy({ - members: new Map( - Array.from(this.members.entries()).map(([name, m]) => { - return [name, m.accept(visitor)]; - }) - ) - }); + en.flags = flags; - return visitor.visitEnum?.(node) ?? node; - } + en._copyBaseProperties(this); - getType(): TypeIdentifier { - return new TypeIdentifier(this.name, this.ns); - } - - asString>(generator: T): ReturnType { - return generator.generateEnum(this); - } - - asClass(): GirRecord { - const { name, namespace } = this; - - const clazz = new GirComplexRecord({ name, namespace }); - - clazz.fields.push( - ...Array.from(this.members.values()).map(m => { - const field = new Field({ - name: m.name, - type: NumberType, - writable: true, - isStatic: true, - }); - - - field.doc = m.doc; - field.metadata = m.metadata; - - return field; - }) - ); - clazz.members = []; - return clazz; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - m: GirEnumElement | GirBitfieldElement, - flags = false - ): IntrospectedEnum { - const em = new IntrospectedEnum(sanitizeMemberName(m.$.name), ns); - - if (m.$["glib:type-name"]) { - em.resolve_names.push(m.$["glib:type-name"]); - - ns.registerResolveName(m.$["glib:type-name"], ns.name, em.name); + return en; } - if (m.$["c:type"]) { - em.resolve_names.push(m.$["c:type"]); + accept(visitor: GirVisitor): IntrospectedEnum { + const node = this.copy({ + members: new Map( + Array.from(this.members.entries()).map(([name, m]) => { + return [name, m.accept(visitor)]; + }) + ) + }); - ns.registerResolveName(m.$["c:type"], ns.name, em.name); + return visitor.visitEnum?.(node) ?? node; } - if (options.loadDocs) { - em.doc = parseDoc(m); - em.metadata = parseMetadata(m); + getType(): TypeIdentifier { + return new TypeIdentifier(this.name, this.ns); } - if (!m.member) { - return em; + asString>(generator: T): ReturnType { + return generator.generateEnum(this) as ReturnType; } - m.member.forEach(m => { - const member = GirEnumMember.fromXML(modName, ns, options, em, m); - - em.members.set(member.name, member); - }); + asClass(): IntrospectedRecord { + const { name, namespace } = this; - em.flags = flags; + const clazz = new GirComplexRecord({ name, namespace }); - return em; - } -} + clazz.fields.push( + ...Array.from(this.members.values()).map(m => { + const field = new Field({ + name: m.name, + type: NumberType, + writable: true, + isStatic: true + }); -export class GirEnumMember extends IntrospectedBase { - value: string; - c_identifier: string; - - constructor(name: string, value: string, c_identifier: string) { - super(name); - this.value = value; - this.c_identifier = c_identifier; - } - - accept(visitor: GirVisitor): GirEnumMember { - const node = this.copy(); - return visitor.visitEnumMember?.(node) ?? node; - } - - copy(): GirEnumMember { - const { value, name, c_identifier } = this; - - return new GirEnumMember(name, value, c_identifier)._copyBaseProperties(this); - } - - static fromXML( - _: string, - _ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - m: GirMemberElement - ): GirEnumMember { - const upper = m.$.name.toUpperCase(); - const c_identifier = m.$["c:identifier"]; - - const enumMember = new GirEnumMember(upper, m.$.value, c_identifier); - - if (options.loadDocs) { - enumMember.doc = parseDoc(m); - enumMember.metadata = parseMetadata(m); + field.doc = m.doc; + field.metadata = m.metadata; + + return field; + }) + ); + clazz.members = []; + return clazz; } - return enumMember; - } + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + m: GirEnumElement | GirBitfieldElement, + flags = false + ): IntrospectedEnum { + const em = new IntrospectedEnum(sanitizeMemberName(m.$.name), ns); - asString>(generator: T): ReturnType { - return generator.generateEnumMember(this); - } -} + if (m.$["glib:type-name"]) { + em.resolve_names.push(m.$["glib:type-name"]); -function isEnumElement(e: unknown): e is GirEnumElement { - return typeof e === "object" && e != null && "function" in e; -} + ns.registerResolveName(m.$["glib:type-name"], ns.name, em.name); + } -export class IntrospectedError extends IntrospectedEnum { - functions: Map = new Map(); + if (m.$["c:type"]) { + em.resolve_names.push(m.$["c:type"]); - asString>(generator: T): ReturnType { - return generator.generateError(this); - } + ns.registerResolveName(m.$["c:type"], ns.name, em.name); + } - copy({ - members - }: { - parent?: undefined; - members?: Map; - } = {}): IntrospectedEnum { - const { namespace, name, flags } = this; + if (options.loadDocs) { + em.doc = parseDoc(m); + em.metadata = parseMetadata(m); + } - const en = new IntrospectedError(name, namespace); + if (!m.member) { + return em; + } - for (const [key, member] of (members ?? this.members).entries()) { - en.members.set(key, member.copy()); - } + m.member.forEach(m => { + const member = GirEnumMember.fromXML(modName, ns, options, em, m); - for (const [key, func] of this.functions.entries()) { - en.functions.set(key, func.copy({ parent: en })); + em.members.set(member.name, member); + }); + + em.flags = flags; + + return em; } +} - en.flags = flags; +export class GirEnumMember extends IntrospectedBase { + value: string; + c_identifier: string; - return en._copyBaseProperties(this); - } + constructor(name: string, value: string, c_identifier: string) { + super(name); + this.value = value; + this.c_identifier = c_identifier; + } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent, - m: GirEnumElement | GirBitfieldElement - ): IntrospectedEnum { - const err = new IntrospectedError(sanitizeMemberName(m.$.name), ns); + accept(visitor: GirVisitor): GirEnumMember { + const node = this.copy(); + return visitor.visitEnumMember?.(node) ?? node; + } - if (m.$["glib:type-name"]) { - err.resolve_names.push(m.$["glib:type-name"]); + copy(): GirEnumMember { + const { value, name, c_identifier } = this; - ns.registerResolveName(m.$["glib:type-name"], ns.name, err.name); + return new GirEnumMember(name, value, c_identifier)._copyBaseProperties(this); } - if (m.$["c:type"]) { - err.resolve_names.push(m.$["c:type"]); + static fromXML( + _: string, + _ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + m: GirMemberElement + ): GirEnumMember { + const upper = m.$.name.toUpperCase(); + const c_identifier = m.$["c:identifier"]; + + const enumMember = new GirEnumMember(upper, m.$.value, c_identifier); + + if (options.loadDocs) { + enumMember.doc = parseDoc(m); + enumMember.metadata = parseMetadata(m); + } - ns.registerResolveName(m.$["c:type"], ns.name, err.name); + return enumMember; } - if (options.loadDocs) { - err.doc = parseDoc(m); - err.metadata = parseMetadata(m); + asString>(generator: T): ReturnType { + return generator.generateEnumMember(this) as ReturnType; } +} + +function isEnumElement(e: unknown): e is GirEnumElement { + return typeof e === "object" && e != null && "function" in e; +} - if (m.member) { - m.member.forEach(m => { - const member = GirEnumMember.fromXML(modName, ns, options, parent, m); - err.members.set(member.name, member); - }); +export class IntrospectedError extends IntrospectedEnum { + functions: Map = new Map(); + + asString>(generator: T): ReturnType { + return generator.generateError(this) as ReturnType; } - if (isEnumElement(m) && m.function) { - m.function.forEach(f => { - const func = IntrospectedStaticClassFunction.fromXML(modName, ns, options, err, f); - err.functions.set(func.name, func); - }); + copy({ + members + }: { + parent?: undefined; + members?: Map; + } = {}): IntrospectedEnum { + const { namespace, name, flags } = this; + + const en = new IntrospectedError(name, namespace); + + for (const [key, member] of (members ?? this.members).entries()) { + en.members.set(key, member.copy()); + } + + for (const [key, func] of this.functions.entries()) { + en.functions.set(key, func.copy({ parent: en })); + } + + en.flags = flags; + + return en._copyBaseProperties(this); } - return err; - } + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent, + m: GirEnumElement | GirBitfieldElement + ): IntrospectedEnum { + const err = new IntrospectedError(sanitizeMemberName(m.$.name), ns); + + if (m.$["glib:type-name"]) { + err.resolve_names.push(m.$["glib:type-name"]); + + ns.registerResolveName(m.$["glib:type-name"], ns.name, err.name); + } + + if (m.$["c:type"]) { + err.resolve_names.push(m.$["c:type"]); + + ns.registerResolveName(m.$["c:type"], ns.name, err.name); + } + + if (options.loadDocs) { + err.doc = parseDoc(m); + err.metadata = parseMetadata(m); + } + + if (m.member) { + m.member.forEach(m => { + const member = GirEnumMember.fromXML(modName, ns, options, parent, m); + err.members.set(member.name, member); + }); + } + + if (isEnumElement(m) && m.function) { + m.function.forEach(f => { + const func = IntrospectedStaticClassFunction.fromXML(modName, ns, options, err, f); + err.functions.set(func.name, func); + }); + } + + return err; + } } diff --git a/packages/lib/src/newlib/gir/function.ts b/packages/lib/src/newlib/gir/function.ts index 1388553c1..2852f0c41 100644 --- a/packages/lib/src/newlib/gir/function.ts +++ b/packages/lib/src/newlib/gir/function.ts @@ -1,37 +1,28 @@ import { - - TypeIdentifier, - UnknownType, - VoidType, - ArrayType, - ClosureType, - NullableType, - TypeExpression, - Generic, - FunctionType, - + TypeIdentifier, + UnknownType, + VoidType, + ArrayType, + ClosureType, + NullableType, + TypeExpression, + Generic, + FunctionType } from "../gir.js"; -import {IntrospectedBase, Options} from './base.js'; +import { IntrospectedBase, Options } from "./base.js"; import { - GirFunctionElement, - GirMethodElement, - GirDirection, - GirCallableParamElement, - GirCallbackElement, - GirVirtualMethodElement, - GirConstructorElement + GirFunctionElement, + GirMethodElement, + GirDirection, + GirCallableParamElement, + GirCallbackElement, + GirVirtualMethodElement, + GirConstructorElement } from "../../index.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; -import { - getType, - isInvalid, - sanitizeMemberName, - sanitizeIdentifierName, - parseDoc, - parseMetadata -} from "./util.js"; +import { getType, isInvalid, sanitizeMemberName, sanitizeIdentifierName, parseDoc, parseMetadata } from "./util.js"; import { IntrospectedBaseClass, IntrospectedClass } from "./class.js"; import { IntrospectedEnum } from "./enum.js"; import { IntrospectedSignal } from "./signal.js"; @@ -40,835 +31,838 @@ import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; import { Field } from "./property.js"; -function hasShadow( - obj: GirFunctionElement | GirMethodElement -): obj is GirFunctionElement & { $: { shadows: string } } { - return obj.$["shadows"] != null; +function hasShadow(obj: GirFunctionElement | GirMethodElement): obj is GirFunctionElement & { $: { shadows: string } } { + return obj.$["shadows"] != null; } export class IntrospectedFunction extends IntrospectedBase { - readonly parameters: IntrospectedFunctionParameter[]; - readonly output_parameters: IntrospectedFunctionParameter[]; - readonly return_type: TypeExpression; - readonly raw_name: string; - - generics: Generic[] = []; - - constructor({ - name, - raw_name, - return_type = UnknownType, - parameters = [], - output_parameters = [], - ...args - }: Options<{ - name: string; - raw_name: string; - return_type?: TypeExpression; - parameters?: IntrospectedFunctionParameter[]; - output_parameters?: IntrospectedFunctionParameter[]; - }>) { - super(name, { ...args }); - - this.raw_name = raw_name; - this.parameters = parameters.map(p => p.copy({ parent: this })); - this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); - this.return_type = return_type; - } - - copy({ - outputParameters, - parameters, - return_type - }: { - parent?: undefined; - parameters?: IntrospectedFunctionParameter[]; - outputParameters?: IntrospectedFunctionParameter[]; - return_type?: TypeExpression; - } = {}): IntrospectedFunction { - const fn = new IntrospectedFunction({ - raw_name: this.raw_name, - name: this.name, - return_type: return_type ?? this.return_type, - output_parameters: outputParameters ?? this.output_parameters, - parameters: parameters ?? this.parameters - }); - - fn.generics = [...this.generics]; - - return fn._copyBaseProperties(this); - } - - accept(visitor: GirVisitor): IntrospectedFunction { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - outputParameters: this.output_parameters.map(p => { - return p.accept(visitor); - }), - return_type: visitor.visitType?.(this.return_type) - }); - - return visitor.visitFunction?.(node) ?? node; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - func: GirFunctionElement | GirMethodElement - ): IntrospectedFunction { - let raw_name = func.$.name; - let name = sanitizeIdentifierName(null, raw_name); - - if (hasShadow(func)) { - raw_name = func.$["shadows"]; - name = sanitizeIdentifierName(null, func.$["shadows"]); - } - - let return_type: TypeExpression; - - if ("return-value" in func && func["return-value"] && func["return-value"].length > 0) { - const value = func["return-value"][0]; - - return_type = getType(modName, ns, value); - } else { - return_type = VoidType; - } - - let parameters: IntrospectedFunctionParameter[] = []; - - if (func.parameters) { - const param = func.parameters[0].parameter; - - if (param) { - const inputs = param.filter((p): p is typeof p & { $: { name: string } } => { - return !!p.$.name; - }); + readonly parameters: IntrospectedFunctionParameter[]; + readonly output_parameters: IntrospectedFunctionParameter[]; + readonly return_type: TypeExpression; + readonly raw_name: string; - parameters.push(...inputs.map(i => IntrospectedFunctionParameter.fromXML(modName, ns, options, null, i))); + generics: Generic[] = []; - const unwrapped = return_type.unwrap(); + constructor({ + name, + raw_name, + return_type = UnknownType, + parameters = [], + output_parameters = [], + ...args + }: Options<{ + name: string; + raw_name: string; + return_type?: TypeExpression; + parameters?: IntrospectedFunctionParameter[]; + output_parameters?: IntrospectedFunctionParameter[]; + }>) { + super(name, { ...args }); + + this.raw_name = raw_name; + this.parameters = parameters.map(p => p.copy({ parent: this })); + this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); + this.return_type = return_type; + } - const length_params = - unwrapped instanceof ArrayType && unwrapped.length != null ? [unwrapped.length] : ([] as number[]); - const user_data_params = [] as number[]; + copy({ + outputParameters, + parameters, + return_type + }: { + parent?: undefined; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; + return_type?: TypeExpression; + } = {}): IntrospectedFunction { + const fn = new IntrospectedFunction({ + raw_name: this.raw_name, + name: this.name, + return_type: return_type ?? this.return_type, + output_parameters: outputParameters ?? this.output_parameters, + parameters: parameters ?? this.parameters + }); - parameters = parameters - .map(p => { - const unwrapped_type = p.type.unwrap(); + fn.generics = [...this.generics]; - if (unwrapped_type instanceof ArrayType && unwrapped_type.length != null) { - length_params.push(unwrapped_type.length); + return fn._copyBaseProperties(this); + } - return p; - } + accept(visitor: GirVisitor): IntrospectedFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + return_type: visitor.visitType?.(this.return_type) + }); - if (unwrapped_type instanceof ClosureType && unwrapped_type.user_data != null) { - user_data_params.push(unwrapped_type.user_data); + return visitor.visitFunction?.(node) ?? node; + } - return p; + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + func: GirFunctionElement | GirMethodElement + ): IntrospectedFunction { + let raw_name = func.$.name; + let name = sanitizeIdentifierName(null, raw_name); + + if (hasShadow(func)) { + raw_name = func.$["shadows"]; + name = sanitizeIdentifierName(null, func.$["shadows"]); + } + + let return_type: TypeExpression; + + if ("return-value" in func && func["return-value"] && func["return-value"].length > 0) { + const value = func["return-value"][0]; + + return_type = getType(modName, ns, value); + } else { + return_type = VoidType; + } + + let parameters: IntrospectedFunctionParameter[] = []; + + if (func.parameters) { + const param = func.parameters[0].parameter; + + if (param) { + const inputs = param.filter((p): p is typeof p & { $: { name: string } } => { + return !!p.$.name; + }); + + parameters.push( + ...inputs.map(i => IntrospectedFunctionParameter.fromXML(modName, ns, options, null, i)) + ); + + const unwrapped = return_type.unwrap(); + + const length_params = + unwrapped instanceof ArrayType && unwrapped.length != null ? [unwrapped.length] : ([] as number[]); + const user_data_params = [] as number[]; + + parameters = parameters + .map(p => { + const unwrapped_type = p.type.unwrap(); + + if (unwrapped_type instanceof ArrayType && unwrapped_type.length != null) { + length_params.push(unwrapped_type.length); + + return p; + } + + if (unwrapped_type instanceof ClosureType && unwrapped_type.user_data != null) { + user_data_params.push(unwrapped_type.user_data); + + return p; + } + + return p; + }) + .filter((_, i) => { + // We remove any length parameters. + return !length_params.includes(i) && !user_data_params.includes(i); + }) + .filter(v => !(v.type instanceof TypeIdentifier && v.type.is("GLib", "DestroyNotify"))) + .reverse() + .reduce( + ({ allowOptions, params }, p) => { + const { type, isOptional } = p; + + if (allowOptions) { + if (type instanceof NullableType) { + params.push(p.copy({ isOptional: true })); + } else if (!isOptional) { + params.push(p); + return { allowOptions: false, params }; + } else { + params.push(p); + } + } else { + if (isOptional) { + params.push(p.copy({ type: new NullableType(type), isOptional: false })); + } else { + params.push(p); + } + } + + return { allowOptions, params }; + }, + { + allowOptions: true, + params: [] as IntrospectedFunctionParameter[] + } + ) + .params.reverse() + .filter((p): p is IntrospectedFunctionParameter => p != null); } + } + + const input_parameters = parameters.filter( + param => param.direction === GirDirection.In || param.direction === GirDirection.Inout + ); + const output_parameters = parameters + .filter( + param => + param.direction && (param.direction === GirDirection.Out || param.direction === GirDirection.Inout) + ) + .map(parameter => parameter.copy({ isOptional: false })); + + const fn = new IntrospectedFunction({ + parameters: input_parameters, + output_parameters, + return_type, + name, + raw_name, + isIntrospectable: isIntrospectable(func) + }); - return p; - }) - .filter((_, i) => { - // We remove any length parameters. - return !length_params.includes(i) && !user_data_params.includes(i); - }) - .filter(v => !(v.type instanceof TypeIdentifier && v.type.is("GLib", "DestroyNotify"))) - .reverse() - .reduce( - ({ allowOptions, params }, p) => { - const { type, isOptional } = p; - - if (allowOptions) { - if (type instanceof NullableType) { - params.push(p.copy({ isOptional: true })); - } else if (!isOptional) { - params.push(p); - return { allowOptions: false, params }; - } else { - params.push(p); - } - } else { - if (isOptional) { - params.push(p.copy({ type: new NullableType(type), isOptional: false })); - } else { - params.push(p); - } - } - - return { allowOptions, params }; - }, - { - allowOptions: true, - params: [] as IntrospectedFunctionParameter[] - } - ) - .params.reverse() - .filter((p): p is IntrospectedFunctionParameter => p != null); - } - } - - let input_parameters = parameters.filter( - param => param.direction === GirDirection.In || param.direction === GirDirection.Inout - ); - let output_parameters = parameters - .filter( - param => param.direction && (param.direction === GirDirection.Out || param.direction === GirDirection.Inout) - ) - .map(parameter => parameter.copy({ isOptional: false })); - - const fn = new IntrospectedFunction({ - parameters: input_parameters, - output_parameters, - return_type, - name, - raw_name, - isIntrospectable: isIntrospectable(func) - }); - - if (options.loadDocs) { - fn.doc = parseDoc(func); - fn.metadata = parseMetadata(func); - } - - return fn; - } - - return() { - return this.return_type; - } - - asCallback(): IntrospectedCallback { - const { raw_name, name, output_parameters, parameters, return_type } = this; - - return new IntrospectedCallback({ - raw_name, - name, - output_parameters, - parameters, - return_type - }); - } - - asClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedClassFunction { - const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - - return new IntrospectedClassFunction({ - parent, - name, - output_parameters, - parameters, - return_type, - doc, - isIntrospectable - }); - } - - asVirtualClassFunction(parent: IntrospectedBaseClass): IntrospectedVirtualClassFunction { - const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - - return new IntrospectedVirtualClassFunction({ - parent, - name, - output_parameters, - parameters, - return_type, - doc, - isIntrospectable - }); - } - - asStaticClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedStaticClassFunction { - const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - - return new IntrospectedStaticClassFunction({ - parent, - name, - output_parameters, - parameters, - return_type, - doc, - isIntrospectable - }); - } - - asString>(generator: T): ReturnType { - return generator.generateFunction(this); - } + if (options.loadDocs) { + fn.doc = parseDoc(func); + fn.metadata = parseMetadata(func); + } + + return fn; + } + + return() { + return this.return_type; + } + + asCallback(): IntrospectedCallback { + const { raw_name, name, output_parameters, parameters, return_type } = this; + + return new IntrospectedCallback({ + raw_name, + name, + output_parameters, + parameters, + return_type + }); + } + + asClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedClassFunction { + const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + return new IntrospectedClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + } + + asVirtualClassFunction(parent: IntrospectedBaseClass): IntrospectedVirtualClassFunction { + const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + return new IntrospectedVirtualClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + } + + asStaticClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedStaticClassFunction { + const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + return new IntrospectedStaticClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + } + + asString>(generator: T): ReturnType { + return generator.generateFunction(this) as ReturnType; + } } export class IntrospectedDirectAllocationConstructor extends IntrospectedBase { - fields: Field[]; - - constructor(fields: Field[]) { - super("new", { isPrivate: false, isIntrospectable: true }); - - this.fields = fields - .filter(field => { - return !field.isStatic && !field.isPrivate && !field.type.isPointer; - }) - .map(field => field.copy({ parent: this })); - } - - asString>( - generator: T - ): ReturnType { - return generator.generateDirectAllocationConstructor(this); - } - - copy( - options?: { parent?: IntrospectedBase | undefined; fields: Field[] } | undefined - ): IntrospectedDirectAllocationConstructor { - const copy = new IntrospectedDirectAllocationConstructor(options?.fields ?? this.fields); - - copy._copyBaseProperties(this); - - return copy; - } - - accept(visitor: GirVisitor): IntrospectedDirectAllocationConstructor { - const node = this.copy({ - fields: this.fields.map(field => { - return field.accept(visitor); - }) - }); - - return visitor.visitDirectAllocationConstructor?.(node) ?? node; - } + fields: Field[]; + + constructor(fields: Field[]) { + super("new", { isPrivate: false, isIntrospectable: true }); + + this.fields = fields + .filter(field => { + return !field.isStatic && !field.isPrivate && !field.type.isPointer; + }) + .map(field => field.copy({ parent: this })); + } + + asString>(generator: T): ReturnType { + return generator.generateDirectAllocationConstructor(this) as ReturnType< + T["generateDirectAllocationConstructor"] + >; + } + + copy( + options?: { parent?: IntrospectedBase | undefined; fields: Field[] } | undefined + ): IntrospectedDirectAllocationConstructor { + const copy = new IntrospectedDirectAllocationConstructor(options?.fields ?? this.fields); + + copy._copyBaseProperties(this); + + return copy; + } + + accept(visitor: GirVisitor): IntrospectedDirectAllocationConstructor { + const node = this.copy({ + fields: this.fields.map(field => { + return field.accept(visitor); + }) + }); + + return visitor.visitDirectAllocationConstructor?.(node) ?? node; + } } export class IntrospectedConstructor extends IntrospectedBase { - readonly parameters: IntrospectedFunctionParameter[] = []; - readonly return_type: TypeExpression = UnknownType; - - constructor({ - name, - parameters = [], - return_type, - ...args - }: Options<{ - name: string; - parameters?: IntrospectedFunctionParameter[]; - return_type: TypeExpression; - }>) { - super(name, { ...args }); - this.return_type = return_type; - this.parameters = parameters.map(p => p.copy({ parent: this })); - } - - copy({ - parameters, - return_type - }: { - parent?: undefined; - parameters?: IntrospectedFunctionParameter[]; - return_type?: TypeExpression; - } = {}): IntrospectedConstructor { - return new IntrospectedConstructor({ - name: this.name, - return_type: return_type ?? this.return_type, - parameters: parameters ?? this.parameters - })._copyBaseProperties(this); - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedBaseClass, - m: GirConstructorElement - ): IntrospectedConstructor { - return IntrospectedClassFunction.fromXML(modName, ns, options, parent, m as GirFunctionElement).asConstructor(); - } - - accept(visitor: GirVisitor): IntrospectedConstructor { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - return_type: visitor.visitType?.(this.return_type) - }); - - return visitor.visitConstructor?.(node) ?? node; - } - - return() { - return this.return_type; - } - - asString>(generator: T): ReturnType { - return generator.generateConstructor(this); - } + readonly parameters: IntrospectedFunctionParameter[] = []; + readonly return_type: TypeExpression = UnknownType; + + constructor({ + name, + parameters = [], + return_type, + ...args + }: Options<{ + name: string; + parameters?: IntrospectedFunctionParameter[]; + return_type: TypeExpression; + }>) { + super(name, { ...args }); + this.return_type = return_type; + this.parameters = parameters.map(p => p.copy({ parent: this })); + } + + copy({ + parameters, + return_type + }: { + parent?: undefined; + parameters?: IntrospectedFunctionParameter[]; + return_type?: TypeExpression; + } = {}): IntrospectedConstructor { + return new IntrospectedConstructor({ + name: this.name, + return_type: return_type ?? this.return_type, + parameters: parameters ?? this.parameters + })._copyBaseProperties(this); + } + + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedBaseClass, + m: GirConstructorElement + ): IntrospectedConstructor { + return IntrospectedClassFunction.fromXML(modName, ns, options, parent, m as GirFunctionElement).asConstructor(); + } + + accept(visitor: GirVisitor): IntrospectedConstructor { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + return_type: visitor.visitType?.(this.return_type) + }); + + return visitor.visitConstructor?.(node) ?? node; + } + + return() { + return this.return_type; + } + + asString>(generator: T): ReturnType { + return generator.generateConstructor(this) as ReturnType; + } } export class IntrospectedFunctionParameter extends IntrospectedBase { - readonly type: TypeExpression; - readonly direction: GirDirection; - readonly isVarArgs: boolean = false; - readonly isOptional: boolean = false; - readonly isNullable: boolean = false; - readonly parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; - - constructor({ - name, - direction, - type, - parent, - doc, - isVarArgs = false, - isOptional = false, - isNullable = false, - ...args - }: Options<{ - name: string; - parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; - type: TypeExpression; - direction: GirDirection; - doc?: string | null; - isVarArgs?: boolean; - isOptional?: boolean; - isNullable?: boolean; - }>) { - super(name, { ...args }); - - this.parent = parent; - this.type = type; - this.direction = direction; - this.doc = doc; - this.isVarArgs = isVarArgs; - this.isOptional = isOptional; - this.isNullable = isNullable; - } - - copy( - options: { - parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; - type?: TypeExpression; - isOptional?: boolean; - isNullable?: boolean; - } = { - parent: this.parent - } - ): IntrospectedFunctionParameter { - const { type, parent, direction, isVarArgs, isOptional, isNullable, name, doc } = this; - - return new IntrospectedFunctionParameter({ - parent: options.parent ?? parent, - name, - direction, - isVarArgs, - isOptional: options.isOptional ?? isOptional, - isNullable: options.isNullable ?? isNullable, - type: options.type ?? type, - doc - })._copyBaseProperties(this); - } - - accept(visitor: GirVisitor): IntrospectedFunctionParameter { - const node = this.copy({ - type: visitor.visitType?.(this.type) - }); - - return visitor.visitParameter?.(node) ?? node; - } - - asString>(generator: T): ReturnType { - return generator.generateParameter(this); - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedSignal | IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor | null, - parameter: GirCallableParamElement & { $: { name: string } } - ): IntrospectedFunctionParameter { - let name = sanitizeMemberName(parameter.$.name); - - if (isInvalid(name)) { - name = `_${name}`; - } - - let isVarArgs = false; - let isOptional = false; - let isNullable = false; - - let type: TypeExpression; - let direction: GirDirection; - - if ( - !parameter.$.direction || - parameter.$.direction === GirDirection.In || - parameter.$.direction === GirDirection.Inout - ) { - if (name === "...") { - isVarArgs = true; - name = "args"; - } - - // Default to "in" direction - direction = parameter.$.direction || GirDirection.In; - - const optional = parameter.$.optional === "1"; - const nullable = parameter.$.nullable === "1"; - - if (optional) { - isOptional = true; - } - - if (nullable) { - isNullable = true; - } - - type = getType(modName, ns, parameter); - } else if (parameter.$.direction === GirDirection.Out || parameter.$.direction === GirDirection.Inout) { - direction = parameter.$.direction; - type = getType(modName, ns, parameter); - } else { - throw new Error(`Unknown parameter direction: ${parameter.$.direction}`); - } - - const fp = new IntrospectedFunctionParameter({ - isVarArgs, - type: isVarArgs ? new ArrayType(type) : type, - direction, - parent: parent ?? undefined, - isOptional, - isNullable, - name, - isIntrospectable: isIntrospectable(parameter) - }); - - if (options.loadDocs) { - fp.doc = parseDoc(parameter); - fp.metadata = parseMetadata(parameter); - } - - return fp; - } + readonly type: TypeExpression; + readonly direction: GirDirection; + readonly isVarArgs: boolean = false; + readonly isOptional: boolean = false; + readonly isNullable: boolean = false; + readonly parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; + + constructor({ + name, + direction, + type, + parent, + doc, + isVarArgs = false, + isOptional = false, + isNullable = false, + ...args + }: Options<{ + name: string; + parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; + type: TypeExpression; + direction: GirDirection; + doc?: string | null; + isVarArgs?: boolean; + isOptional?: boolean; + isNullable?: boolean; + }>) { + super(name, { ...args }); + + this.parent = parent; + this.type = type; + this.direction = direction; + this.doc = doc; + this.isVarArgs = isVarArgs; + this.isOptional = isOptional; + this.isNullable = isNullable; + } + + copy( + options: { + parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; + type?: TypeExpression; + isOptional?: boolean; + isNullable?: boolean; + } = { + parent: this.parent + } + ): IntrospectedFunctionParameter { + const { type, parent, direction, isVarArgs, isOptional, isNullable, name, doc } = this; + + return new IntrospectedFunctionParameter({ + parent: options.parent ?? parent, + name, + direction, + isVarArgs, + isOptional: options.isOptional ?? isOptional, + isNullable: options.isNullable ?? isNullable, + type: options.type ?? type, + doc + })._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): IntrospectedFunctionParameter { + const node = this.copy({ + type: visitor.visitType?.(this.type) + }); + + return visitor.visitParameter?.(node) ?? node; + } + + asString(generator: FormatGenerator): T { + return generator.generateParameter(this); + } + + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedSignal | IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor | null, + parameter: GirCallableParamElement & { $: { name: string } } + ): IntrospectedFunctionParameter { + let name = sanitizeMemberName(parameter.$.name); + + if (isInvalid(name)) { + name = `_${name}`; + } + + let isVarArgs = false; + let isOptional = false; + let isNullable = false; + + let type: TypeExpression; + let direction: GirDirection; + + if ( + !parameter.$.direction || + parameter.$.direction === GirDirection.In || + parameter.$.direction === GirDirection.Inout || + parameter.$.direction === GirDirection.InOut + ) { + if (name === "...") { + isVarArgs = true; + name = "args"; + } + + // Default to "in" direction + direction = parameter.$.direction || GirDirection.In; + + const optional = parameter.$.optional === "1"; + const nullable = parameter.$.nullable === "1"; + + if (optional) { + isOptional = true; + } + + if (nullable) { + isNullable = true; + } + + type = getType(modName, ns, parameter); + } else if (parameter.$.direction === GirDirection.Out) { + direction = parameter.$.direction; + type = getType(modName, ns, parameter); + } else { + throw new Error(`Unknown parameter direction: ${parameter.$.direction as string}`); + } + + const fp = new IntrospectedFunctionParameter({ + isVarArgs, + type: isVarArgs ? new ArrayType(type) : type, + direction, + parent: parent ?? undefined, + isOptional, + isNullable, + name, + isIntrospectable: isIntrospectable(parameter) + }); + + if (options.loadDocs) { + fp.doc = parseDoc(parameter); + fp.metadata = parseMetadata(parameter); + } + + return fp; + } } export class IntrospectedClassFunction extends IntrospectedBase { - readonly parameters: IntrospectedFunctionParameter[]; - protected readonly return_type: TypeExpression; - readonly output_parameters: IntrospectedFunctionParameter[]; - protected _anyify: boolean = false; - protected _generify: boolean = false; - parent: IntrospectedBaseClass | IntrospectedEnum; - interfaceParent: IntrospectedBaseClass | IntrospectedEnum | null = null; - - generics: Generic[] = []; - - constructor({ - name, - parameters = [], - output_parameters = [], - return_type = UnknownType, - parent, - doc, - ...args - }: Options<{ - name: string; - parameters?: IntrospectedFunctionParameter[]; - output_parameters?: IntrospectedFunctionParameter[]; - return_type?: TypeExpression; + readonly parameters: IntrospectedFunctionParameter[]; + protected readonly return_type: TypeExpression; + readonly output_parameters: IntrospectedFunctionParameter[]; + protected _anyify: boolean = false; + protected _generify: boolean = false; parent: IntrospectedBaseClass | IntrospectedEnum; - doc?: string | null; - }>) { - super(name, { ...args }); - - this.parameters = parameters.map(p => p.copy({ parent: this })); - this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); - this.return_type = return_type; - this.parent = parent; - this.doc = doc; - } - - asConstructor(): IntrospectedConstructor { - const { name, parameters } = this; - - if (this.parent instanceof IntrospectedBaseClass) { - // Always force constructors to have the correct return type. - return new IntrospectedConstructor({ + interfaceParent: IntrospectedBaseClass | IntrospectedEnum | null = null; + + generics: Generic[] = []; + + constructor({ name, + parameters = [], + output_parameters = [], + return_type = UnknownType, + parent, + doc, + ...args + }: Options<{ + name: string; + parameters?: IntrospectedFunctionParameter[]; + output_parameters?: IntrospectedFunctionParameter[]; + return_type?: TypeExpression; + parent: IntrospectedBaseClass | IntrospectedEnum; + doc?: string | null; + }>) { + super(name, { ...args }); + + this.parameters = parameters.map(p => p.copy({ parent: this })); + this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); + this.return_type = return_type; + this.parent = parent; + this.doc = doc; + } + + asConstructor(): IntrospectedConstructor { + const { name, parameters } = this; + + if (this.parent instanceof IntrospectedBaseClass) { + // Always force constructors to have the correct return type. + return new IntrospectedConstructor({ + name, + parameters, + return_type: this.parent.getType(), + isIntrospectable: this.isIntrospectable + }); + } + + throw new Error( + `Attempted to convert GirClassFunction into GirConstructor from invalid parent: ${this.parent.name}` + ); + } + + asStaticClassFunction(parent: IntrospectedClass) { + const { name, parameters, return_type, output_parameters } = this; + + return new IntrospectedStaticClassFunction({ + name, + parameters, + output_parameters, + return_type, + parent, + isIntrospectable: this.isIntrospectable + }); + } + + copy({ + parent = this.parent, + interfaceParent, parameters, - return_type: this.parent.getType(), - isIntrospectable: this.isIntrospectable - }); - } - - throw new Error( - `Attempted to convert GirClassFunction into GirConstructor from invalid parent: ${this.parent.name}` - ); - } - - asStaticClassFunction(parent: IntrospectedClass): any { - const { name, parameters, return_type, output_parameters } = this; - - return new IntrospectedStaticClassFunction({ - name, - parameters, - output_parameters, - return_type, - parent, - isIntrospectable: this.isIntrospectable - }); - } - - copy({ - parent = this.parent, - interfaceParent, - parameters, - outputParameters, - returnType - }: { - parent?: IntrospectedBaseClass | IntrospectedEnum; - interfaceParent?: IntrospectedBaseClass | IntrospectedEnum; - parameters?: IntrospectedFunctionParameter[]; - outputParameters?: IntrospectedFunctionParameter[]; - returnType?: TypeExpression; - } = {}): IntrospectedClassFunction { - let constr = IntrospectedClassFunction; - - if (this instanceof IntrospectedVirtualClassFunction) { - constr = IntrospectedVirtualClassFunction; - } else if (this instanceof IntrospectedStaticClassFunction) { - constr = IntrospectedStaticClassFunction; - } - - const fn = new constr({ - name: this.name, - parent, - output_parameters: outputParameters ?? this.output_parameters, - parameters: parameters ?? this.parameters, - return_type: returnType ?? this.return_type - }); - - fn.generics = [...this.generics]; - - if (interfaceParent) { - fn.interfaceParent = interfaceParent; - } - - return fn._copyBaseProperties(this); - } - - accept(visitor: GirVisitor): IntrospectedClassFunction { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - outputParameters: this.output_parameters.map(p => { - return p.accept(visitor); - }), - returnType: visitor.visitType?.(this.return_type) - }); - - const fn = visitor.visitClassFunction?.(node); - - return fn ?? node; - } - - anyify(): this { - this._anyify = true; - - return this; - } - - shouldAnyify() { - return this._anyify; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedBaseClass | IntrospectedEnum, - m: GirFunctionElement | GirMethodElement - ): IntrospectedClassFunction { - const fn = IntrospectedFunction.fromXML(modName, ns, options, null, m); - - return fn.asClassFunction(parent); - } - - return(): TypeExpression { - return this.return_type; - } - - asString>(generator: T): ReturnType { - return generator.generateClassFunction(this); - } + outputParameters, + returnType + }: { + parent?: IntrospectedBaseClass | IntrospectedEnum; + interfaceParent?: IntrospectedBaseClass | IntrospectedEnum; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; + returnType?: TypeExpression; + } = {}): IntrospectedClassFunction { + let constr = IntrospectedClassFunction; + + if (this instanceof IntrospectedVirtualClassFunction) { + constr = IntrospectedVirtualClassFunction; + } else if (this instanceof IntrospectedStaticClassFunction) { + constr = IntrospectedStaticClassFunction; + } + + const fn = new constr({ + name: this.name, + parent, + output_parameters: outputParameters ?? this.output_parameters, + parameters: parameters ?? this.parameters, + return_type: returnType ?? this.return_type + }); + + fn.generics = [...this.generics]; + + if (interfaceParent) { + fn.interfaceParent = interfaceParent; + } + + return fn._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): IntrospectedClassFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + const fn = visitor.visitClassFunction?.(node); + + return fn ?? node; + } + + anyify(): this { + this._anyify = true; + + return this; + } + + shouldAnyify() { + return this._anyify; + } + + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedBaseClass | IntrospectedEnum, + m: GirFunctionElement | GirMethodElement + ): IntrospectedClassFunction { + const fn = IntrospectedFunction.fromXML(modName, ns, options, null, m); + + return fn.asClassFunction(parent); + } + + return(): TypeExpression { + return this.return_type; + } + + asString>(generator: T): ReturnType { + return generator.generateClassFunction(this) as ReturnType; + } } export class IntrospectedVirtualClassFunction extends IntrospectedClassFunction { - constructor({ - name, - parameters = [], - output_parameters = [], - return_type = UnknownType, - parent, - doc, - ...args - }: Options<{ - name: string; - parameters: IntrospectedFunctionParameter[]; - output_parameters?: IntrospectedFunctionParameter[]; - return_type?: TypeExpression; - parent: IntrospectedBaseClass; - doc?: string | null; - }>) { - super({ - parent, - name: name.startsWith("vfunc_") ? name : `vfunc_${name}`, - parameters, - output_parameters, - return_type, - doc, - ...args - }); - } - - return(): TypeExpression { - return this.return_type; - } - - accept(visitor: GirVisitor): IntrospectedVirtualClassFunction { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - outputParameters: this.output_parameters.map(p => { - return p.accept(visitor); - }), - returnType: visitor.visitType?.(this.return_type) - }); - return visitor.visitVirtualClassFunction?.(node) ?? node; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedBaseClass, - m: GirVirtualMethodElement - ): IntrospectedVirtualClassFunction { - const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); - - return fn.asVirtualClassFunction(parent); - } - - asString>(generator: T): ReturnType { - return generator.generateVirtualClassFunction(this); - } + constructor({ + name, + parameters = [], + output_parameters = [], + return_type = UnknownType, + parent, + doc, + ...args + }: Options<{ + name: string; + parameters: IntrospectedFunctionParameter[]; + output_parameters?: IntrospectedFunctionParameter[]; + return_type?: TypeExpression; + parent: IntrospectedBaseClass; + doc?: string | null; + }>) { + super({ + parent, + name: name.startsWith("vfunc_") ? name : `vfunc_${name}`, + parameters, + output_parameters, + return_type, + doc, + ...args + }); + } + + return(): TypeExpression { + return this.return_type; + } + + accept(visitor: GirVisitor): IntrospectedVirtualClassFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + return visitor.visitVirtualClassFunction?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedBaseClass, + m: GirVirtualMethodElement + ): IntrospectedVirtualClassFunction { + const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); + + return fn.asVirtualClassFunction(parent); + } + + asString>(generator: T): ReturnType { + return generator.generateVirtualClassFunction(this) as ReturnType; + } } export class IntrospectedStaticClassFunction extends IntrospectedClassFunction { - asString>(generator: T): ReturnType { - return generator.generateStaticClassFunction(this); - } - - accept(visitor: GirVisitor): IntrospectedStaticClassFunction { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - outputParameters: this.output_parameters.map(p => { - return p.accept(visitor); - }), - returnType: visitor.visitType?.(this.return_type) - }); - - return visitor.visitStaticClassFunction?.(node) ?? node; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedBaseClass | IntrospectedEnum, - m: GirFunctionElement - ): IntrospectedStaticClassFunction { - const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); - - return fn.asStaticClassFunction(parent); - } + asString>(generator: T): ReturnType { + return generator.generateStaticClassFunction(this) as ReturnType; + } + + accept(visitor: GirVisitor): IntrospectedStaticClassFunction { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + return visitor.visitStaticClassFunction?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedBaseClass | IntrospectedEnum, + m: GirFunctionElement + ): IntrospectedStaticClassFunction { + const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); + + return fn.asStaticClassFunction(parent); + } } export class IntrospectedCallback extends IntrospectedFunction { - asFunctionType(): FunctionType { - return new FunctionType( - Object.fromEntries(this.parameters.map(p => [p.name, p.type] as const)), - this.return_type - ); - } - - copy({ - parameters, - returnType, - outputParameters - }: { - parent?: undefined; - parameters?: IntrospectedFunctionParameter[]; - outputParameters?: IntrospectedFunctionParameter[]; - returnType?: TypeExpression; - } = {}): IntrospectedCallback { - const cb = new IntrospectedCallback({ - name: this.name, - raw_name: this.raw_name, - return_type: returnType ?? this.return_type, - parameters: parameters ?? this.parameters, - output_parameters: outputParameters ?? this.output_parameters - })._copyBaseProperties(this); - - cb.generics = [...this.generics]; - - return cb; - } - - accept(visitor: GirVisitor): IntrospectedCallback { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - outputParameters: this.output_parameters.map(p => { - return p.accept(visitor); - }), - returnType: visitor.visitType?.(this.return_type) - }); - - return visitor.visitCallback?.(node) ?? node; - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - func: GirCallbackElement - ): IntrospectedCallback { - const cb = IntrospectedFunction.fromXML(modName, ns, options, null, func).asCallback(); - - if (func.$["glib:type-name"]) { - cb.resolve_names.push(func.$["glib:type-name"]); - - ns.registerResolveName(func.$["glib:type-name"], ns.name, cb.name); - } - - if (func.$["c:type"]) { - cb.resolve_names.push(func.$["c:type"]); - - ns.registerResolveName(func.$["c:type"], ns.name, cb.name); - } - - return cb; - } - - asString>(generator: T): ReturnType { - return generator.generateCallback(this); - } + asFunctionType(): FunctionType { + return new FunctionType( + Object.fromEntries(this.parameters.map(p => [p.name, p.type] as const)), + this.return_type + ); + } + + copy({ + parameters, + returnType, + outputParameters + }: { + parent?: undefined; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; + returnType?: TypeExpression; + } = {}): IntrospectedCallback { + const cb = new IntrospectedCallback({ + name: this.name, + raw_name: this.raw_name, + return_type: returnType ?? this.return_type, + parameters: parameters ?? this.parameters, + output_parameters: outputParameters ?? this.output_parameters + })._copyBaseProperties(this); + + cb.generics = [...this.generics]; + + return cb; + } + + accept(visitor: GirVisitor): IntrospectedCallback { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + return visitor.visitCallback?.(node) ?? node; + } + + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + _parent, + func: GirCallbackElement + ): IntrospectedCallback { + const cb = IntrospectedFunction.fromXML(modName, ns, options, null, func).asCallback(); + + const glibTypeName = func.$["glib:type-name"]; + if (typeof glibTypeName === "string" && func.$["glib:type-name"]) { + cb.resolve_names.push(glibTypeName); + + ns.registerResolveName(glibTypeName, ns.name, cb.name); + } + + if (func.$["c:type"]) { + cb.resolve_names.push(func.$["c:type"]); + + ns.registerResolveName(func.$["c:type"], ns.name, cb.name); + } + + return cb; + } + + asString>(generator: T): ReturnType { + return generator.generateCallback(this) as ReturnType; + } } diff --git a/packages/lib/src/newlib/gir/generics.ts b/packages/lib/src/newlib/gir/generics.ts index 45b80a054..f9acee5d9 100644 --- a/packages/lib/src/newlib/gir/generics.ts +++ b/packages/lib/src/newlib/gir/generics.ts @@ -1,68 +1,68 @@ const GenericNames = [ - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - "J", - "K", - "L", - "M", - "N", - "O", - "P", - "Q", - "R", - "S", - "U", - "V", - "W", - "X", - "Y", - "Z" + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "U", + "V", + "W", + "X", + "Y", + "Z" ]; export function* getGenericNames(start: string = "A") { - let names = GenericNames.map(s => `${s}`); - let startIteration = Number.parseInt(start.slice(1) || "0"); + let names = GenericNames.map(s => `${s}`); + const startIteration = Number.parseInt(start.slice(1) || "0"); - let i = startIteration; + let i = startIteration; - names = names.map(s => (i == 0 ? s : `${s}${i}`)); + names = names.map(s => (i == 0 ? s : `${s}${i}`)); - let StartLetter = start[0]; - const position = GenericNames.indexOf(StartLetter); + const StartLetter = start[0]; + const position = GenericNames.indexOf(StartLetter); - while (true) { - for (const name of names) { - if (i === startIteration && GenericNames.indexOf(name) >= position) { - yield name; - } - } + while (true) { + for (const name of names) { + if (i === startIteration && GenericNames.indexOf(name) >= position) { + yield name; + } + } - names = names.map(s => `${s}${i}`); + names = names.map(s => `${s}${i}`); - i++; - } + i++; + } - // This will always be a string return. - return "ThisShouldNeverHappen"; + // This will always be a string return. + return "ThisShouldNeverHappen"; } export class GenericNameGenerator { - static new(): () => string { - const genericNames = getGenericNames(); + static new(): () => string { + const genericNames = getGenericNames(); - return () => genericNames.next().value; - } + return () => genericNames.next().value; + } - static at(start: string): () => string { - const genericNames = getGenericNames(start); + static at(start: string): () => string { + const genericNames = getGenericNames(start); - return () => genericNames.next().value; - } + return () => genericNames.next().value; + } } diff --git a/packages/lib/src/newlib/gir/namespace.ts b/packages/lib/src/newlib/gir/namespace.ts index 2820d8fc4..b2c1e7f35 100644 --- a/packages/lib/src/newlib/gir/namespace.ts +++ b/packages/lib/src/newlib/gir/namespace.ts @@ -1,21 +1,20 @@ import { - - NullableType, - ObjectType, - BinaryType, - VoidType, - PromiseType, - BooleanType, - TupleType, - TypeIdentifier, - ClosureType + NullableType, + ObjectType, + BinaryType, + VoidType, + PromiseType, + BooleanType, + TupleType, + TypeIdentifier, + ClosureType } from "../gir.js"; -import {IntrospectedBase, Options, Metadata} from './base.js'; -import { GirAliasElement, ParsedGir, GirInfoAttrs, GirType } from "../../index.js"; +import { IntrospectedBase } from "./base.js"; +import { ParsedGir, GirInfoAttrs, GirType } from "../../index.js"; import { isPrimitiveType } from "./util.js"; -import { IntrospectedClass, GirInterface, GirRecord, IntrospectedBaseClass } from "./class.js"; +import { IntrospectedClass, IntrospectedInterface, IntrospectedRecord, IntrospectedBaseClass } from "./class.js"; import { IntrospectedFunction, IntrospectedCallback } from "./function.js"; import { IntrospectedEnum, IntrospectedError } from "./enum.js"; import { IntrospectedConstant } from "./const.js"; @@ -25,549 +24,558 @@ import { LoadOptions } from "../types.js"; import { NSRegistry } from "./registry.js"; import { GirVisitor } from "../visitor.js"; -export type GirNSMember = IntrospectedBaseClass | IntrospectedFunction | IntrospectedConstant | IntrospectedEnum | IntrospectedAlias; +export type GirNSMember = + | IntrospectedBaseClass + | IntrospectedFunction + | IntrospectedConstant + | IntrospectedEnum + | IntrospectedAlias; export const isIntrospectable = (e: { $?: GirInfoAttrs }) => - !e || !e.$ || !e.$.introspectable || e.$.introspectable === "1"; + !e || !e.$ || !e.$.introspectable || e.$.introspectable === "1"; export const isDeprecated = (e: { $: GirInfoAttrs }) => e && e.$ && e.$.deprecated === "1"; export const deprecatedVersion = (e: { $: GirInfoAttrs }) => e?.$?.["deprecated-version"]; export const introducedVersion = (e: { $: GirInfoAttrs }) => e?.$?.version; export function promisifyNamespaceFunctions(namespace: IntrospectedNamespace) { - return namespace.members.forEach(node => { - if (!(node instanceof IntrospectedFunction)) return; - - if (node.parameters.length < 1) return; - - const last_param = node.parameters[node.parameters.length - 1]; - - if (!last_param) return; - - const last_param_unwrapped = last_param.type.unwrap(); - - if (!(last_param_unwrapped instanceof ClosureType)) return; - - const internal = last_param_unwrapped.type; - - if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { - let async_res = [ - ...Array.from(namespace.members.values()).filter((m): m is IntrospectedFunction => m instanceof IntrospectedFunction) - ].find( - m => m.name === `${node.name.replace(/_async$/, "")}_finish` || m.name === `${node.name}_finish` - ); - - if (async_res) { - const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); - const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); - const output_parameters = async_res.output_parameters; - - let async_return = new PromiseType(async_res.return()); - - if (output_parameters.length > 0) { - const raw_return = async_res.return(); - if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { - const [output_type, ...output_types] = output_parameters.map(op => op.type); - async_return = new PromiseType(new TupleType(output_type, ...output_types)); - } else { - const [...output_types] = output_parameters.map(op => op.type); - async_return = new PromiseType(new TupleType(raw_return, ...output_types)); - } - } - - namespace.members.set(node.name, [ - node.copy({ - parameters: async_parameters, - return_type: async_return - }), - node.copy({ - parameters: sync_parameters - }), - node.copy({ - return_type: new BinaryType(async_return, node.return()) - }) - ]); - } - } - }); + return namespace.members.forEach(node => { + if (!(node instanceof IntrospectedFunction)) return; + + if (node.parameters.length < 1) return; + + const last_param = node.parameters[node.parameters.length - 1]; + + if (!last_param) return; + + const last_param_unwrapped = last_param.type.unwrap(); + + if (!(last_param_unwrapped instanceof ClosureType)) return; + + const internal = last_param_unwrapped.type; + + if (internal instanceof TypeIdentifier && internal.is("Gio", "AsyncReadyCallback")) { + const async_res = [ + ...Array.from(namespace.members.values()).filter( + (m): m is IntrospectedFunction => m instanceof IntrospectedFunction + ) + ].find(m => m.name === `${node.name.replace(/_async$/, "")}_finish` || m.name === `${node.name}_finish`); + + if (async_res) { + const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); + const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); + const output_parameters = async_res.output_parameters; + + let async_return = new PromiseType(async_res.return()); + + if (output_parameters.length > 0) { + const raw_return = async_res.return(); + if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { + const [output_type, ...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(output_type, ...output_types)); + } else { + const [...output_types] = output_parameters.map(op => op.type); + async_return = new PromiseType(new TupleType(raw_return, ...output_types)); + } + } + + namespace.members.set(node.name, [ + node.copy({ + parameters: async_parameters, + return_type: async_return + }), + node.copy({ + parameters: sync_parameters + }), + node.copy({ + return_type: new BinaryType(async_return, node.return()) + }) + ]); + } + } + }); } export class IntrospectedNamespace { - readonly name: string; - readonly version: string; - readonly c_prefixes: string[]; - - private imports: Map = new Map(); - default_imports: Map = new Map(); - - private _members?: Map; - private _enum_constants?: Map; - private _resolve_names: Map = new Map(); - __dts__references?: string[]; - - package_version!: readonly [string, string] | readonly [string, string, string]; - parent!: NSRegistry; - - constructor(name: string, version: string, prefixes: string[]) { - this.name = name; - this.version = version; - this.c_prefixes = [...prefixes]; - this.package_version = ['0', '0']; - } - - registerResolveName(resolveName: string, namespace: string, name: string) { - this._resolve_names.set(resolveName, new TypeIdentifier(name, namespace)); - } - - get members(): Map { - if (!this._members) { - this._members = new Map(); - } + readonly name: string; + readonly version: string; + readonly c_prefixes: string[]; - return this._members; - } + private imports: Map = new Map(); + default_imports: Map = new Map(); - get enum_constants(): Map { - if (!this._enum_constants) { - this._enum_constants = new Map(); - } - - return this._enum_constants; - } + private _members?: Map; + private _enum_constants?: Map; + private _resolve_names: Map = new Map(); + __dts__references?: string[]; - accept(visitor: GirVisitor) { - for (const key of [...this.members.keys()]) { - const member = this.members.get(key); + package_version!: readonly [string, string] | readonly [string, string, string]; + parent!: NSRegistry; - if (!member) continue; + constructor(name: string, version: string, prefixes: string[]) { + this.name = name; + this.version = version; + this.c_prefixes = [...prefixes]; + this.package_version = ["0", "0"]; + } - if (Array.isArray(member)) { - this.members.set( - key, - member.map(m => { - return m.accept(visitor); - }) - ); - } else { - this.members.set(key, member.accept(visitor)); - } + registerResolveName(resolveName: string, namespace: string, name: string) { + this._resolve_names.set(resolveName, new TypeIdentifier(name, namespace)); } - } - getImportsForCPrefix(c_prefix: string): IntrospectedNamespace[] { - return this.parent.namespacesForPrefix(c_prefix); - } + get members(): Map { + if (!this._members) { + this._members = new Map(); + } - hasImport(name: string): boolean { - return this.default_imports.has(name) || this.imports.has(name); - } + return this._members; + } - private _getImport(name: string): IntrospectedNamespace | null { - let version = this.default_imports.get(name) ?? this.imports.get(name); + get enum_constants(): Map { + if (!this._enum_constants) { + this._enum_constants = new Map(); + } - if (name === this.name) { - return this; + return this._enum_constants; } - // TODO: Clean this up, but essentially try to resolve import versions - // using transitive imports (e.g. use GtkSource to find the version of Gtk) - if (!version) { - const entries = [...this.default_imports.entries()].flatMap(([_name]) => { - const namespace = this._getImport(_name); + accept(visitor: GirVisitor) { + for (const key of [...this.members.keys()]) { + const member = this.members.get(key); - return [...namespace?.default_imports.entries() ?? []] - }) + if (!member) continue; - version = Object.fromEntries(entries)[name]; + if (Array.isArray(member)) { + this.members.set( + key, + member.map(m => { + return m.accept(visitor); + }) + ); + } else { + this.members.set(key, member.accept(visitor)); + } + } } - if (!version) { - version = this.parent.assertDefaultVersionOf(name); + getImportsForCPrefix(c_prefix: string): IntrospectedNamespace[] { + return this.parent.namespacesForPrefix(c_prefix); } - const namespace = this.parent.namespace(name, version); - - if (namespace) { - if (!this.imports.has(namespace.name)) { - this.imports.set(namespace.name, namespace.version); - } + hasImport(name: string): boolean { + return this.default_imports.has(name) || this.imports.has(name); } - return namespace; - } - - getInstalledImport(name: string): IntrospectedNamespace | null { - let version = this.default_imports.get(name) ?? this.imports.get(name); + private _getImport(name: string): IntrospectedNamespace | null { + let version = this.default_imports.get(name) ?? this.imports.get(name); - if (name === this.name) { - return this; - } + if (name === this.name) { + return this; + } - if (!version) { - version = this.parent.defaultVersionOf(name) ?? undefined; - } + // TODO: Clean this up, but essentially try to resolve import versions + // using transitive imports (e.g. use GtkSource to find the version of Gtk) + if (!version) { + const entries = [...this.default_imports.entries()].flatMap(([_name]) => { + const namespace = this._getImport(_name); - if (!version) { - return null; - } + return [...(namespace?.default_imports.entries() ?? [])]; + }); - const namespace = this.parent.namespace(name, version); + version = Object.fromEntries(entries)[name]; + } - if (namespace) { - if (!this.imports.has(namespace.name)) { - this.imports.set(namespace.name, namespace.version); - } - } + if (!version) { + version = this.parent.assertDefaultVersionOf(name); + } - return namespace; - } + const namespace = this.parent.namespace(name, version); - assertInstalledImport(name: string): IntrospectedNamespace { - let namespace = this._getImport(name); + if (namespace) { + if (!this.imports.has(namespace.name)) { + this.imports.set(namespace.name, namespace.version); + } + } - if (!namespace) { - throw new Error(`Failed to import ${name} in ${this.name}, not installed or accessible.`); + return namespace; } - return namespace; - } + getInstalledImport(name: string): IntrospectedNamespace | null { + let version = this.default_imports.get(name) ?? this.imports.get(name); - getImports(): [string, string][] { - return [...this.imports.entries()].sort(([[a], [b]]) => a.localeCompare(b)); - } + if (name === this.name) { + return this; + } + + if (!version) { + version = this.parent.defaultVersionOf(name) ?? undefined; + } - addImport(ns_name: string) { + if (!version) { + return null; + } - this._getImport(ns_name); - } + const namespace = this.parent.namespace(name, version); - getMembers(name: string): IntrospectedBase[] { - const members = this.members.get(name); + if (namespace) { + if (!this.imports.has(namespace.name)) { + this.imports.set(namespace.name, namespace.version); + } + } - if (Array.isArray(members)) { - return [...members]; + return namespace; } - return members ? [members] : []; - } - getMemberWithoutOverrides(name: string) { - if (this.members.has(name)) { - const member = this.members.get(name); + assertInstalledImport(name: string): IntrospectedNamespace { + const namespace = this._getImport(name); - if (!Array.isArray(member)) { - return member; - } + if (!namespace) { + throw new Error(`Failed to import ${name} in ${this.name}, not installed or accessible.`); + } - return null; + return namespace; } - const resolvedName = this._resolve_names.get(name); - if (resolvedName) { - const member = this.members.get(resolvedName.name); - - if (!Array.isArray(member)) { - return member; - } + getImports(): [string, string][] { + return [...this.imports.entries()].sort(([[a], [b]]) => a.localeCompare(b)); } - return null; - } + addImport(ns_name: string) { + this._getImport(ns_name); + } - assertClass(name: string): IntrospectedBaseClass { - const clazz = this.getClass(name); + getMembers(name: string): IntrospectedBase[] { + const members = this.members.get(name); - if (!clazz) { - throw new Error(`Class ${name} does not exist in namespace ${this.name}.`); + if (Array.isArray(members)) { + return [...members]; + } + return members ? [members] : []; } - return clazz; - } + getMemberWithoutOverrides(name: string) { + if (this.members.has(name)) { + const member = this.members.get(name); - getClass(name: string): IntrospectedBaseClass | null { - const member = this.getMemberWithoutOverrides(name); - - if (member instanceof IntrospectedBaseClass) { - return member; - } - return null; - } + if (!Array.isArray(member)) { + return member; + } - getEnum(name: string): IntrospectedEnum | null { - const member = this.getMemberWithoutOverrides(name); + return null; + } - if (member instanceof IntrospectedEnum) { - return member; - } - return null; - } + const resolvedName = this._resolve_names.get(name); + if (resolvedName) { + const member = this.members.get(resolvedName.name); - getAlias(name: string): IntrospectedAlias | null { - const member = this.getMemberWithoutOverrides(name); + if (!Array.isArray(member)) { + return member; + } + } - if (member instanceof IntrospectedAlias) { - return member; + return null; } - return null; - } - hasSymbol(name: string) { - return this.members.has(name); - } + assertClass(name: string): IntrospectedBaseClass { + const clazz = this.getClass(name); - resolveSymbolFromTypeName(name: string): string | null { - const resolvedName = this._resolve_names.get(name); + if (!clazz) { + throw new Error(`Class ${name} does not exist in namespace ${this.name}.`); + } - if (!resolvedName) { - return null; + return clazz; } - const member = this.members.get(resolvedName.name); - if (member instanceof IntrospectedBase) { - return member.name; - } + getClass(name: string): IntrospectedBaseClass | null { + const member = this.getMemberWithoutOverrides(name); - return null; - } - - findClassCallback(name: string): [string | null, string] { - const clazzes = Array.from(this.members.values()).filter( - (m): m is IntrospectedBaseClass => m instanceof IntrospectedBaseClass - ); - const res = clazzes - .map<[IntrospectedBaseClass, IntrospectedCallback | undefined]>(m => [ - m, - m.callbacks.find(c => c.name === name || c.resolve_names.includes(name)) - ]) - .find((r): r is [IntrospectedBaseClass, IntrospectedCallback] => r[1] != null); - - if (res) { - return [res[0].name, res[1].name]; - } else { - return [null, name]; + if (member instanceof IntrospectedBaseClass) { + return member; + } + return null; } - } - - /** - * This is an internal method to add TypeScript - * comments when overrides use parts of the TypeScript standard - * libraries that are newer than default. - */ - ___dts___addReference(reference: string) { - this.__dts__references ??= []; - this.__dts__references.push(reference); - } - static fromXML(repo: ParsedGir, options: LoadOptions, registry: NSRegistry): IntrospectedNamespace { - const ns = repo.repository[0]?.namespace?.[0]; + getEnum(name: string): IntrospectedEnum | null { + const member = this.getMemberWithoutOverrides(name); - if (!ns) throw new Error(`Missing namespace in ${repo.repository[0].package[0].$.name}`) + if (member instanceof IntrospectedEnum) { + return member; + } + return null; + } - const modName = ns.$["name"]; - let version = ns.$["version"]; + getAlias(name: string): IntrospectedAlias | null { + const member = this.getMemberWithoutOverrides(name); - // Hardcode harfbuzz version for now... - if (modName === "HarfBuzz" && version === "0.0") { - version = "2.0"; + if (member instanceof IntrospectedAlias) { + return member; + } + return null; } - if (!modName) { - throw new Error(`Invalid GIR file: no namespace name specified.`); + hasSymbol(name: string) { + return this.members.has(name); } - if (!version) { - throw new Error(`Invalid GIR file: no version name specified.`); - } + resolveSymbolFromTypeName(name: string): string | null { + const resolvedName = this._resolve_names.get(name); - const c_prefix = ns.$?.["c:symbol-prefixes"]?.split(",") ?? []; + if (!resolvedName) { + return null; + } - if (options.verbose) { - console.debug(`Parsing ${modName}...`); - } + const member = this.members.get(resolvedName.name); + if (member instanceof IntrospectedBase) { + return member.name; + } - const building = new IntrospectedNamespace(modName, version, c_prefix); - building.parent = registry; - // Set the namespace object here to prevent re-parsing the namespace if - // another namespace imports it. - registry.mapping.set(modName, version, building); - - const includes = repo.repository[0].include || []; - - includes - .map(i => [i.$.name, i.$.version] as const) - .forEach(([name, version]) => { - if (version) { - if (options.verbose) { - console.debug(`Adding dependency ${name} ${version}...`); - } - - building.default_imports.set(name, version); - } - }); - - const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { - return !building.hasImport(el.name); - }; - - if (ns.enumeration) { - // Get the requested enums - ns.enumeration - ?.map(enumeration => { - if (enumeration.$["glib:error-domain"]) { - return IntrospectedError.fromXML(modName, building, options, null, enumeration); - } else { - return IntrospectedEnum.fromXML(modName, building, options, null, enumeration); - } - }) - .forEach(c => building.members.set(c.name, c)); + return null; } - // Constants - if (ns.constant) { - ns.constant - ?.filter(isIntrospectable) - .map(constant => IntrospectedConstant.fromXML(modName, building, options, null, constant)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); + findClassCallback(name: string): [string | null, string] { + const clazzes = Array.from(this.members.values()).filter( + (m): m is IntrospectedBaseClass => m instanceof IntrospectedBaseClass + ); + const res = clazzes + .map<[IntrospectedBaseClass, IntrospectedCallback | undefined]>(m => [ + m, + m.callbacks.find(c => c.name === name || c.resolve_names.includes(name)) + ]) + .find((r): r is [IntrospectedBaseClass, IntrospectedCallback] => r[1] != null); + + if (res) { + return [res[0].name, res[1].name]; + } else { + return [null, name]; + } } - // Get the requested functions - if (ns.function) { - ns.function - ?.filter(isIntrospectable) - .map(func => IntrospectedFunction.fromXML(modName, building, options, null, func)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); + /** + * This is an internal method to add TypeScript + * comments when overrides use parts of the TypeScript standard + * libraries that are newer than default. + */ + ___dts___addReference(reference: string) { + this.__dts__references ??= []; + this.__dts__references.push(reference); } - if (ns.callback) { - ns.callback - ?.filter(isIntrospectable) - .map(callback => IntrospectedCallback.fromXML(modName, building, options, null, callback)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } + static fromXML(repo: ParsedGir, options: LoadOptions, registry: NSRegistry): IntrospectedNamespace { + const ns = repo.repository[0]?.namespace?.[0]; - if (ns["glib:boxed"]) { - ns["glib:boxed"] - ?.filter(isIntrospectable) - .map(boxed => new IntrospectedAlias({ name: boxed.$["glib:name"], type: new NullableType(ObjectType) })) - .forEach(c => building.members.set(c.name, c)); - } + if (!ns) throw new Error(`Missing namespace in ${repo.repository[0].package[0].$.name}`); + const modName = ns.$["name"]; + let version = ns.$["version"]; - // Bitfield is a type of enum - if (ns.bitfield) { - ns.bitfield - ?.filter(isIntrospectable) - .map(field => IntrospectedEnum.fromXML(modName, building, options, building, field, true)) - .forEach(c => building.members.set(c.name, c)); - } + // Hardcode harfbuzz version for now... + if (modName === "HarfBuzz" && version === "0.0") { + version = "2.0"; + } - // The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y) - // to the name of the enum (Button) to resolve references (Gtk.Button.Y) - Array.from(building.members.values()) - .filter((m): m is IntrospectedEnum => m instanceof IntrospectedEnum) - .forEach(m => { - m.members.forEach(member => { - building.enum_constants.set(member.c_identifier, [m.name, member.name] as const); - }); - }); - - // Get the requested classes - if (ns.class) { - ns.class - ?.filter(isIntrospectable) - .map(klass => IntrospectedClass.fromXML(modName, building, options, building, klass)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } + if (!modName) { + throw new Error("Invalid GIR file: no namespace name specified."); + } - if (ns.record) { - ns.record - ?.filter(isIntrospectable) - .map(record => GirRecord.fromXML(modName, building, options, record)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } + if (!version) { + throw new Error("Invalid GIR file: no version name specified."); + } - if (ns.union) { - ns.union - ?.filter(isIntrospectable) - .map(union => GirRecord.fromXML(modName, building, options, union)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } + const c_prefix = ns.$?.["c:symbol-prefixes"]?.split(",") ?? []; - if (ns.interface) { - ns.interface - ?.map(inter => GirInterface.fromXML(modName, building, options, inter)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } + if (options.verbose) { + console.debug(`Parsing ${modName}...`); + } + + const building = new IntrospectedNamespace(modName, version, c_prefix); + building.parent = registry; + // Set the namespace object here to prevent re-parsing the namespace if + // another namespace imports it. + registry.mapping.set(modName, version, building); + + const includes = repo.repository[0].include || []; + + includes + .map(i => [i.$.name, i.$.version] as const) + .forEach(([name, version]) => { + if (version) { + if (options.verbose) { + console.debug(`Adding dependency ${name} ${version}...`); + } - if (ns.alias) { - type NamedType = GirType & { $: { name: string } }; - - ns.alias - ?.filter(isIntrospectable) - // Avoid attempting to alias non-introspectable symbols. - .map(b => { - b.type = b.type?.filter((t): t is NamedType => !!(t && t.$.name)) - .map(t => { - if ( - t.$.name && - !building.hasSymbol(t.$.name) && - !isPrimitiveType(t.$.name) && - !t.$.name.includes(".") - ) { - return { $: { name: "unknown", "c:type": "unknown" } } as GirType; - } - - return t; + building.default_imports.set(name, version); + } }); - return b; - }) - .map(alias => IntrospectedAlias.fromXML(modName, building, options, null, alias)) - .filter((alias): alias is IntrospectedAlias => alias != null) - .forEach(c => building.members.set(c.name, c)); - } + const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { + return !building.hasImport(el.name); + }; + + if (ns.enumeration) { + // Get the requested enums + ns.enumeration + ?.map(enumeration => { + if (enumeration.$["glib:error-domain"]) { + return IntrospectedError.fromXML(modName, building, options, null, enumeration); + } else { + return IntrospectedEnum.fromXML(modName, building, options, null, enumeration); + } + }) + .forEach(c => building.members.set(c.name, c)); + } - try { - let [major = null] = building.getMembers("MAJOR_VERSION"); - let [minor = null] = building.getMembers("MINOR_VERSION"); - let [micro = null] = building.getMembers("MICRO_VERSION"); + // Constants + if (ns.constant) { + ns.constant + ?.filter(isIntrospectable) + .map(constant => IntrospectedConstant.fromXML(modName, building, options, null, constant)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } - if (!major) { - major = building.getMembers("VERSION_MAJOR")[0] ?? null; - } + // Get the requested functions + if (ns.function) { + ns.function + ?.filter(isIntrospectable) + .map(func => IntrospectedFunction.fromXML(modName, building, options, null, func)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } - if (!minor) { - minor = building.getMembers("VERSION_MINOR")[0] ?? null; - } + if (ns.callback) { + ns.callback + ?.filter(isIntrospectable) + .map(callback => IntrospectedCallback.fromXML(modName, building, options, null, callback)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } - if (!micro) { - micro = building.getMembers("VERSION_MICRO")[0] ?? null; - } + if (ns["glib:boxed"]) { + ns["glib:boxed"] + ?.filter(isIntrospectable) + .map(boxed => new IntrospectedAlias({ name: boxed.$["glib:name"], type: new NullableType(ObjectType) })) + .forEach(c => building.members.set(c.name, c)); + } - if (major instanceof IntrospectedConstant && minor instanceof IntrospectedConstant && major.value && minor.value) { - if (micro instanceof IntrospectedConstant && micro.value) { - building.package_version = [major.value, minor.value, micro.value] as const; - } else { - building.package_version = [major.value, minor.value] as const; + // Bitfield is a type of enum + if (ns.bitfield) { + ns.bitfield + ?.filter(isIntrospectable) + .map(field => IntrospectedEnum.fromXML(modName, building, options, building, field, true)) + .forEach(c => building.members.set(c.name, c)); } - } else { - const [major = "", minor = "0", micro] = building.version.split(".").filter(v => v != ""); - if (micro) { - building.package_version = [major, minor, micro]; - } else { - building.package_version = [major, minor]; + // The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y) + // to the name of the enum (Button) to resolve references (Gtk.Button.Y) + Array.from(building.members.values()) + .filter((m): m is IntrospectedEnum => m instanceof IntrospectedEnum) + .forEach(m => { + m.members.forEach(member => { + building.enum_constants.set(member.c_identifier, [m.name, member.name] as const); + }); + }); + + // Get the requested classes + if (ns.class) { + ns.class + ?.filter(isIntrospectable) + .map(klass => IntrospectedClass.fromXML(modName, building, options, building, klass)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); } - } - } catch (error) { - console.error(`Failed to parse package version for ${building.name} with version ${building.version}`); - } - return building; - } + if (ns.record) { + ns.record + ?.filter(isIntrospectable) + .map(record => IntrospectedRecord.fromXML(modName, building, options, record)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.union) { + ns.union + ?.filter(isIntrospectable) + .map(union => IntrospectedRecord.fromXML(modName, building, options, union)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.interface) { + ns.interface + ?.map(inter => IntrospectedInterface.fromXML(modName, building, options, inter)) + .filter(importConflicts) + .forEach(c => building.members.set(c.name, c)); + } + + if (ns.alias) { + type NamedType = GirType & { $: { name: string } }; + + ns.alias + ?.filter(isIntrospectable) + // Avoid attempting to alias non-introspectable symbols. + .map(b => { + b.type = b.type + ?.filter((t): t is NamedType => !!(t && t.$.name)) + .map(t => { + if ( + t.$.name && + !building.hasSymbol(t.$.name) && + !isPrimitiveType(t.$.name) && + !t.$.name.includes(".") + ) { + return { $: { name: "unknown", "c:type": "unknown" } } as GirType; + } + + return t; + }); + + return b; + }) + .map(alias => IntrospectedAlias.fromXML(modName, building, options, null, alias)) + .filter((alias): alias is IntrospectedAlias => alias != null) + .forEach(c => building.members.set(c.name, c)); + } + + try { + let [major = null] = building.getMembers("MAJOR_VERSION"); + let [minor = null] = building.getMembers("MINOR_VERSION"); + let [micro = null] = building.getMembers("MICRO_VERSION"); + + if (!major) { + major = building.getMembers("VERSION_MAJOR")[0] ?? null; + } + + if (!minor) { + minor = building.getMembers("VERSION_MINOR")[0] ?? null; + } + + if (!micro) { + micro = building.getMembers("VERSION_MICRO")[0] ?? null; + } + + if ( + major instanceof IntrospectedConstant && + minor instanceof IntrospectedConstant && + major.value && + minor.value + ) { + if (micro instanceof IntrospectedConstant && micro.value) { + building.package_version = [major.value, minor.value, micro.value] as const; + } else { + building.package_version = [major.value, minor.value] as const; + } + } else { + const [major = "", minor = "0", micro] = building.version.split(".").filter(v => v != ""); + + if (micro) { + building.package_version = [major, minor, micro]; + } else { + building.package_version = [major, minor]; + } + } + } catch (error) { + console.error(`Failed to parse package version for ${building.name} with version ${building.version}`); + } + + return building; + } } diff --git a/packages/lib/src/newlib/gir/nodes.ts b/packages/lib/src/newlib/gir/nodes.ts index 053fb4a1f..aeebaa06d 100644 --- a/packages/lib/src/newlib/gir/nodes.ts +++ b/packages/lib/src/newlib/gir/nodes.ts @@ -1,16 +1,22 @@ export { IntrospectedAlias as GirAlias } from "./alias.js"; -export { IntrospectedClass as GirClass, GirInterface, GirRecord, GirComplexRecord, IntrospectedBaseClass as GirBaseClass } from "./class.js"; +export { + IntrospectedClass as GirClass, + IntrospectedInterface as GirInterface, + IntrospectedRecord as GirRecord, + GirComplexRecord, + IntrospectedBaseClass as GirBaseClass +} from "./class.js"; export { IntrospectedConstant as GirConst } from "./const.js"; export { IntrospectedEnum as GirEnum, IntrospectedError as GirError, GirEnumMember } from "./enum.js"; export { - IntrospectedFunction as GirFunction, - IntrospectedClassFunction as GirClassFunction, - IntrospectedCallback as GirCallback, - IntrospectedConstructor as GirConstructor, - IntrospectedStaticClassFunction as GirStaticClassFunction, - IntrospectedVirtualClassFunction as GirVirtualClassFunction, - IntrospectedFunctionParameter as GirFunctionParameter, - IntrospectedDirectAllocationConstructor as GirDirectAllocationConstructor, + IntrospectedFunction as GirFunction, + IntrospectedClassFunction as GirClassFunction, + IntrospectedCallback as GirCallback, + IntrospectedConstructor as GirConstructor, + IntrospectedStaticClassFunction as GirStaticClassFunction, + IntrospectedVirtualClassFunction as GirVirtualClassFunction, + IntrospectedFunctionParameter as GirFunctionParameter, + IntrospectedDirectAllocationConstructor as GirDirectAllocationConstructor } from "./function.js"; export { IntrospectedNamespace as GirNamespace, GirNSMember } from "./namespace.js"; export { NSRegistry as GirNSRegistry, NSLoader as GirNSLoader } from "./registry.js"; diff --git a/packages/lib/src/newlib/gir/property.ts b/packages/lib/src/newlib/gir/property.ts index 2df885eb9..be9909c9a 100644 --- a/packages/lib/src/newlib/gir/property.ts +++ b/packages/lib/src/newlib/gir/property.ts @@ -1,5 +1,5 @@ import { TypeExpression } from "../gir.js"; -import {IntrospectedBase, Options} from './base.js'; +import { IntrospectedBase, Options } from "./base.js"; import { GirFieldElement, GirPropertyElement } from "../../index.js"; import { getType, parseDoc, parseMetadata } from "./util.js"; @@ -11,194 +11,195 @@ import { IntrospectedBaseClass } from "./class.js"; import { IntrospectedEnum } from "./enum.js"; export class Field extends IntrospectedBase { - type: TypeExpression; - - // TODO: Make these properties readonly - optional: boolean = false; - computed: boolean; - isStatic: boolean; - writable: boolean; - isNative: boolean = false; - - copy(options?: { parent?: IntrospectedBase; type?: TypeExpression; isStatic?: boolean }): Field { - const { type, name, optional, computed, isStatic, writable } = this; - - return new Field({ - name, - type: options?.type ?? type, - optional, - computed, - isStatic: options?.isStatic ?? isStatic, - writable - })._copyBaseProperties(this); - } - - constructor({ - name, - type, - computed = false, - optional = false, - isStatic = false, - writable = true, - ...args - }: Options<{ - name: string; type: TypeExpression; - computed?: boolean; - optional?: boolean; - isStatic?: boolean; - writable?: boolean; - }>) { - super(name, { ...args }); - - this.type = type; - this.computed = computed; - this.optional = optional; - this.isStatic = isStatic; - this.writable = writable; - } - - asString>(generator: T): ReturnType { - return generator.generateField(this); - } - - accept(visitor: GirVisitor): Field { - const node = this.copy({ - type: visitor.visitType?.(this.type) ?? this.type - }); - - return visitor.visitField?.(node) ?? node; - } - - static fromXML( - namespace: string, - ns: IntrospectedNamespace, - _options: LoadOptions, - _parent, - field: GirFieldElement - ): Field { - let name = field.$["name"]; - let _name = name.replace(/[-]/g, "_"); - const f = new Field({ - name: _name, - type: getType(namespace, ns, field), - isPrivate: field.$.private === "1", - isIntrospectable: isIntrospectable(field) - }); - - return f; - } + + // TODO: Make these properties readonly + optional: boolean = false; + computed: boolean; + isStatic: boolean; + writable: boolean; + isNative: boolean = false; + + copy(options?: { parent?: IntrospectedBase; type?: TypeExpression; isStatic?: boolean }): Field { + const { type, name, optional, computed, isStatic, writable } = this; + + return new Field({ + name, + type: options?.type ?? type, + optional, + computed, + isStatic: options?.isStatic ?? isStatic, + writable + })._copyBaseProperties(this); + } + + constructor({ + name, + type, + computed = false, + optional = false, + isStatic = false, + writable = true, + ...args + }: Options<{ + name: string; + type: TypeExpression; + computed?: boolean; + optional?: boolean; + isStatic?: boolean; + writable?: boolean; + }>) { + super(name, { ...args }); + + this.type = type; + this.computed = computed; + this.optional = optional; + this.isStatic = isStatic; + this.writable = writable; + } + + asString>(generator: T): ReturnType { + return generator.generateField(this) as ReturnType; + } + + accept(visitor: GirVisitor): Field { + const node = this.copy({ + type: visitor.visitType?.(this.type) ?? this.type + }); + + return visitor.visitField?.(node) ?? node; + } + + static fromXML( + namespace: string, + ns: IntrospectedNamespace, + _options: LoadOptions, + _parent, + field: GirFieldElement + ): Field { + const name = field.$["name"]; + const _name = name.replace(/[-]/g, "_"); + const f = new Field({ + name: _name, + type: getType(namespace, ns, field), + isPrivate: field.$.private === "1", + isIntrospectable: isIntrospectable(field) + }); + + return f; + } } export class JSField extends Field { - isNative = true; + isNative = true; } export class GirProperty extends IntrospectedBase { - type: TypeExpression; - - readonly writable: boolean = false; - readonly readable: boolean = true; - readonly constructOnly: boolean; - - parent: IntrospectedBaseClass | IntrospectedEnum; - - copy(options?: { name?: string; parent?: IntrospectedBaseClass | IntrospectedEnum; type?: TypeExpression }): GirProperty { - const { name, writable, readable, type, constructOnly, parent } = this; - - return new GirProperty({ - name: options?.name ?? name, - writable, - readable, - type: options?.type ?? type, - constructOnly, - parent: options?.parent ?? parent - })._copyBaseProperties(this); - } - - accept(visitor: GirVisitor): GirProperty { - const node = this.copy({ - parent: this.parent, - type: visitor.visitType?.(this.type) ?? this.type - }); - - return visitor.visitProperty?.(node) ?? node; - } - - constructor({ - name, - type, - writable, - readable, - constructOnly, - parent, - ...args - }: Options<{ - name: string; type: TypeExpression; - writable: boolean; - readable: boolean; - constructOnly: boolean; + + readonly writable: boolean = false; + readonly readable: boolean = true; + readonly constructOnly: boolean; + parent: IntrospectedBaseClass | IntrospectedEnum; - }>) { - super(name, { ...args }); - - this.type = type; - this.writable = writable; - this.readable = readable; - this.constructOnly = constructOnly; - this.parent = parent; - } - - asString>( - generator: T, - construct?: boolean - ): ReturnType { - return generator.generateProperty(this, construct); - } - - toCamelCase() { - const [part, ...parts] = this.name.split("_"); - - if (parts.length === 0) { - return this.copy({ - name: part, - parent: this.parent - }); + + copy(options?: { + name?: string; + parent?: IntrospectedBaseClass | IntrospectedEnum; + type?: TypeExpression; + }): GirProperty { + const { name, writable, readable, type, constructOnly, parent } = this; + + return new GirProperty({ + name: options?.name ?? name, + writable, + readable, + type: options?.type ?? type, + constructOnly, + parent: options?.parent ?? parent + })._copyBaseProperties(this); + } + + accept(visitor: GirVisitor): GirProperty { + const node = this.copy({ + parent: this.parent, + type: visitor.visitType?.(this.type) ?? this.type + }); + + return visitor.visitProperty?.(node) ?? node; + } + + constructor({ + name, + type, + writable, + readable, + constructOnly, + parent, + ...args + }: Options<{ + name: string; + type: TypeExpression; + writable: boolean; + readable: boolean; + constructOnly: boolean; + parent: IntrospectedBaseClass | IntrospectedEnum; + }>) { + super(name, { ...args }); + + this.type = type; + this.writable = writable; + this.readable = readable; + this.constructOnly = constructOnly; + this.parent = parent; } - const camelCase = `${part}${parts.map(s => `${s[0].toUpperCase()}${s.slice(1)}`).join("")}`; - - return this.copy({ - name: camelCase, - parent: this.parent - }); - } - - static fromXML( - namespace: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedBaseClass | IntrospectedEnum, - prop: GirPropertyElement - ): GirProperty { - let name = prop.$["name"]; - let _name = name.replace(/[-]/g, "_"); - const property = new GirProperty({ - name: _name, - writable: prop.$?.writable === "1", - readable: prop.$?.readable !== "0", - constructOnly: prop.$?.["construct-only"] === "1", - type: getType(namespace, ns, prop), - parent, - isIntrospectable: isIntrospectable(prop), - }); - - if (options.loadDocs) { - property.doc = parseDoc(prop); - property.metadata = parseMetadata(prop); + asString>(generator: T, construct?: boolean): ReturnType { + return generator.generateProperty(this, construct) as ReturnType; } - return property; - } + toCamelCase() { + const [part, ...parts] = this.name.split("_"); + + if (parts.length === 0) { + return this.copy({ + name: part, + parent: this.parent + }); + } + + const camelCase = `${part}${parts.map(s => `${s[0].toUpperCase()}${s.slice(1)}`).join("")}`; + + return this.copy({ + name: camelCase, + parent: this.parent + }); + } + + static fromXML( + namespace: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedBaseClass | IntrospectedEnum, + prop: GirPropertyElement + ): GirProperty { + const name = prop.$["name"]; + const _name = name.replace(/[-]/g, "_"); + const property = new GirProperty({ + name: _name, + writable: prop.$?.writable === "1", + readable: prop.$?.readable !== "0", + constructOnly: prop.$?.["construct-only"] === "1", + type: getType(namespace, ns, prop), + parent, + isIntrospectable: isIntrospectable(prop) + }); + + if (options.loadDocs) { + property.doc = parseDoc(prop); + property.metadata = parseMetadata(prop); + } + + return property; + } } diff --git a/packages/lib/src/newlib/gir/registry.ts b/packages/lib/src/newlib/gir/registry.ts index 3d6c89c1d..dec54b606 100644 --- a/packages/lib/src/newlib/gir/registry.ts +++ b/packages/lib/src/newlib/gir/registry.ts @@ -1,4 +1,3 @@ -import { GirXML } from "@gi.ts/parser"; import { DefaultFormatter } from "../formatters/default.js"; import { Formatter } from "../formatters/formatter.js"; import { JSONFormatter } from "../formatters/json.js"; @@ -15,268 +14,277 @@ import { GirVisitor } from "../visitor.js"; import { IntrospectedNamespace } from "./namespace.js"; import { DtsModuleGenerator } from "../generators/dts-modules.js"; import { DtsInlineGenerator } from "../generators/dts-inline.js"; +import { ParsedGir } from "../../types/parsed-gir.js"; export interface NSLoader { - load(namespace: string, version: string): GirXML | null; - loadAll(namespace: string): GirXML[]; + load(namespace: string, version: string): ParsedGir | null; + loadAll(namespace: string): ParsedGir[]; } type GeneratorConstructor = { - new (namespace: IntrospectedNamespace, options: GenerationOptions, ...args: any[]): FormatGenerator; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + new (namespace: IntrospectedNamespace, options: GenerationOptions, ...args: any[]): FormatGenerator; }; export class NSRegistry { - mapping: TwoKeyMap = new TwoKeyMap(); - private formatters: Map = new Map(); - private generators: Map> = new Map(); - c_mapping: Map = new Map(); - transformations: GirVisitor[] = []; - loaders: [NSLoader, LoadOptions][] = []; - subtypes = new TwoKeyMap>(); - - constructor() { - this.formatters.set("json", new JSONFormatter()); - } - - registerTransformation(visitor: GirVisitor) { - this.transformations.push(visitor); - - // Apply transformations to already built namespaces. - this.mapping.forEach(n => { - n.accept(visitor); - }); - } - - registerFormatter(output: string, formatter: Formatter) { - this.formatters.set(output, formatter); - } - - getFormatter(output: string) { - return this.formatters.get(output) ?? new DefaultFormatter(); - } - - registerGenerator( - output: string, - generator: { new (namespace: IntrospectedNamespace, options: GenerationOptions): FormatGenerator } - ) { - this.generators.set(output, generator); - } - - getGenerator(output: "json"): { new (namespace: IntrospectedNamespace, options: GenerationOptions): JsonGenerator }; - getGenerator(output: "dts"): { new (namespace: IntrospectedNamespace, options: GenerationOptions): DtsGenerator }; - getGenerator(output: string): GeneratorConstructor | undefined; - getGenerator(output: string): GeneratorConstructor | undefined { - if (output === "dts") { - return DtsModuleGenerator; + mapping: TwoKeyMap = new TwoKeyMap(); + private formatters: Map = new Map(); + private generators: Map> = new Map(); + c_mapping: Map = new Map(); + transformations: GirVisitor[] = []; + loaders: [NSLoader, LoadOptions][] = []; + subtypes = new TwoKeyMap>(); + + constructor() { + this.formatters.set("json", new JSONFormatter()); } - if (output === 'dts-inline') { - return DtsInlineGenerator; + registerTransformation(visitor: GirVisitor) { + this.transformations.push(visitor); + + // Apply transformations to already built namespaces. + this.mapping.forEach(n => { + n.accept(visitor); + }); } - if (output === "json") { - return JsonGenerator; + registerFormatter(output: string, formatter: Formatter) { + this.formatters.set(output, formatter); } - // Handle loading external generators... - if (!this.generators.has(output)) { - (() => { - let Generator = require(`@gi.ts/generator-${output}`); + getFormatter(output: string) { + return this.formatters.get(output) ?? new DefaultFormatter(); + } - if (Generator) { - console.log(`Loading generator "@gi.ts/generator-${output}"...`); - this.generators.set(output, Generator); - return; - } + registerGenerator( + output: string, + generator: { new (namespace: IntrospectedNamespace, options: GenerationOptions): FormatGenerator } + ) { + this.generators.set(output, generator); + } - Generator = require(`gi-ts-generator-${output}`); + async getGenerator( + output: "json" + ): Promise<{ new (namespace: IntrospectedNamespace, options: GenerationOptions): JsonGenerator }>; + async getGenerator( + output: "dts" + ): Promise<{ new (namespace: IntrospectedNamespace, options: GenerationOptions): DtsGenerator }>; + async getGenerator(output: string): Promise | undefined>; + async getGenerator(output: string): Promise | undefined> { + if (output === "dts") { + return DtsModuleGenerator; + } - if (Generator) { - console.log(`Loading generator "gi-ts-generator-${output}"...`); - this.generators.set(output, Generator); - return; + if (output === "dts-inline") { + return DtsInlineGenerator; } - Generator = require(`${output}`); + if (output === "json") { + return JsonGenerator; + } - if (Generator) { - console.log(`Loading generator "${output}"...`); - this.generators.set(output, Generator); - return; + // Handle loading external generators... + if (!this.generators.has(output)) { + let Generator: { default: GeneratorConstructor }; + try { + Generator = (await import(`@gi.ts/generator-${output}`)) as { default: GeneratorConstructor }; + + if (Generator) { + console.log(`Loading generator "@gi.ts/generator-${output}"...`); + this.generators.set(output, Generator.default); + return; + } + } catch { + try { + Generator = (await import(`gi-ts-generator-${output}`)) as { + default: GeneratorConstructor; + }; + + console.log(`Loading generator "gi-ts-generator-${output}"...`); + this.generators.set(output, Generator.default); + return; + } catch { + try { + Generator = (await import(`${output}`)) as { default: GeneratorConstructor }; + + console.log(`Loading generator "${output}"...`); + this.generators.set(output, Generator.default); + return; + } catch {} + } + } } - })(); + + return this.generators.get(output); } - return this.generators.get(output); - } + private _transformNamespace(namespace: IntrospectedNamespace) { + this.transformations.forEach(t => { + namespace.accept(t); + }); + } - private _transformNamespace(namespace: IntrospectedNamespace) { - this.transformations.forEach(t => { - namespace.accept(t); - }); - } + namespace(name: string, version: string): IntrospectedNamespace | null { + const namespace = this.mapping.get(name, version); - namespace(name: string, version: string): IntrospectedNamespace | null { - const namespace = this.mapping.get(name, version); + if (!namespace) { + return this._internalLoad(name, version); + } - if (!namespace) { - return this._internalLoad(name, version); + return namespace; } - return namespace; - } + namespacesForPrefix(c_prefix: string): IntrospectedNamespace[] { + return this.c_mapping.get(c_prefix) ?? []; + } - namespacesForPrefix(c_prefix): IntrospectedNamespace[] { - return this.c_mapping.get(c_prefix) ?? []; - } + transform(options: TransformOptions) { + const GLib = this.assertNamespace("GLib", "2.0"); + const Gio = this.assertNamespace("Gio", "2.0"); + const GObject = this.assertNamespace("GObject", "2.0"); - transform(options: TransformOptions) { - const GLib = this.assertNamespace("GLib", "2.0"); - const Gio = this.assertNamespace("Gio", "2.0"); - const GObject = this.assertNamespace("GObject", "2.0"); + // These follow the GLib version. + Gio.package_version = [...GLib.package_version]; + GObject.package_version = [...GLib.package_version]; - // These follow the GLib version. - Gio.package_version = [...GLib.package_version]; - GObject.package_version = [...GLib.package_version]; + const interfaceVisitor = new InterfaceVisitor(); - const interfaceVisitor = new InterfaceVisitor(); + this.registerTransformation(interfaceVisitor); - this.registerTransformation(interfaceVisitor); + const classVisitor = new ClassVisitor(); - const classVisitor = new ClassVisitor(); + this.registerTransformation(classVisitor); - this.registerTransformation(classVisitor); + console.log("Adding generics..."); + generify(this, options.inferGenerics); - console.log("Adding generics..."); - generify(this, options.inferGenerics); + console.log("Injecting types..."); + inject(this); + } - console.log("Injecting types..."); - inject(this); - } + defaultVersionOf(name: string): string | null { + // GJS has a hard dependency on these versions. + if (name === "GLib" || name === "Gio" || name === "GObject") { + return "2.0"; + } - defaultVersionOf(name: string): string | null { - // GJS has a hard dependency on these versions. - if (name === "GLib" || name === "Gio" || name === "GObject") { - return "2.0"; - } + const meta = this.mapping.getIfOnly(name); - const meta = this.mapping.getIfOnly(name); + if (meta) { + return meta[0]; + } - if (meta) { - return meta[0]; - } + const ns = this._defaultVersionInternalLoad(name); - let ns = this._defaultVersionInternalLoad(name); + if (ns) { + return ns.version; + } - if (ns) { - return ns.version; + return null; } - return null; - } + assertDefaultVersionOf(name: string): string { + const version = this.defaultVersionOf(name); - assertDefaultVersionOf(name: string): string { - const version = this.defaultVersionOf(name); + if (version) { + return version; + } - if (version) { - return version; + // This mirrors GJS' and GI's default behavior. + // If we can't find a single version of an unspecified dependency, we throw an error. + throw new Error(`No single version found for unspecified dependency: ${name}.`); } - // This mirrors GJS' and GI's default behavior. - // If we can't find a single version of an unspecified dependency, we throw an error. - throw new Error(`No single version found for unspecified dependency: ${name}.`); - } + assertNamespace(name: string, version: string): IntrospectedNamespace { + let namespace = this.mapping.get(name, version) ?? null; - assertNamespace(name: string, version: string): IntrospectedNamespace { - let namespace = this.mapping.get(name, version) ?? null; + if (!namespace) { + namespace = this._internalLoad(name, version); + } - if (!namespace) { - namespace = this._internalLoad(name, version); - } + if (!namespace) { + throw new Error(`Namespace '${name}' not found.`); + } - if (!namespace) { - throw new Error(`Namespace '${name}' not found.`); + return namespace; } - return namespace; - } + load(gir: ParsedGir, options: LoadOptions): IntrospectedNamespace { + const namespace = IntrospectedNamespace.fromXML(gir, options, this); - load(gir: GirXML, options: LoadOptions): IntrospectedNamespace { - const namespace = IntrospectedNamespace.fromXML(gir, options, this); + this.mapping.set(namespace.name, namespace.version, namespace); - this.mapping.set(namespace.name, namespace.version, namespace); + namespace.c_prefixes.forEach(c_prefix => { + const c_map = this.c_mapping.get(c_prefix) || []; - namespace.c_prefixes.forEach(c_prefix => { - let c_map = this.c_mapping.get(c_prefix) || []; + c_map.push(namespace); - c_map.push(namespace); + this.c_mapping.set(c_prefix, c_map); + }); - this.c_mapping.set(c_prefix, c_map); - }); + this._transformNamespace(namespace); - this._transformNamespace(namespace); - - return namespace; - } + return namespace; + } - private _defaultVersionInternalLoad(name: string): IntrospectedNamespace | null { - const all = this.loaders - .map(([loader, options]) => { - try { - return [loader.loadAll(name), options] as const; - } catch (error) { - // TODO: Should we throw here? - console.error(error); - return null; + private _defaultVersionInternalLoad(name: string): IntrospectedNamespace | null { + const all = this.loaders + .map(([loader, options]) => { + try { + return [loader.loadAll(name), options] as const; + } catch (error) { + // TODO: Should we throw here? + console.error(error); + return null; + } + }) + .filter((a): a is [ParsedGir[], LoadOptions] => a != null); + + if (all.length === 0 || all.length > 1) { + return null; } - }) - .filter((a): a is [GirXML[], LoadOptions] => a != null); - if (all.length === 0 || all.length > 1) { - return null; - } + const [[xmls, options]] = all; - const [[xmls, options]] = all; + if (xmls.length === 0 || xmls.length > 1) { + return null; + } - if (xmls.length === 0 || xmls.length > 1) { - return null; - } + const [xml] = xmls; - const [xml] = xmls; + const ns = this.load(xml, options); - const ns = this.load(xml, options); + if (ns) { + this._transformNamespace(ns); + } - if (ns) { - this._transformNamespace(ns); + return ns; } - return ns; - } - - private _internalLoad(name: string, version: string): IntrospectedNamespace | null { - for (const [loader, options] of this.loaders) { - try { - const xml = loader.load(name, version); + private _internalLoad(name: string, version: string): IntrospectedNamespace | null { + for (const [loader, options] of this.loaders) { + try { + const xml = loader.load(name, version); - if (xml) { - const ns = this.load(xml, options); + if (xml) { + const ns = this.load(xml, options); - if (ns) { - this._transformNamespace(ns); - } + if (ns) { + this._transformNamespace(ns); + } - return ns; + return ns; + } + } catch (error) { + // TODO: Should we throw here? + console.error(error); + } } - } catch (error) { - // TODO: Should we throw here? - console.error(error); - } - } - return null; - } + return null; + } - registerLoader(loader: NSLoader, options: LoadOptions) { - this.loaders.push([loader, options]); - } + registerLoader(loader: NSLoader, options: LoadOptions) { + this.loaders.push([loader, options]); + } } diff --git a/packages/lib/src/newlib/gir/signal.ts b/packages/lib/src/newlib/gir/signal.ts index ea2bb7345..089e4708e 100644 --- a/packages/lib/src/newlib/gir/signal.ts +++ b/packages/lib/src/newlib/gir/signal.ts @@ -1,235 +1,235 @@ import { - VoidType, - UnknownType, - NativeType, - TypeExpression, - ThisType, - NumberType, - NullableType, - ArrayType + VoidType, + UnknownType, + NativeType, + TypeExpression, + ThisType, + NumberType, + NullableType, + ArrayType } from "../gir.js"; -import {IntrospectedBase, Options} from './base.js'; +import { IntrospectedBase, Options } from "./base.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { IntrospectedClass } from "./class.js"; import { IntrospectedClassFunction, IntrospectedFunctionParameter, IntrospectedCallback } from "./function.js"; -import { GirSignalElement, GirDirection, GirCallableParamElement } from "@gi.ts/parser"; +import { GirSignalElement, GirDirection, GirCallableParamElement } from "@gi.ts/parser"; import { getType, parseDoc, parseMetadata } from "./util.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; export enum IntrospectedSignalType { - CONNECT, - CONNECT_AFTER, - EMIT + CONNECT, + CONNECT_AFTER, + EMIT } export class IntrospectedSignal extends IntrospectedBase { - parameters: IntrospectedFunctionParameter[]; - return_type: TypeExpression; - parent: IntrospectedClass; - - constructor({ - name, - parameters = [], - return_type = UnknownType, - parent, - ...args - }: Options<{ - name: string; - parameters?: IntrospectedFunctionParameter[]; - return_type?: TypeExpression; + parameters: IntrospectedFunctionParameter[]; + return_type: TypeExpression; parent: IntrospectedClass; - }>) { - super(name, { ...args }); - - this.parameters = parameters.map(p => p.copy({ parent: this })); - this.return_type = return_type; - this.parent = parent; - } - - accept(visitor: GirVisitor): IntrospectedSignal { - const node = this.copy({ - parameters: this.parameters.map(p => { - return p.accept(visitor); - }), - returnType: visitor.visitType?.(this.return_type) - }); - - return visitor.visitSignal?.(node) ?? node; - } - - copy({ - parent = this.parent, - parameters, - returnType - }: { - parent?: IntrospectedClass; - parameters?: IntrospectedFunctionParameter[]; - returnType?: TypeExpression; - } = {}): IntrospectedSignal { - return new IntrospectedSignal({ - name: this.name, - parent, - parameters: parameters ?? this.parameters, - return_type: returnType ?? this.return_type - })._copyBaseProperties(this); - } - - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedClass, - sig: GirSignalElement - ): IntrospectedSignal { - const signal = new IntrospectedSignal({ - name: sig.$.name, - parent, - isIntrospectable: isIntrospectable(sig) - }); - - if (sig.parameters && sig.parameters[0].parameter) { - signal.parameters.push( - ...sig.parameters[0].parameter - .filter((p): p is GirCallableParamElement & { $: { name: string } } => !!p.$.name) - .map(p => IntrospectedFunctionParameter.fromXML(modName, ns, options, signal, p)) - ); + + constructor({ + name, + parameters = [], + return_type = UnknownType, + parent, + ...args + }: Options<{ + name: string; + parameters?: IntrospectedFunctionParameter[]; + return_type?: TypeExpression; + parent: IntrospectedClass; + }>) { + super(name, { ...args }); + + this.parameters = parameters.map(p => p.copy({ parent: this })); + this.return_type = return_type; + this.parent = parent; } - const length_params = [] as number[]; + accept(visitor: GirVisitor): IntrospectedSignal { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); - signal.parameters = signal.parameters - .map(p => { - const unwrapped_type = p.type.unwrap(); + return visitor.visitSignal?.(node) ?? node; + } - if (unwrapped_type instanceof ArrayType && unwrapped_type.length != null) { - length_params.push(unwrapped_type.length); + copy({ + parent = this.parent, + parameters, + returnType + }: { + parent?: IntrospectedClass; + parameters?: IntrospectedFunctionParameter[]; + returnType?: TypeExpression; + } = {}): IntrospectedSignal { + return new IntrospectedSignal({ + name: this.name, + parent, + parameters: parameters ?? this.parameters, + return_type: returnType ?? this.return_type + })._copyBaseProperties(this); + } - return p; + static fromXML( + modName: string, + ns: IntrospectedNamespace, + options: LoadOptions, + parent: IntrospectedClass, + sig: GirSignalElement + ): IntrospectedSignal { + const signal = new IntrospectedSignal({ + name: sig.$.name, + parent, + isIntrospectable: isIntrospectable(sig) + }); + + if (sig.parameters && sig.parameters[0].parameter) { + signal.parameters.push( + ...sig.parameters[0].parameter + .filter((p): p is GirCallableParamElement & { $: { name: string } } => !!p.$.name) + .map(p => IntrospectedFunctionParameter.fromXML(modName, ns, options, signal, p)) + ); } - return p; - }) - .filter((_, i) => { - // We remove any length parameters. - return !length_params.includes(i); - }) - - .reverse() - .reduce( - ({ allowOptions, params }, p) => { - const { type, isOptional } = p; - - if (allowOptions) { - if (type instanceof NullableType) { - params.push(p.copy({ isOptional: true })); - } else if (!isOptional) { - params.push(p); - return { allowOptions: false, params }; - } else { - params.push(p); - } - } else { - if (isOptional) { - params.push(p.copy({ type: new NullableType(type), isOptional: false })); - } else { - params.push(p); - } - } - - return { allowOptions, params }; - }, - { - allowOptions: true, - params: [] as IntrospectedFunctionParameter[] + const length_params = [] as number[]; + + signal.parameters = signal.parameters + .map(p => { + const unwrapped_type = p.type.unwrap(); + + if (unwrapped_type instanceof ArrayType && unwrapped_type.length != null) { + length_params.push(unwrapped_type.length); + + return p; + } + + return p; + }) + .filter((_, i) => { + // We remove any length parameters. + return !length_params.includes(i); + }) + + .reverse() + .reduce( + ({ allowOptions, params }, p) => { + const { type, isOptional } = p; + + if (allowOptions) { + if (type instanceof NullableType) { + params.push(p.copy({ isOptional: true })); + } else if (!isOptional) { + params.push(p); + return { allowOptions: false, params }; + } else { + params.push(p); + } + } else { + if (isOptional) { + params.push(p.copy({ type: new NullableType(type), isOptional: false })); + } else { + params.push(p); + } + } + + return { allowOptions, params }; + }, + { + allowOptions: true, + params: [] as IntrospectedFunctionParameter[] + } + ) + .params.reverse() + .filter((p): p is IntrospectedFunctionParameter => p != null); + + signal.return_type = getType(modName, ns, sig["return-value"]?.[0]); + + if (options.loadDocs) { + signal.doc = parseDoc(sig); + signal.metadata = parseMetadata(sig); } - ) - .params.reverse() - .filter((p): p is IntrospectedFunctionParameter => p != null); - signal.return_type = getType(modName, ns, sig["return-value"]?.[0]); + return signal; + } + + asEmit() { + const emit = this.copy(); + + const parent = this.parent; - if (options.loadDocs) { - signal.doc = parseDoc(sig); - signal.metadata = parseMetadata(sig); + const prefix_signal = emit.parameters.some(p => { + return p.name === "signal"; + }); + + const parameters = [ + new IntrospectedFunctionParameter({ + name: prefix_signal ? "$signal" : "signal", + type: NativeType.of(`'${this.name}'`), + direction: GirDirection.In + }), + ...emit.parameters + ]; + + const return_type = VoidType; + + return new IntrospectedClassFunction({ + return_type, + parameters, + name: "emit", + parent + }); } - return signal; - } - - asEmit() { - const emit = this.copy(); - - const parent = this.parent; - - const prefix_signal = emit.parameters.some(p => { - return p.name === "signal"; - }); - - const parameters = [ - new IntrospectedFunctionParameter({ - name: prefix_signal ? "$signal" : "signal", - type: NativeType.of(`'${this.name}'`), - direction: GirDirection.In - }), - ...emit.parameters - ]; - - const return_type = VoidType; - - return new IntrospectedClassFunction({ - return_type, - parameters, - name: "emit", - parent - }); - } - - asConnect(after = false) { - const connect = this.copy(); - - const name = after ? "connect_after" : "connect"; - - const parent = this.parent; - const cb = new IntrospectedCallback({ - raw_name: "callback", - name: "callback", - output_parameters: [], - parameters: [ - new IntrospectedFunctionParameter({ name: "_source", type: ThisType, direction: GirDirection.In }), - ...connect.parameters.map(p => p.copy()) - ], - return_type: connect.return_type - }); - - const parameters = [ - new IntrospectedFunctionParameter({ - name: "signal", - type: NativeType.of(`'${this.name}'`), - direction: GirDirection.In - }), - new IntrospectedFunctionParameter({ - name: "callback", - type: cb.asFunctionType(), - direction: GirDirection.In - }) - ]; - - const return_type = NumberType; - - return new IntrospectedClassFunction({ - return_type, - parameters, - name, - parent - }); - } - - asString>( - generator: T, - type?: IntrospectedSignalType - ): ReturnType { - return generator.generateSignal(this, type); - } + asConnect(after = false) { + const connect = this.copy(); + + const name = after ? "connect_after" : "connect"; + + const parent = this.parent; + const cb = new IntrospectedCallback({ + raw_name: "callback", + name: "callback", + output_parameters: [], + parameters: [ + new IntrospectedFunctionParameter({ name: "_source", type: ThisType, direction: GirDirection.In }), + ...connect.parameters.map(p => p.copy()) + ], + return_type: connect.return_type + }); + + const parameters = [ + new IntrospectedFunctionParameter({ + name: "signal", + type: NativeType.of(`'${this.name}'`), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "callback", + type: cb.asFunctionType(), + direction: GirDirection.In + }) + ]; + + const return_type = NumberType; + + return new IntrospectedClassFunction({ + return_type, + parameters, + name, + parent + }); + } + + asString>( + generator: T, + type?: IntrospectedSignalType + ): ReturnType { + return generator.generateSignal(this, type) as ReturnType; + } } diff --git a/packages/lib/src/newlib/gir/util.ts b/packages/lib/src/newlib/gir/util.ts index e4970381b..996ed5851 100644 --- a/packages/lib/src/newlib/gir/util.ts +++ b/packages/lib/src/newlib/gir/util.ts @@ -1,123 +1,122 @@ import { deprecatedVersion, IntrospectedNamespace, introducedVersion, isDeprecated } from "./namespace.js"; import { - GirCallableParamElement, - GirDirection, - GirAliasElement, - GirDocElement, - GirInfoAttrs, - GirType, - GirConstantElement, - GirCallableReturn, - GirFieldElement + GirCallableParamElement, + GirDirection, + GirAliasElement, + GirDocElement, + GirInfoAttrs, + GirType, + GirConstantElement, + GirCallableReturn, + GirFieldElement } from "@gi.ts/parser"; import { - TypeIdentifier, - ThisType, - ArrayType, - ClosureType, - GTypeType, - BinaryType, - ObjectType, - NullableType, - TypeExpression, - StringType, - NumberType, - BooleanType, - Uint8ArrayType, - AnyType, - UnknownType, - NeverType, - VoidType, - GenerifiedTypeIdentifier, - GenericType, - - NativeType + TypeIdentifier, + ThisType, + ArrayType, + ClosureType, + GTypeType, + BinaryType, + ObjectType, + NullableType, + TypeExpression, + StringType, + NumberType, + BooleanType, + Uint8ArrayType, + AnyType, + UnknownType, + NeverType, + VoidType, + GenerifiedTypeIdentifier, + GenericType, + NativeType } from "../gir.js"; -import {IntrospectedBase, Options, Metadata} from './base.js'; +import { Metadata } from "./base.js"; import { IntrospectedBaseClass } from "./class.js"; import { TwoKeyMap } from "../util.js"; const reservedWords = [ - // For now, at least, the typescript compiler doesn't throw on numerical types like int, float, etc. - "abstract", - "arguments", - "await", - "boolean", - "break", - "byte", - "case", - "catch", - "char", - "class", - "const", - "continue", - "constructor", // This isn't technically reserved, but it's problematic. - "debugger", - "default", - "delete", - "do", - // "double", - "else", - "enum", - "eval", - "export", - "extends", - "false", - "final", - "finally", - // "float", - "for", - "function", - "goto", - "if", - "implements", - "import", - "in", - "instanceof", - // "int", - "interface", - "let", - // "long", - "native", - "new", - "null", - "package", - "private", - "protected", - "public", - "return", - "short", - "static", - "super", - "switch", - "synchronized", - "this", - "throw", - "throws", - "transient", - "true", - "try", - "typeof", - "var", - "void", - "volatile", - "while", - "with", - "yield" + // For now, at least, the typescript compiler doesn't throw on numerical types like int, float, etc. + "abstract", + "arguments", + "await", + "boolean", + "break", + "byte", + "case", + "catch", + "char", + "class", + "const", + "continue", + "constructor", // This isn't technically reserved, but it's problematic. + "debugger", + "default", + "delete", + "do", + // "double", + "else", + "enum", + "eval", + "export", + "extends", + "false", + "final", + "finally", + // "float", + "for", + "function", + "goto", + "if", + "implements", + "import", + "in", + "instanceof", + // "int", + "interface", + "let", + // "long", + "native", + "new", + "null", + "package", + "private", + "protected", + "public", + "return", + "short", + "static", + "super", + "switch", + "synchronized", + "this", + "throw", + "throws", + "transient", + "true", + "try", + "typeof", + "var", + "void", + "volatile", + "while", + "with", + "yield" ]; export function getAliasType(modName: string, _ns: IntrospectedNamespace, parameter: GirAliasElement): TypeExpression { - let name = parameter.type?.[0].$["name"] || "unknown"; + let name = parameter.type?.[0].$["name"] || "unknown"; - let nameParts = name.split(" "); + const nameParts = name.split(" "); - if (nameParts.length === 1) { - name = nameParts[0]; - } else { - name = nameParts[1]; - } + if (nameParts.length === 1) { + name = nameParts[0]; + } else { + name = nameParts[1]; + } - return parseTypeExpression(modName, name); + return parseTypeExpression(modName, name); } /** @@ -126,427 +125,427 @@ export function getAliasType(modName: string, _ns: IntrospectedNamespace, parame * Any type where the c:type ends with * */ function isPointerType(types: GirType[] | undefined) { - const type = types?.[0]; - if (!type) return false; + const type = types?.[0]; + if (!type) return false; - const ctype = type.$["c:type"]; - if (!ctype) return false; + const ctype = type.$["c:type"]; + if (!ctype) return false; - const typeName = type.$.name; - if (!typeName) return false; + const typeName = type.$.name; + if (!typeName) return false; - if (isPrimitiveType(typeName)) return false; + if (isPrimitiveType(typeName)) return false; - return ctype.endsWith("*"); + return ctype.endsWith("*"); } /* Decode the type */ export function getType( - modName: string, - _ns: IntrospectedNamespace, - param?: GirConstantElement | GirCallableReturn | GirFieldElement + modName: string, + _ns: IntrospectedNamespace, + param?: GirConstantElement | GirCallableReturn | GirFieldElement ): TypeExpression { - if (!param) return VoidType; - - let name = ""; - let arrayDepth: number | null = null; - let length: number | null = null; - let isPointer = false; - - let parameter = param as GirCallableParamElement; - if (parameter.array && parameter.array[0]) { - arrayDepth = 1; - - const [array] = parameter.array; + if (!param) return VoidType; - if (array.$ && array.$.length != null) { - length = Number.parseInt(array.$.length, 10); + let name = ""; + let arrayDepth: number | null = null; + let length: number | null = null; + let isPointer = false; - if (Number.isNaN(length)) { - throw new Error(`Error parsing array length: ${array.$.length}`); - } - } + const parameter = param as GirCallableParamElement; + if (parameter.array && parameter.array[0]) { + arrayDepth = 1; - if (array.type && array.type[0].$ && array.type[0].$["name"]) { - name = array.type[0].$["name"]; - } else if (array.array) { - let arr = array; - let depth = 1; - - while (Array.isArray(arr.array)) { - arr = arr.array[0]; - depth++; - } - - let possibleName = arr.type?.[0].$["name"]; - if (possibleName) { - name = possibleName; - } else { + const [array] = parameter.array; + + if (array.$ && array.$.length != null) { + length = Number.parseInt(array.$.length, 10); + + if (Number.isNaN(length)) { + throw new Error(`Error parsing array length: ${array.$.length}`); + } + } + + if (array.type && array.type[0].$ && array.type[0].$["name"]) { + name = array.type[0].$["name"]; + } else if (array.array) { + let arr = array; + let depth = 1; + + while (Array.isArray(arr.array)) { + arr = arr.array[0]; + depth++; + } + + const possibleName = arr.type?.[0].$["name"]; + if (possibleName) { + name = possibleName; + } else { + name = "unknown"; + console.log( + `Failed to find array type in ${modName}: `, + JSON.stringify(parameter.$, null, 4), + "\nMarking as unknown!" + ); + } + arrayDepth = depth; + isPointer = isPointerType(array.type); + } else { + name = "unknown"; + } + } else if (parameter.type && parameter.type[0] && parameter.type[0].$) { + const possibleName = parameter.type[0].$["name"]; + if (possibleName) { + name = possibleName; + } else { + name = "unknown"; + console.log( + `Failed to find type in ${modName}: `, + JSON.stringify(parameter.$, null, 4), + "\nMarking as unknown!" + ); + } + isPointer = isPointerType(parameter.type); + } else if (parameter.varargs || (parameter.$ && parameter.$.name === "...")) { + arrayDepth = 1; + name = "any"; + } else { name = "unknown"; console.log( - `Failed to find array type in ${modName}: `, - JSON.stringify(parameter.$, null, 4), - "\nMarking as unknown!" + `Unknown varargs type in ${modName}: `, + JSON.stringify(parameter.$, null, 4), + "\nMarking as unknown!" ); - } - arrayDepth = depth; - isPointer = isPointerType(array.type); - } else { - name = "unknown"; } - } else if (parameter.type && parameter.type[0] && parameter.type[0].$) { - let possibleName = parameter.type[0].$["name"]; - if (possibleName) { - name = possibleName; - } else { - name = "unknown"; - console.log( - `Failed to find type in ${modName}: `, - JSON.stringify(parameter.$, null, 4), - "\nMarking as unknown!" - ); - } - isPointer = isPointerType(parameter.type); - } else if (parameter.varargs || (parameter.$ && parameter.$.name === "...")) { - arrayDepth = 1; - name = "any"; - } else { - name = "unknown"; - console.log( - `Unknown varargs type in ${modName}: `, - JSON.stringify(parameter.$, null, 4), - "\nMarking as unknown!" - ); - } - - let closure = null as null | number; - - if (parameter.$ && parameter.$.closure) { - closure = Number.parseInt(parameter.$.closure, 10); - - if (Number.isNaN(closure)) { - throw new Error(`Error parsing closure data position: ${parameter.$.closure}`); + + let closure = null as null | number; + + if (parameter.$ && parameter.$.closure) { + closure = Number.parseInt(parameter.$.closure, 10); + + if (Number.isNaN(closure)) { + throw new Error(`Error parsing closure data position: ${parameter.$.closure}`); + } } - } - const nullable = parameter.$ && parameter.$["nullable"] === "1"; - const allowNone = parameter.$ && parameter.$["allow-none"] === "1"; + const nullable = parameter.$ && parameter.$["nullable"] === "1"; + const allowNone = parameter.$ && parameter.$["allow-none"] === "1"; - let x = name.split(" "); - if (x.length === 1) { - name = x[0]; - } else { - name = x[1]; - } + const x = name.split(" "); + if (x.length === 1) { + name = x[0]; + } else { + name = x[1]; + } - const baseType = parseTypeString(name); + const baseType = parseTypeString(name); - if (!baseType) { - throw new Error(`Un-parsable type: ${name}`); - } + if (!baseType) { + throw new Error(`Un-parsable type: ${name}`); + } - let variableType: TypeExpression = parseTypeExpression(modName, name); + let variableType: TypeExpression = parseTypeExpression(modName, name); - if (variableType instanceof TypeIdentifier) { - if (variableType.is("GLib", "List") || variableType.is("GLib", "SList")) { - const listType = parameter?.type?.[0].type?.[0]?.$.name; + if (variableType instanceof TypeIdentifier) { + if (variableType.is("GLib", "List") || variableType.is("GLib", "SList")) { + const listType = parameter?.type?.[0].type?.[0]?.$.name; - if (listType) { - name = listType; - variableType = parseTypeExpression(modName, name); + if (listType) { + name = listType; + variableType = parseTypeExpression(modName, name); - arrayDepth = 1; - } - } else if (variableType.is("GLib", "HashTable")) { - const keyType = parameter?.type?.[0]?.type?.[0]?.$.name; - const valueType = parameter?.type?.[0]?.type?.[1]?.$.name; + arrayDepth = 1; + } + } else if (variableType.is("GLib", "HashTable")) { + const keyType = parameter?.type?.[0]?.type?.[0]?.$.name; + const valueType = parameter?.type?.[0]?.type?.[1]?.$.name; - if (keyType && valueType) { - const key = parseTypeExpression(modName, keyType); - const value = parseTypeExpression(modName, valueType); + if (keyType && valueType) { + const key = parseTypeExpression(modName, keyType); + const value = parseTypeExpression(modName, valueType); - variableType = new GenerifiedTypeIdentifier("HashTable", "GLib", [key, value]); - } + variableType = new GenerifiedTypeIdentifier("HashTable", "GLib", [key, value]); + } + } } - } - if (arrayDepth != null) { - const primitiveArrayType = resolvePrimitiveArrayType(name, arrayDepth); + if (arrayDepth != null) { + const primitiveArrayType = resolvePrimitiveArrayType(name, arrayDepth); + + if (primitiveArrayType) { + const [primitiveName, primitiveArrayDepth] = primitiveArrayType; + + variableType = ArrayType.new({ + type: primitiveName, + arrayDepth: primitiveArrayDepth, + length + }); + } else { + variableType = ArrayType.new({ type: variableType, arrayDepth, length }); + } + } else if (closure != null) { + variableType = ClosureType.new({ type: variableType, user_data: closure }); + } - if (primitiveArrayType) { - const [primitiveName, primitiveArrayDepth] = primitiveArrayType; + if ( + parameter.$ && + (parameter.$.direction === GirDirection.Inout || parameter.$.direction === GirDirection.Out) && + (nullable || allowNone) && + !(variableType instanceof NativeType) + ) { + return new NullableType(variableType); + } - variableType = ArrayType.new({ - type: primitiveName, - arrayDepth: primitiveArrayDepth, - length - }); - } else { - variableType = ArrayType.new({ type: variableType, arrayDepth, length }); + if ((!parameter.$?.direction || parameter.$.direction === GirDirection.In) && nullable) { + return new NullableType(variableType); } - } else if (closure != null) { - variableType = ClosureType.new({ type: variableType, user_data: closure }); - } - - if ( - parameter.$ && - (parameter.$.direction === "inout" || parameter.$.direction === "out") && - (nullable || allowNone) && - !(variableType instanceof NativeType) - ) { - return new NullableType(variableType); - } - - if ((!parameter.$?.direction || parameter.$.direction === "in") && nullable) { - return new NullableType(variableType); - } - - variableType.isPointer = isPointer; - - return variableType; + + variableType.isPointer = isPointer; + + return variableType; } export const SanitizedIdentifiers = new Map(); export function sanitizeIdentifierName(namespace: string | null, name: string): string { - // This is a unique case where the name is "empty". - if (name === "") { - return `''`; - } + // This is a unique case where the name is "empty". + if (name === "") { + return "''"; + } - let sanitized_name = name.replace(/[^A-z0-9_]/gi, "_"); + let sanitized_name = name.replace(/[^A-z0-9_]/gi, "_"); - if (reservedWords.includes(sanitized_name)) { - sanitized_name = `__${sanitized_name}`; - } + if (reservedWords.includes(sanitized_name)) { + sanitized_name = `__${sanitized_name}`; + } - if (sanitized_name.match(/^[^A-z_]/) != null) { - sanitized_name = `__${sanitized_name}`; - } + if (sanitized_name.match(/^[^A-z_]/) != null) { + sanitized_name = `__${sanitized_name}`; + } - if (namespace && sanitized_name !== name) { - SanitizedIdentifiers.set(`${namespace}.${name}`, `${namespace}.${sanitized_name}`); - } + if (namespace && sanitized_name !== name) { + SanitizedIdentifiers.set(`${namespace}.${name}`, `${namespace}.${sanitized_name}`); + } - return sanitized_name; + return sanitized_name; } export function sanitizeMemberName(name: string): string { - // This is a unique case where the name is "empty". - if (name === "") { - return `''`; - } + // This is a unique case where the name is "empty". + if (name === "") { + return "''"; + } - return name.replace(/[^A-z0-9_]/gi, "_"); + return name.replace(/[^A-z0-9_]/gi, "_"); } export function isInvalid(name: string): boolean { - if (reservedWords.includes(name)) { - return true; - } + if (reservedWords.includes(name)) { + return true; + } - const sanitized = sanitizeMemberName(name); + const sanitized = sanitizeMemberName(name); - if (sanitized.match(/^[^A-z_]/) != null) { - return true; - } + if (sanitized.match(/^[^A-z_]/) != null) { + return true; + } - return false; + return false; } export function parseDoc(element: GirDocElement): string | null { - return element.doc?.[0]?._ ?? null; + return element.doc?.[0]?._ ?? null; } export function parseDeprecatedDoc(element: GirDocElement): string | null { - return element["doc-deprecated"]?.[0]?._ ?? null; + return element["doc-deprecated"]?.[0]?._ ?? null; } export function parseMetadata(element: { $: GirInfoAttrs } & GirDocElement): Metadata | undefined { - const version = introducedVersion(element); - const deprecatedIn = deprecatedVersion(element); - const deprecated = isDeprecated(element); - const doc = parseDeprecatedDoc(element); - - if (!version && !deprecated && !deprecatedIn && !doc) { - return undefined; - } - - return { - ...(deprecated ? { deprecated } : {}), - ...(doc ? { deprecatedDoc: doc } : {}), - ...(deprecatedIn ? { deprecatedVersion: deprecatedIn } : {}), - ...(version ? { introducedVersion: version } : {}) - }; + const version = introducedVersion(element); + const deprecatedIn = deprecatedVersion(element); + const deprecated = isDeprecated(element); + const doc = parseDeprecatedDoc(element); + + if (!version && !deprecated && !deprecatedIn && !doc) { + return undefined; + } + + return { + ...(deprecated ? { deprecated } : {}), + ...(doc ? { deprecatedDoc: doc } : {}), + ...(deprecatedIn ? { deprecatedVersion: deprecatedIn } : {}), + ...(version ? { introducedVersion: version } : {}) + }; } export function parseTypeString(type: string): { namespace: string | null; name: string } { - if (type.includes(".")) { - const parts = type.split("."); + if (type.includes(".")) { + const parts = type.split("."); - if (parts.length > 2) { - throw new Error(`Invalid type string ${type} passed.`); - } + if (parts.length > 2) { + throw new Error(`Invalid type string ${type} passed.`); + } - const [namespace, name] = parts; + const [namespace, name] = parts; - return { name, namespace }; - } else { - return { name: type, namespace: null }; - } + return { name, namespace }; + } else { + return { name: type, namespace: null }; + } } export function parseTypeIdentifier(modName: string, type: string): TypeIdentifier { - const baseType = parseTypeString(type); + const baseType = parseTypeString(type); - if (baseType.namespace) { - return new TypeIdentifier(baseType.name, baseType.namespace); - } else { - return new TypeIdentifier(baseType.name, modName); - } + if (baseType.namespace) { + return new TypeIdentifier(baseType.name, baseType.namespace); + } else { + return new TypeIdentifier(baseType.name, modName); + } } export function parseTypeExpression(modName: string, type: string): TypeExpression { - const baseType = parseTypeString(type); + const baseType = parseTypeString(type); - if (baseType.namespace) { - return new TypeIdentifier(baseType.name, baseType.namespace); - } else { - const primitiveType = resolvePrimitiveType(baseType.name); - - if (primitiveType !== null) { - return primitiveType; + if (baseType.namespace) { + return new TypeIdentifier(baseType.name, baseType.namespace); } else { - return new TypeIdentifier(baseType.name, modName); + const primitiveType = resolvePrimitiveType(baseType.name); + + if (primitiveType !== null) { + return primitiveType; + } else { + return new TypeIdentifier(baseType.name, modName); + } } - } } export function resolvePrimitiveArrayType(name: string, arrayDepth: number): [TypeExpression, number] | null { - if (arrayDepth > 0) { - switch (name) { - case "gint8": - case "guint8": - return [Uint8ArrayType, arrayDepth - 1]; + if (arrayDepth > 0) { + switch (name) { + case "gint8": + case "guint8": + return [Uint8ArrayType, arrayDepth - 1]; + } } - } - const resolvedName = resolvePrimitiveType(name); + const resolvedName = resolvePrimitiveType(name); - if (resolvedName) { - return [resolvedName, arrayDepth]; - } else { - return null; - } + if (resolvedName) { + return [resolvedName, arrayDepth]; + } else { + return null; + } } export function isPrimitiveType(name: string): boolean { - return resolvePrimitiveType(name) !== null; + return resolvePrimitiveType(name) !== null; } export function resolvePrimitiveType(name: string): TypeExpression | null { - switch (name) { - case "": - console.error("Resolving '' to any on " + name); - return AnyType; - case "filename": - return StringType; - // Pass this through - case "GType": - return GTypeType; - case "utf8": - return StringType; - case "void": // Support TS "void" - case "none": - return VoidType; - // TODO Some libraries are bad and don't use g-prefixed numerical types - case "uint32": - case "int32": - case "double": - // Most libraries will use these though: - case "gshort": - case "guint32": - case "guint16": - case "gint16": - case "gunichar": - case "gint8": - case "gint32": - case "gushort": - case "gfloat": - case "gchar": - case "guint": - case "glong": - case "gulong": - case "gint": - case "guint8": - case "guint64": - case "gint64": - case "gdouble": - case "gssize": - case "gsize": - case "long": - return NumberType; - case "gboolean": - return BooleanType; - case "gpointer": // This is typically used in callbacks to pass data, so we'll allow anything. - return AnyType; - case "object": - return ObjectType; - case "va_list": - return AnyType; - case "guintptr": // You can't use pointers in GJS! (at least that I'm aware of) - return NeverType; - case "never": // Support TS "never" - return NeverType; - case "unknown": // Support TS "unknown" - return UnknownType; - case "any": // Support TS "any" - return AnyType; - case "this": // Support TS "this" - return ThisType; - case "number": // Support TS "number" - return NumberType; - case "string": // Support TS "string" - return StringType; - case "boolean": // Support TS "boolean" - return BooleanType; - case "object": // Support TS "object" - return ObjectType; - } - - return null; + switch (name) { + case "": + console.error("Resolving '' to any on " + name); + return AnyType; + case "filename": + return StringType; + // Pass this through + case "GType": + return GTypeType; + case "utf8": + return StringType; + case "void": // Support TS "void" + case "none": + return VoidType; + // TODO Some libraries are bad and don't use g-prefixed numerical types + case "uint32": + case "int32": + case "double": + // Most libraries will use these though: + case "gshort": + case "guint32": + case "guint16": + case "gint16": + case "gunichar": + case "gint8": + case "gint32": + case "gushort": + case "gfloat": + case "gchar": + case "guint": + case "glong": + case "gulong": + case "gint": + case "guint8": + case "guint64": + case "gint64": + case "gdouble": + case "gssize": + case "gsize": + case "long": + return NumberType; + case "gboolean": + return BooleanType; + case "gpointer": // This is typically used in callbacks to pass data, so we'll allow anything. + return AnyType; + case "object": + return ObjectType; + case "va_list": + return AnyType; + case "guintptr": // You can't use pointers in GJS! (at least that I'm aware of) + return NeverType; + case "never": // Support TS "never" + return NeverType; + case "unknown": // Support TS "unknown" + return UnknownType; + case "any": // Support TS "any" + return AnyType; + case "this": // Support TS "this" + return ThisType; + case "number": // Support TS "number" + return NumberType; + case "string": // Support TS "string" + return StringType; + case "boolean": // Support TS "boolean" + return BooleanType; + case "object": // Support TS "object" + return ObjectType; + } + + return null; } export function resolveDirectedType(type: TypeExpression, direction: GirDirection): TypeExpression | null { - if (type instanceof ArrayType) { - if ( - (direction === GirDirection.In || direction === GirDirection.Inout) && - type.type.equals(Uint8ArrayType) && - type.arrayDepth === 0 - ) { - return new BinaryType(type, StringType); - } - } else if (type instanceof TypeIdentifier) { - if ((direction === GirDirection.In || direction === GirDirection.Inout) && type.is("GLib", "Bytes")) { - return new BinaryType(type, Uint8ArrayType); - } else if (type.is("GObject", "Value")) { - if (direction === GirDirection.In || direction === GirDirection.Inout) { - return new BinaryType(type, AnyType); - } else { - // GJS converts GObject.Value out parameters to their unboxed type, which we don't know, - // so type as `unknown` - return UnknownType; - } - } else if (type.is("GLib", "HashTable")) { - if (direction === GirDirection.In) { - return new BinaryType(new NativeType("{ [key: string]: any }"), type); - } else { - return type; - } + if (type instanceof ArrayType) { + if ( + (direction === GirDirection.In || direction === GirDirection.Inout) && + type.type.equals(Uint8ArrayType) && + type.arrayDepth === 0 + ) { + return new BinaryType(type, StringType); + } + } else if (type instanceof TypeIdentifier) { + if ((direction === GirDirection.In || direction === GirDirection.Inout) && type.is("GLib", "Bytes")) { + return new BinaryType(type, Uint8ArrayType); + } else if (type.is("GObject", "Value")) { + if (direction === GirDirection.In || direction === GirDirection.Inout) { + return new BinaryType(type, AnyType); + } else { + // GJS converts GObject.Value out parameters to their unboxed type, which we don't know, + // so type as `unknown` + return UnknownType; + } + } else if (type.is("GLib", "HashTable")) { + if (direction === GirDirection.In) { + return new BinaryType(new NativeType("{ [key: string]: any }"), type); + } else { + return type; + } + } } - } - return null; + return null; } /** @@ -558,18 +557,21 @@ export function resolveDirectedType(type: TypeExpression, direction: GirDirectio * @param namespace * @param type */ -export function resolveTypeIdentifier(namespace: IntrospectedNamespace, type: TypeIdentifier): IntrospectedBaseClass | null { - const ns = type.namespace; - const name = type.name; - - const resolved_ns = namespace.assertInstalledImport(ns); - - const pclass = resolved_ns.getClass(name); - if (pclass) { - return pclass; - } else { - return null; - } +export function resolveTypeIdentifier( + namespace: IntrospectedNamespace, + type: TypeIdentifier +): IntrospectedBaseClass | null { + const ns = type.namespace; + const name = type.name; + + const resolved_ns = namespace.assertInstalledImport(ns); + + const pclass = resolved_ns.getClass(name); + if (pclass) { + return pclass; + } else { + return null; + } } /** @@ -578,7 +580,7 @@ export function resolveTypeIdentifier(namespace: IntrospectedNamespace, type: Ty * @param b */ function isTypeConflict(a: TypeExpression, b: TypeExpression) { - return !a.equals(b) || !b.equals(a); + return !a.equals(b) || !b.equals(a); } /** @@ -593,65 +595,67 @@ function isTypeConflict(a: TypeExpression, b: TypeExpression) { * @param parentType */ export function isSubtypeOf( - namespace: IntrospectedNamespace, - thisType: TypeIdentifier, - parentThisType: TypeIdentifier, - potentialSubtype: TypeExpression, - parentType: TypeExpression + namespace: IntrospectedNamespace, + thisType: TypeIdentifier, + parentThisType: TypeIdentifier, + potentialSubtype: TypeExpression, + parentType: TypeExpression ) { - if (!isTypeConflict(potentialSubtype, parentType)) { - return true; - } - - const unwrappedSubtype = potentialSubtype.unwrap(); - let unwrappedParent = parentType.unwrap(); - - if ( - (potentialSubtype.equals(ThisType) && unwrappedParent.equals(thisType)) || - (parentType.equals(ThisType) && unwrappedSubtype.equals(parentThisType)) - ) { - return true; - } - - if (unwrappedParent instanceof GenericType && unwrappedParent.identifier !== "T") { - // Technically there could be a conflicting generic, but most generic types should specify a replacement for type checking. - // "T" denotes a local function generic in the current implementation, those can't be ignored. - if (!unwrappedParent.replacedType) { - return true; + if (!isTypeConflict(potentialSubtype, parentType)) { + return true; } - // Use the generic replaced type as a stand-in. - unwrappedParent = unwrappedParent.replacedType; - } + const unwrappedSubtype = potentialSubtype.unwrap(); + let unwrappedParent = parentType.unwrap(); - if (!(unwrappedSubtype instanceof TypeIdentifier) || !(unwrappedParent instanceof TypeIdentifier)) { - return false; - } + if ( + (potentialSubtype.equals(ThisType) && unwrappedParent.equals(thisType)) || + (parentType.equals(ThisType) && unwrappedSubtype.equals(parentThisType)) + ) { + return true; + } - const resolutions = - namespace.parent.subtypes.get(unwrappedSubtype.name, unwrappedSubtype.namespace) ?? - new TwoKeyMap(); - const resolution = resolutions.get(unwrappedParent.name, unwrappedParent.namespace); + if (unwrappedParent instanceof GenericType && unwrappedParent.identifier !== "T") { + // Technically there could be a conflicting generic, but most generic types should specify a replacement for type checking. + // "T" denotes a local function generic in the current implementation, those can't be ignored. + if (!unwrappedParent.replacedType) { + return true; + } - if (typeof resolution === "boolean") { - return resolution; - } + // Use the generic replaced type as a stand-in. + unwrappedParent = unwrappedParent.replacedType; + } - const resolved = resolveTypeIdentifier(namespace, unwrappedSubtype); + if (!(unwrappedSubtype instanceof TypeIdentifier) || !(unwrappedParent instanceof TypeIdentifier)) { + return false; + } - if (!resolved) { - return false; - } - let x = resolved.resolveParents(); + const resolutions = + namespace.parent.subtypes.get(unwrappedSubtype.name, unwrappedSubtype.namespace) ?? + new TwoKeyMap(); + const resolution = resolutions.get(unwrappedParent.name, unwrappedParent.namespace); + + if (typeof resolution === "boolean") { + return resolution; + } + + const resolved = resolveTypeIdentifier(namespace, unwrappedSubtype); + + if (!resolved) { + return false; + } + const parentResolution = resolved.resolveParents(); - // This checks that the two types have the same form, regardless of identifier (e.g. A | null and B | null) - const isStructurallySubtype = potentialSubtype.rewrap(AnyType).equals(parentType.rewrap(AnyType)); + // This checks that the two types have the same form, regardless of identifier (e.g. A | null and B | null) + const isStructurallySubtype = potentialSubtype.rewrap(AnyType).equals(parentType.rewrap(AnyType)); - const isSubtype = isStructurallySubtype && x.node.someParent(t => t.getType().equals(unwrappedParent)); + const isSubtype = + isStructurallySubtype && + parentResolution.node.someParent((t: IntrospectedBaseClass) => t.getType().equals(unwrappedParent)); - resolutions.set(unwrappedParent.name, unwrappedParent.namespace, isSubtype); + resolutions.set(unwrappedParent.name, unwrappedParent.namespace, isSubtype); - namespace.parent.subtypes.set(unwrappedSubtype.name, unwrappedSubtype.namespace, resolutions); + namespace.parent.subtypes.set(unwrappedSubtype.name, unwrappedSubtype.namespace, resolutions); - return isSubtype; + return isSubtype; } diff --git a/packages/lib/src/newlib/injections/gio.ts b/packages/lib/src/newlib/injections/gio.ts index 63fa98905..72363c0fb 100644 --- a/packages/lib/src/newlib/injections/gio.ts +++ b/packages/lib/src/newlib/injections/gio.ts @@ -1,438 +1,440 @@ import { IntrospectedNamespace } from "../gir/namespace.js"; import { - IntrospectedClassFunction, - IntrospectedConstructor, - IntrospectedFunction, - IntrospectedFunctionParameter, - IntrospectedStaticClassFunction + IntrospectedClassFunction, + IntrospectedConstructor, + IntrospectedFunction, + IntrospectedFunctionParameter, + IntrospectedStaticClassFunction } from "../gir/function.js"; import { - StringType, - NativeType, - FunctionType, - GenerifiedType, - GenericType, - AnyFunctionType, - ArrayType, - AnyType, - VoidType, - GenerifiedTypeIdentifier, - Generic + StringType, + NativeType, + FunctionType, + GenerifiedType, + GenericType, + AnyFunctionType, + ArrayType, + AnyType, + VoidType, + GenerifiedTypeIdentifier, + Generic } from "../gir.js"; -import { Direction } from "@gi.ts/parser"; +import { GirDirection } from "@gi.ts/parser"; import { Field, JSField } from "../gir/property.js"; -import { IntrospectedClass, GirInterface } from "../gir/class.js"; +import { IntrospectedClass, IntrospectedInterface } from "../gir/class.js"; export default { - namespace: "Gio", - version: "2.0", - modifier(namespace: IntrospectedNamespace) { - // For IterableIterator... - namespace.___dts___addReference(`/// `); - - { - const DBusNodeInfo = namespace.assertClass("DBusNodeInfo"); - - DBusNodeInfo.constructors.push( - new IntrospectedConstructor({ - name: "new_for_xml", - parameters: [ - new IntrospectedFunctionParameter({ - name: "info", - type: StringType, - direction: Direction.In - }) - ], - return_type: DBusNodeInfo.getType() - }) - ); - } - - { - const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); - - DBusInterfaceInfo.constructors.push( - new IntrospectedConstructor({ - name: "new_for_xml", - parameters: [ - new IntrospectedFunctionParameter({ - name: "info", - type: StringType, - direction: Direction.In - }) - ], - return_type: DBusInterfaceInfo.getType() - }) - ); - } - - { - const ListStore = namespace.assertClass("ListStore"); - - ListStore.fields.push( - new Field({ - name: "Symbol.iterator", - computed: true, - type: new FunctionType( - {}, - new GenerifiedType(new NativeType("IterableIterator"), new GenericType("A")) - ) - }) - ); - } - - { - const SettingsSchema = namespace.assertClass("SettingsSchema"); - - SettingsSchema.fields.push( - new JSField({ - name: "_realGetKey", - type: new NativeType("typeof SettingsSchema.prototype.get_key") - }) - ); - } + namespace: "Gio", + version: "2.0", + modifier(namespace: IntrospectedNamespace) { + // For IterableIterator... + namespace.___dts___addReference('/// '); + + { + const DBusNodeInfo = namespace.assertClass("DBusNodeInfo"); + + DBusNodeInfo.constructors.push( + new IntrospectedConstructor({ + name: "new_for_xml", + parameters: [ + new IntrospectedFunctionParameter({ + name: "info", + type: StringType, + direction: GirDirection.In + }) + ], + return_type: DBusNodeInfo.getType() + }) + ); + } + + { + const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); + + DBusInterfaceInfo.constructors.push( + new IntrospectedConstructor({ + name: "new_for_xml", + parameters: [ + new IntrospectedFunctionParameter({ + name: "info", + type: StringType, + direction: GirDirection.In + }) + ], + return_type: DBusInterfaceInfo.getType() + }) + ); + } + + { + const ListStore = namespace.assertClass("ListStore"); + + ListStore.fields.push( + new Field({ + name: "Symbol.iterator", + computed: true, + type: new FunctionType( + {}, + new GenerifiedType(new NativeType("IterableIterator"), new GenericType("A")) + ) + }) + ); + } + + { + const SettingsSchema = namespace.assertClass("SettingsSchema"); + + SettingsSchema.fields.push( + new JSField({ + name: "_realGetKey", + type: new NativeType("typeof SettingsSchema.prototype.get_key") + }) + ); + } + + { + const Settings = namespace.assertClass("Settings"); + + Settings.fields.push( + new JSField({ + name: "_realInit", + type: AnyFunctionType + }), + new JSField({ + name: "_realMethods", + type: new NativeType("typeof Settings.prototype") + }), + new JSField({ + name: "_keys", + type: new ArrayType(StringType) + }), + new JSField({ + name: "_children", + type: new ArrayType(StringType) + }) + ); + } + { + const DBusProxy = namespace.assertClass("DBusProxy"); + + // This is not ideal, but DBusProxy's define functions and properties on the prototype. + DBusProxy.indexSignature = "[key: string]: any;"; + + DBusProxy.members.push( + new IntrospectedStaticClassFunction({ + name: "makeProxyWrapper", + parent: DBusProxy, + parameters: [ + new IntrospectedFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: GirDirection.In + }) + ], + return_type: AnyType + }), + new IntrospectedClassFunction({ + name: "connectSignal", + parent: DBusProxy, + parameters: [ + new IntrospectedFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: GirDirection.In + }) + ], + return_type: AnyType + }), + new IntrospectedClassFunction({ + name: "disconnectSignal", + parent: DBusProxy, + parameters: [ + new IntrospectedFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: GirDirection.In + }) + ], + return_type: AnyType + }) + ); + } + + { + const [bus_get] = namespace.getMembers("bus_get"); + const [bus_get_finish] = namespace.getMembers("bus_get_finish"); + const [bus_get_sync] = namespace.getMembers("bus_get_sync"); + const [bus_own_name] = namespace.getMembers("bus_own_name"); + const [bus_own_name_on_connection] = namespace.getMembers("bus_own_name_on_connection"); + const [bus_unown_name] = namespace.getMembers("bus_unown_name"); + const [bus_watch_name] = namespace.getMembers("bus_watch_name"); + const [bus_unwatch_name] = namespace.getMembers("bus_unwatch_name"); + const [bus_watch_name_on_connection] = namespace.getMembers("bus_watch_name_on_connection"); + + if ( + !( + bus_get instanceof IntrospectedFunction && + bus_get_finish instanceof IntrospectedFunction && + bus_get_sync instanceof IntrospectedFunction && + bus_own_name instanceof IntrospectedFunction && + bus_own_name_on_connection instanceof IntrospectedFunction && + bus_unown_name instanceof IntrospectedFunction && + bus_watch_name instanceof IntrospectedFunction && + bus_unwatch_name instanceof IntrospectedFunction && + bus_watch_name_on_connection instanceof IntrospectedFunction + ) + ) { + throw new Error("Invalid dbus functions found in Gio!"); + } + + const DBus = new IntrospectedInterface({ + name: "DBus", + namespace + }); - { - const Settings = namespace.assertClass("Settings"); - - Settings.fields.push( - new JSField({ - name: "_realInit", - type: AnyFunctionType - }), - new JSField({ - name: "_realMethods", - type: new NativeType("typeof Settings.prototype") - }), - new JSField({ - name: "_keys", - type: new ArrayType(StringType) - }), - new JSField({ - name: "_children", - type: new ArrayType(StringType) - }) - ); - } - { - const DBusProxy = namespace.assertClass("DBusProxy"); - - // This is not ideal, but DBusProxy's define functions and properties on the prototype. - DBusProxy.indexSignature = "[key: string]: any;"; - - DBusProxy.members.push( - new IntrospectedStaticClassFunction({ - name: "makeProxyWrapper", - parent: DBusProxy, - parameters: [ - new IntrospectedFunctionParameter({ - name: "args", - type: new ArrayType(AnyType), - isVarArgs: true, - direction: Direction.In - }) - ], - return_type: AnyType - }), - new IntrospectedClassFunction({ - name: "connectSignal", - parent: DBusProxy, - parameters: [ - new IntrospectedFunctionParameter({ - name: "args", - type: new ArrayType(AnyType), - isVarArgs: true, - direction: Direction.In - }) - ], - return_type: AnyType - }), - new IntrospectedClassFunction({ - name: "disconnectSignal", - parent: DBusProxy, - parameters: [ - new IntrospectedFunctionParameter({ - name: "args", - type: new ArrayType(AnyType), - isVarArgs: true, - direction: Direction.In - }) - ], - return_type: AnyType - }) - ); - } + DBus.members.push( + ...[ + bus_get, + bus_get_finish, + bus_get_sync, + bus_own_name, + bus_own_name_on_connection, + bus_unown_name, + bus_watch_name, + bus_unwatch_name, + bus_watch_name_on_connection + ] + .map(fn => fn.asStaticClassFunction(DBus)) + .map(fn => { + const member = fn.copy(); + + member.name = member.name.substring(4); + + return member; + }) + ); + + const DBusConnection = namespace.assertClass("DBusConnection"); + + const call = DBusConnection.members.find(m => m.name === "call"); + const callFinish = DBusConnection.members.find(m => m.name === "call_finish"); + + if (!call || !callFinish) { + throw new Error("Missing call or call_finish in Gio.DBusConnection."); + } + + // Add generic + const call_generic = new Generic(new GenericType("T"), AnyType, undefined, StringType); + call.generics.push(call_generic); + callFinish.generics.push(call_generic); + + const replacement = call.copy({ + parameters: call.parameters.map(p => { + if (p.name === "reply_type") { + // Generify the parameter + return p.copy({ + type: p.type.rewrap( + new GenerifiedTypeIdentifier("VariantType", "GLib", [new GenericType("T")]) + ) + }); + } + + return p; + }) + }); - { - const [bus_get] = namespace.getMembers("bus_get"); - const [bus_get_finish] = namespace.getMembers("bus_get_finish"); - const [bus_get_sync] = namespace.getMembers("bus_get_sync"); - const [bus_own_name] = namespace.getMembers("bus_own_name"); - const [bus_own_name_on_connection] = namespace.getMembers("bus_own_name_on_connection"); - const [bus_unown_name] = namespace.getMembers("bus_unown_name"); - const [bus_watch_name] = namespace.getMembers("bus_watch_name"); - const [bus_unwatch_name] = namespace.getMembers("bus_unwatch_name"); - const [bus_watch_name_on_connection] = namespace.getMembers("bus_watch_name_on_connection"); - - if ( - !( - bus_get instanceof IntrospectedFunction && - bus_get_finish instanceof IntrospectedFunction && - bus_get_sync instanceof IntrospectedFunction && - bus_own_name instanceof IntrospectedFunction && - bus_own_name_on_connection instanceof IntrospectedFunction && - bus_unown_name instanceof IntrospectedFunction && - bus_watch_name instanceof IntrospectedFunction && - bus_unwatch_name instanceof IntrospectedFunction && - bus_watch_name_on_connection instanceof IntrospectedFunction - ) - ) { - throw new Error(`Invalid dbus functions found in Gio!`); - } - - const DBus = new GirInterface({ - name: "DBus", - namespace - }); - - DBus.members.push( - ...[ - bus_get, - bus_get_finish, - bus_get_sync, - bus_own_name, - bus_own_name_on_connection, - bus_unown_name, - bus_watch_name, - bus_unwatch_name, - bus_watch_name_on_connection - ] - .map(fn => fn.asStaticClassFunction(DBus)) - .map(fn => { - const member = fn.copy(); - - member.name = member.name.substring(4); - - return member; - }) - ); - - const DBusConnection = namespace.assertClass("DBusConnection"); - - const call = DBusConnection.members.find(m => m.name === "call"); - const callFinish = DBusConnection.members.find(m => m.name === "call_finish"); - - if (!call || !callFinish) { - throw new Error(`Missing call or call_finish in Gio.DBusConnection.`); - } - - // Add generic - const call_generic = new Generic(new GenericType("T"), AnyType, undefined, StringType); - call.generics.push(call_generic); - callFinish.generics.push(call_generic); - - const replacement = call.copy({ - parameters: call.parameters.map(p => { - if (p.name === "reply_type") { - // Generify the parameter - return p.copy({ - type: p.type.rewrap(new GenerifiedTypeIdentifier("VariantType", "GLib", [new GenericType("T")])) + const finishReplacement = callFinish.copy({ + returnType: callFinish + .return() + .rewrap(new GenerifiedTypeIdentifier("Variant", "GLib", [new GenericType("T")])) }); - } - - return p; - }) - }); - - const finishReplacement = callFinish.copy({ - returnType: callFinish - .return() - .rewrap(new GenerifiedTypeIdentifier("Variant", "GLib", [new GenericType("T")])) - }); - - DBusConnection.members.splice(DBusConnection.members.indexOf(call), 1, replacement); - DBusConnection.members.splice(DBusConnection.members.indexOf(callFinish), 1, finishReplacement); - - DBusConnection.members.push( - new IntrospectedClassFunction({ - name: "watch_name", - parameters: bus_watch_name_on_connection.parameters.slice(1), - return_type: bus_watch_name_on_connection.return_type, - parent: DBusConnection - }), - new IntrospectedClassFunction({ - name: "unwatch_name", - parameters: bus_unwatch_name.parameters.slice(), - return_type: bus_unwatch_name.return_type, - parent: DBusConnection - }), - new IntrospectedClassFunction({ - name: "own_name", - parameters: bus_own_name_on_connection.parameters.slice(1), - return_type: bus_own_name_on_connection.return_type, - parent: DBusConnection - }), - new IntrospectedClassFunction({ - name: "unown_name", - parameters: bus_unown_name.parameters.slice(), - return_type: bus_unown_name.return_type, - parent: DBusConnection - }) - ); - - DBus.fields.push( - new JSField({ - isStatic: true, - name: "session", - type: DBusConnection.getType(), - writable: false - }), - new JSField({ - isStatic: true, - name: "system", - type: DBusConnection.getType(), - writable: false - }) - ); - - namespace.members.set("DBus", DBus); - } - // From GJS Documentation: - // - // `Gio.DBusExportedObject.wrapJSObject(Gio.DbusInterfaceInfo, jsObj)` - - // Takes `jsObj`, an object instance implementing the interface described by `Gio.DbusInterfaceInfo`, and returns an implementation object with these methods: - - // * `export(busConnection, objectPath)` - // * `unexport()` - // * `flush()` - // * `emit_signal(name, variant)` - // * `emit_property_changed(name, variant)` - - { - const Variant = namespace.assertInstalledImport("GLib").assertClass("Variant"); - const DBusConnection = namespace.assertClass("DBusConnection"); - const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); - const DBusExportedObject = new IntrospectedClass("DBusExportedObject", namespace); - - DBusExportedObject.members.push( - new IntrospectedStaticClassFunction({ - name: "wrapJSObject", - parent: DBusExportedObject, - parameters: [ - new IntrospectedFunctionParameter({ - name: "info", - type: StringType, - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "obj", - type: AnyType, - direction: Direction.In - }) - ], - return_type: DBusExportedObject.getType() - }), - new IntrospectedClassFunction({ - name: "get_info", - parent: DBusExportedObject, - parameters: [], - return_type: DBusInterfaceInfo.getType() - }), - new IntrospectedClassFunction({ - name: "get_connection", - parent: DBusExportedObject, - parameters: [], - return_type: DBusConnection.getType() - }), - new IntrospectedClassFunction({ - name: "get_object_path", - parent: DBusExportedObject, - parameters: [], - return_type: StringType - }), - new IntrospectedClassFunction({ - name: "unexport_from_connection", - parent: DBusExportedObject, - parameters: [ - new IntrospectedFunctionParameter({ - name: "connection", - type: DBusConnection.getType(), - direction: Direction.In - }) - ], - return_type: VoidType - }), - // export(busConnection, objectPath) - new IntrospectedClassFunction({ - name: "export", - parent: DBusExportedObject, - parameters: [ - new IntrospectedFunctionParameter({ - name: "busConnection", - type: DBusConnection.getType(), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "objectPath", - type: StringType, - direction: Direction.In - }) - ], - return_type: VoidType - }), - // unexport() - new IntrospectedClassFunction({ - name: "unexport", - parent: DBusExportedObject, - return_type: VoidType - }), - // flush() - new IntrospectedClassFunction({ - name: "flush", - parent: DBusExportedObject, - return_type: VoidType - }), - // emit_signal(name, variant) - new IntrospectedClassFunction({ - name: "emit_signal", - parent: DBusExportedObject, - parameters: [ - new IntrospectedFunctionParameter({ - name: "name", - type: StringType, - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "variant", - type: Variant.getType(), - direction: Direction.In - }) - ], - return_type: VoidType - }), - // emit_property_changed(name, variant) - new IntrospectedClassFunction({ - name: "emit_property_changed", - parent: DBusExportedObject, - parameters: [ - new IntrospectedFunctionParameter({ - name: "name", - type: StringType, - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "variant", - type: Variant.getType(), - direction: Direction.In - }) - ], - return_type: VoidType - }) - ); - - namespace.members.set("DBusExportedObject", DBusExportedObject); + DBusConnection.members.splice(DBusConnection.members.indexOf(call), 1, replacement); + DBusConnection.members.splice(DBusConnection.members.indexOf(callFinish), 1, finishReplacement); + + DBusConnection.members.push( + new IntrospectedClassFunction({ + name: "watch_name", + parameters: bus_watch_name_on_connection.parameters.slice(1), + return_type: bus_watch_name_on_connection.return_type, + parent: DBusConnection + }), + new IntrospectedClassFunction({ + name: "unwatch_name", + parameters: bus_unwatch_name.parameters.slice(), + return_type: bus_unwatch_name.return_type, + parent: DBusConnection + }), + new IntrospectedClassFunction({ + name: "own_name", + parameters: bus_own_name_on_connection.parameters.slice(1), + return_type: bus_own_name_on_connection.return_type, + parent: DBusConnection + }), + new IntrospectedClassFunction({ + name: "unown_name", + parameters: bus_unown_name.parameters.slice(), + return_type: bus_unown_name.return_type, + parent: DBusConnection + }) + ); + + DBus.fields.push( + new JSField({ + isStatic: true, + name: "session", + type: DBusConnection.getType(), + writable: false + }), + new JSField({ + isStatic: true, + name: "system", + type: DBusConnection.getType(), + writable: false + }) + ); + + namespace.members.set("DBus", DBus); + } + + // From GJS Documentation: + // + // `Gio.DBusExportedObject.wrapJSObject(Gio.DbusInterfaceInfo, jsObj)` + + // Takes `jsObj`, an object instance implementing the interface described by `Gio.DbusInterfaceInfo`, and returns an implementation object with these methods: + + // * `export(busConnection, objectPath)` + // * `unexport()` + // * `flush()` + // * `emit_signal(name, variant)` + // * `emit_property_changed(name, variant)` + + { + const Variant = namespace.assertInstalledImport("GLib").assertClass("Variant"); + const DBusConnection = namespace.assertClass("DBusConnection"); + const DBusInterfaceInfo = namespace.assertClass("DBusInterfaceInfo"); + const DBusExportedObject = new IntrospectedClass("DBusExportedObject", namespace); + + DBusExportedObject.members.push( + new IntrospectedStaticClassFunction({ + name: "wrapJSObject", + parent: DBusExportedObject, + parameters: [ + new IntrospectedFunctionParameter({ + name: "info", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "obj", + type: AnyType, + direction: GirDirection.In + }) + ], + return_type: DBusExportedObject.getType() + }), + new IntrospectedClassFunction({ + name: "get_info", + parent: DBusExportedObject, + parameters: [], + return_type: DBusInterfaceInfo.getType() + }), + new IntrospectedClassFunction({ + name: "get_connection", + parent: DBusExportedObject, + parameters: [], + return_type: DBusConnection.getType() + }), + new IntrospectedClassFunction({ + name: "get_object_path", + parent: DBusExportedObject, + parameters: [], + return_type: StringType + }), + new IntrospectedClassFunction({ + name: "unexport_from_connection", + parent: DBusExportedObject, + parameters: [ + new IntrospectedFunctionParameter({ + name: "connection", + type: DBusConnection.getType(), + direction: GirDirection.In + }) + ], + return_type: VoidType + }), + // export(busConnection, objectPath) + new IntrospectedClassFunction({ + name: "export", + parent: DBusExportedObject, + parameters: [ + new IntrospectedFunctionParameter({ + name: "busConnection", + type: DBusConnection.getType(), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "objectPath", + type: StringType, + direction: GirDirection.In + }) + ], + return_type: VoidType + }), + // unexport() + new IntrospectedClassFunction({ + name: "unexport", + parent: DBusExportedObject, + return_type: VoidType + }), + // flush() + new IntrospectedClassFunction({ + name: "flush", + parent: DBusExportedObject, + return_type: VoidType + }), + // emit_signal(name, variant) + new IntrospectedClassFunction({ + name: "emit_signal", + parent: DBusExportedObject, + parameters: [ + new IntrospectedFunctionParameter({ + name: "name", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "variant", + type: Variant.getType(), + direction: GirDirection.In + }) + ], + return_type: VoidType + }), + // emit_property_changed(name, variant) + new IntrospectedClassFunction({ + name: "emit_property_changed", + parent: DBusExportedObject, + parameters: [ + new IntrospectedFunctionParameter({ + name: "name", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "variant", + type: Variant.getType(), + direction: GirDirection.In + }) + ], + return_type: VoidType + }) + ); + + namespace.members.set("DBusExportedObject", DBusExportedObject); + } } - } }; diff --git a/packages/lib/src/newlib/injections/glib.ts b/packages/lib/src/newlib/injections/glib.ts index 67f04ac44..71da10eed 100644 --- a/packages/lib/src/newlib/injections/glib.ts +++ b/packages/lib/src/newlib/injections/glib.ts @@ -1,238 +1,237 @@ import { IntrospectedNamespace } from "../gir/namespace.js"; import { - IntrospectedConstructor, - IntrospectedFunctionParameter, - IntrospectedClassFunction, - IntrospectedFunction, - IntrospectedDirectAllocationConstructor + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedClassFunction, + IntrospectedFunction, + IntrospectedDirectAllocationConstructor } from "../gir/function.js"; import { - NativeType, - AnyType, - BooleanType, - Uint8ArrayType, - StringType, - UnknownType, - GenericType, - TypeIdentifier, - BinaryType + NativeType, + AnyType, + BooleanType, + Uint8ArrayType, + StringType, + UnknownType, + GenericType, + TypeIdentifier, + BinaryType } from "../gir.js"; -import { Direction } from "@gi.ts/parser"; -import { NSRegistry } from "../gir/registry.js"; -import { GirRecord } from "../gir/class.js"; +import { GirDirection } from "@gi.ts/parser"; +import { IntrospectedRecord } from "../gir/class.js"; export default { - namespace: "GLib", - version: "2.0", - modifier(namespace: IntrospectedNamespace, registry: NSRegistry) { - // export function log_structured(logDomain, logLevel, stringFields); - - namespace.members.set( - "log_structured", - new IntrospectedFunction({ - name: "log_structured", - raw_name: "log_structured", - parameters: [ - new IntrospectedFunctionParameter({ - name: "logDomain", - type: AnyType, - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "logLevel", - type: AnyType, - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "stringFields", - type: AnyType, - direction: Direction.In - }) - ], - return_type: AnyType - }) - ); - - // export function strstrip(str: string): string; - - namespace.members.set( - "strstrip", - new IntrospectedFunction({ - name: "strstrip", - raw_name: "strstrip", - parameters: [ - new IntrospectedFunctionParameter({ - name: "str", - type: StringType, - direction: Direction.In - }) - ], - return_type: StringType - }) - ); - - // GLib.Error - - { - const Error = namespace.assertClass("Error"); - - const fixQuark = (c: T): T => { - return c.copy({ - parameters: c.parameters.map(p => { - if (p.type instanceof TypeIdentifier && p.type.is("GLib", "Quark")) { - return p.copy({ - type: new BinaryType(new NativeType("({ new(...args: any[] ): Error })"), p.type) - }); - } - - return p; - }) - }) as T; - }; - - if (Error.mainConstructor && !(Error.mainConstructor instanceof IntrospectedDirectAllocationConstructor)) - Error.mainConstructor = fixQuark(Error.mainConstructor); - - Error.constructors = Error.constructors.map(c => fixQuark(c)); - Error.members = Error.members.map(m => fixQuark(m)); - } - - { - const HashTable = namespace.assertClass("HashTable") as GirRecord; - - HashTable.indexSignature = `[key: string]: B;`; - } - - // GLib.Variant - - { - const Variant = namespace.assertClass("Variant"); - const VariantType = namespace.assertClass("VariantType"); - - Variant.addGeneric({ - default: new NativeType(`any`), - constraint: StringType - }); - - VariantType.addGeneric({ - default: new NativeType(`any`), - constraint: StringType - }); - - const VariantParams = [ - new IntrospectedFunctionParameter({ - name: "sig", - type: new GenericType("A"), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "value", - type: AnyType, - direction: Direction.In - }) - ]; - const VariantConstructor = new IntrospectedConstructor({ - name: "new", - parameters: VariantParams.map(vp => vp.copy()), - return_type: Variant.getType() - }); - - Variant.mainConstructor = VariantConstructor.copy(); - - Variant.constructors.unshift( - // static new: (sig: any, value: any) => Variant; - VariantConstructor.copy(), - // static _new_internal: (sig: any, value: any) => any;, - new IntrospectedConstructor({ - name: "_new_internal", - parameters: VariantParams.map(vp => vp.copy()), - return_type: AnyType - }) - ); - - Variant.members.push( - // unpack(): T; - new IntrospectedClassFunction({ - name: "unpack", - return_type: UnknownType, - parent: Variant - }), - // deepUnpack(): T; - new IntrospectedClassFunction({ - name: "deepUnpack", - return_type: UnknownType, - parent: Variant - }), - // deep_unpack: any; - new IntrospectedClassFunction({ - name: "deep_unpack", - return_type: UnknownType, - parent: Variant - }), - // recursiveUnpack: () => any; - new IntrospectedClassFunction({ - name: "recursiveUnpack", - return_type: AnyType, - parent: Variant - }), - // _init(sig: any, value: any): Variant; - new IntrospectedClassFunction({ - name: "_init", - return_type: Variant.getType(), - parent: Variant, - parameters: VariantParams.map(vp => vp.copy()) - }) - ); - } - - // GLib.VariantDict - - { - const VariantDict = namespace.assertClass("VariantDict"); - - VariantDict.members.push( - // lookup(key: any, variantType?: any, deep?: any): any; - new IntrospectedClassFunction({ - name: "lookup", - return_type: AnyType, - parent: VariantDict, - parameters: [ - new IntrospectedFunctionParameter({ - name: "key", - direction: Direction.In, - type: AnyType - }), - new IntrospectedFunctionParameter({ - name: "variantType", - direction: Direction.In, - type: AnyType, - isOptional: true - }), - new IntrospectedFunctionParameter({ - name: "deep", - direction: Direction.In, - type: BooleanType, - isOptional: true + namespace: "GLib", + version: "2.0", + modifier(namespace: IntrospectedNamespace) { + // export function log_structured(logDomain, logLevel, stringFields); + + namespace.members.set( + "log_structured", + new IntrospectedFunction({ + name: "log_structured", + raw_name: "log_structured", + parameters: [ + new IntrospectedFunctionParameter({ + name: "logDomain", + type: AnyType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "logLevel", + type: AnyType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "stringFields", + type: AnyType, + direction: GirDirection.In + }) + ], + return_type: AnyType }) - ] - }) - ); - } - - // GLib.Bytes - - { - const Bytes = namespace.assertClass("Bytes"); - - Bytes.members.push( - // toArray(): Uint8Array; - new IntrospectedClassFunction({ - name: "toArray", - return_type: Uint8ArrayType, - parent: Bytes, - parameters: [] - }) - ); + ); + + // export function strstrip(str: string): string; + + namespace.members.set( + "strstrip", + new IntrospectedFunction({ + name: "strstrip", + raw_name: "strstrip", + parameters: [ + new IntrospectedFunctionParameter({ + name: "str", + type: StringType, + direction: GirDirection.In + }) + ], + return_type: StringType + }) + ); + + // GLib.Error + + { + const Error = namespace.assertClass("Error"); + + const fixQuark = (c: T): T => { + return c.copy({ + parameters: c.parameters.map(p => { + if (p.type instanceof TypeIdentifier && p.type.is("GLib", "Quark")) { + return p.copy({ + type: new BinaryType(new NativeType("({ new(...args: any[] ): Error })"), p.type) + }); + } + + return p; + }) + }) as T; + }; + + if (Error.mainConstructor && !(Error.mainConstructor instanceof IntrospectedDirectAllocationConstructor)) + Error.mainConstructor = fixQuark(Error.mainConstructor); + + Error.constructors = Error.constructors.map(c => fixQuark(c)); + Error.members = Error.members.map(m => fixQuark(m)); + } + + { + const HashTable = namespace.assertClass("HashTable") as IntrospectedRecord; + + HashTable.indexSignature = "[key: string]: B;"; + } + + // GLib.Variant + + { + const Variant = namespace.assertClass("Variant"); + const VariantType = namespace.assertClass("VariantType"); + + Variant.addGeneric({ + default: new NativeType("any"), + constraint: StringType + }); + + VariantType.addGeneric({ + default: new NativeType("any"), + constraint: StringType + }); + + const VariantParams = [ + new IntrospectedFunctionParameter({ + name: "sig", + type: new GenericType("A"), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "value", + type: AnyType, + direction: GirDirection.In + }) + ]; + const VariantConstructor = new IntrospectedConstructor({ + name: "new", + parameters: VariantParams.map(vp => vp.copy()), + return_type: Variant.getType() + }); + + Variant.mainConstructor = VariantConstructor.copy(); + + Variant.constructors.unshift( + // static new: (sig: any, value: any) => Variant; + VariantConstructor.copy(), + // static _new_internal: (sig: any, value: any) => any;, + new IntrospectedConstructor({ + name: "_new_internal", + parameters: VariantParams.map(vp => vp.copy()), + return_type: AnyType + }) + ); + + Variant.members.push( + // unpack(): T; + new IntrospectedClassFunction({ + name: "unpack", + return_type: UnknownType, + parent: Variant + }), + // deepUnpack(): T; + new IntrospectedClassFunction({ + name: "deepUnpack", + return_type: UnknownType, + parent: Variant + }), + // deep_unpack: any; + new IntrospectedClassFunction({ + name: "deep_unpack", + return_type: UnknownType, + parent: Variant + }), + // recursiveUnpack: () => any; + new IntrospectedClassFunction({ + name: "recursiveUnpack", + return_type: AnyType, + parent: Variant + }), + // _init(sig: any, value: any): Variant; + new IntrospectedClassFunction({ + name: "_init", + return_type: Variant.getType(), + parent: Variant, + parameters: VariantParams.map(vp => vp.copy()) + }) + ); + } + + // GLib.VariantDict + + { + const VariantDict = namespace.assertClass("VariantDict"); + + VariantDict.members.push( + // lookup(key: any, variantType?: any, deep?: any): any; + new IntrospectedClassFunction({ + name: "lookup", + return_type: AnyType, + parent: VariantDict, + parameters: [ + new IntrospectedFunctionParameter({ + name: "key", + direction: GirDirection.In, + type: AnyType + }), + new IntrospectedFunctionParameter({ + name: "variantType", + direction: GirDirection.In, + type: AnyType, + isOptional: true + }), + new IntrospectedFunctionParameter({ + name: "deep", + direction: GirDirection.In, + type: BooleanType, + isOptional: true + }) + ] + }) + ); + } + + // GLib.Bytes + + { + const Bytes = namespace.assertClass("Bytes"); + + Bytes.members.push( + // toArray(): Uint8Array; + new IntrospectedClassFunction({ + name: "toArray", + return_type: Uint8ArrayType, + parent: Bytes, + parameters: [] + }) + ); + } } - } }; diff --git a/packages/lib/src/newlib/injections/gobject.ts b/packages/lib/src/newlib/injections/gobject.ts index 2f78fc53c..a318af7f6 100644 --- a/packages/lib/src/newlib/injections/gobject.ts +++ b/packages/lib/src/newlib/injections/gobject.ts @@ -1,568 +1,572 @@ import { IntrospectedNamespace } from "../gir/namespace.js"; -import { IntrospectedFunctionParameter, IntrospectedClassFunction, IntrospectedFunction, IntrospectedStaticClassFunction } from "../gir/function.js"; import { - NativeType, - AnyType, - StringType, - BinaryType, - VoidType, - NumberType, - TypeIdentifier, - ObjectType, - NullableType, - TupleType, - UnknownType, - AnyFunctionType, - Generic, - GenericType, - TypeExpression, - BooleanType, - GenerifiedTypeIdentifier + IntrospectedFunctionParameter, + IntrospectedClassFunction, + IntrospectedFunction, + IntrospectedStaticClassFunction +} from "../gir/function.js"; +import { + NativeType, + AnyType, + StringType, + BinaryType, + VoidType, + NumberType, + TypeIdentifier, + ObjectType, + NullableType, + TupleType, + UnknownType, + AnyFunctionType, + Generic, + GenericType, + TypeExpression, + BooleanType, + GenerifiedTypeIdentifier } from "../gir.js"; -import { Direction } from "@gi.ts/parser"; +import { GirDirection } from "@gi.ts/parser"; import { Field } from "../gir/property.js"; import { IntrospectedAlias } from "../gir/alias.js"; -import { GirInterface } from "../gir/class.js"; -import { NSRegistry } from "../gir/registry.js"; +import { IntrospectedInterface } from "../gir/class.js"; function typeParam(name: string, type: TypeExpression) { - return new IntrospectedFunctionParameter({ - name, - direction: Direction.In, - type: type - }); + return new IntrospectedFunctionParameter({ + name, + direction: GirDirection.In, + type: type + }); } function anyParam(name: string) { - return typeParam(name, AnyType); + return typeParam(name, AnyType); } export default { - namespace: "GObject", - version: "2.0", - modifier(namespace: IntrospectedNamespace, _registry: NSRegistry) { - { - const SignalMatch = new GirInterface({ - name: "SignalMatch", - namespace, - fields: [ - new Field({ - name: "signalId", - type: StringType, - isStatic: false, - writable: true - }), - new Field({ - name: "detail", - type: StringType, - isStatic: false, - writable: true - }), - new Field({ - name: "func", - type: AnyFunctionType, - isStatic: false, - writable: true - }) - ] - }); - - // TODO: Devise a better way to represent pure TypeScript types. - SignalMatch.noParent = true; - - namespace.members.set("SignalMatch", SignalMatch); - - const GType = new IntrospectedAlias({ - name: "GType", - type: new NativeType("any") - }); - namespace.members.set("GType", GType); - - // We don't want to emit TypeScript-specific GType - // hacks, but we still need the alias so the type - // can resolve. - GType.noEmit(); - - const ParamSpec = namespace.assertClass("ParamSpec"); - const ParamFlags = namespace.getEnum("ParamFlags"); - - function generateParamSpec( - name: string, - returnType: TypeExpression = ParamSpec.getType(), - minMax = false, - type: string | null = null, - defaultValue = false, - defaultValueType: TypeExpression = AnyType, - addGeneric = false - ) { - const fn = new IntrospectedStaticClassFunction({ - name, - parameters: [ - typeParam("name", StringType), - typeParam("nick", StringType), - typeParam("blurb", StringType), - typeParam("flags", new BinaryType(ParamFlags?.getType() ?? AnyType, NumberType)), - ...(minMax ? [typeParam("minimum", NumberType), typeParam("maximum", NumberType)] : []), - ...(type - ? !addGeneric - ? [anyParam(`${type}Type`)] - : [ + namespace: "GObject", + version: "2.0", + modifier(namespace: IntrospectedNamespace) { + { + const SignalMatch = new IntrospectedInterface({ + name: "SignalMatch", + namespace, + fields: [ + new Field({ + name: "signalId", + type: StringType, + isStatic: false, + writable: true + }), + new Field({ + name: "detail", + type: StringType, + isStatic: false, + writable: true + }), + new Field({ + name: "func", + type: AnyFunctionType, + isStatic: false, + writable: true + }) + ] + }); + + // TODO: Devise a better way to represent pure TypeScript types. + SignalMatch.noParent = true; + + namespace.members.set("SignalMatch", SignalMatch); + + const GType = new IntrospectedAlias({ + name: "GType", + type: new NativeType("any") + }); + namespace.members.set("GType", GType); + + // We don't want to emit TypeScript-specific GType + // hacks, but we still need the alias so the type + // can resolve. + GType.noEmit(); + + const ParamSpec = namespace.assertClass("ParamSpec"); + const ParamFlags = namespace.getEnum("ParamFlags"); + + function generateParamSpec( + name: string, + returnType: TypeExpression = ParamSpec.getType(), + minMax = false, + type: string | null = null, + defaultValue = false, + defaultValueType: TypeExpression = AnyType, + addGeneric = false + ) { + const fn = new IntrospectedStaticClassFunction({ + name, + parameters: [ + typeParam("name", StringType), + typeParam("nick", StringType), + typeParam("blurb", StringType), + typeParam("flags", new BinaryType(ParamFlags?.getType() ?? AnyType, NumberType)), + ...(minMax ? [typeParam("minimum", NumberType), typeParam("maximum", NumberType)] : []), + ...(type + ? !addGeneric + ? [anyParam(`${type}Type`)] + : [ + new IntrospectedFunctionParameter({ + name: `${type}Type`, + direction: GirDirection.In, + type: new NativeType("GType | { $gtype: GType }") + }) + ] + : []), + ...(defaultValue ? [typeParam("defaultValue", defaultValueType)] : []) + ], + parent: ParamSpec, + return_type: returnType + }); + + if (addGeneric) { + fn.generics.push(new Generic(new GenericType("T"))); + } + + return fn; + } + + ParamSpec.fields.push( + new Field({ + name: "override", + isStatic: true, + type: AnyType, + writable: true + }) + ); + + // Get rid of the ParamSpec subtypes. + namespace.assertClass("ParamSpecBoolean").noEmit(); + namespace.assertClass("ParamSpecBoxed").noEmit(); + namespace.assertClass("ParamSpecChar").noEmit(); + namespace.assertClass("ParamSpecDouble").noEmit(); + namespace.assertClass("ParamSpecEnum").noEmit(); + namespace.assertClass("ParamSpecFlags").noEmit(); + namespace.assertClass("ParamSpecFloat").noEmit(); + namespace.assertClass("ParamSpecInt").noEmit(); + namespace.assertClass("ParamSpecInt64").noEmit(); + namespace.assertClass("ParamSpecLong").noEmit(); + namespace.assertClass("ParamSpecObject").noEmit(); + namespace.assertClass("ParamSpecParam").noEmit(); + namespace.assertClass("ParamSpecString").noEmit(); + namespace.assertClass("ParamSpecUChar").noEmit(); + namespace.assertClass("ParamSpecUnichar").noEmit(); + namespace.assertClass("ParamSpecValueArray").noEmit(); + namespace.assertClass("ParamSpecVariant").noEmit(); + namespace.assertClass("ParamSpecUInt").noEmit(); + namespace.assertClass("ParamSpecUInt64").noEmit(); + namespace.assertClass("ParamSpecULong").noEmit(); + namespace.assertClass("ParamSpecGType").noEmit(); + namespace.assertClass("ParamSpecOverride").noEmit(); + namespace.assertClass("ParamSpecPointer").noEmit(); + + // The primary "type" + ParamSpec.addGeneric({ + default: UnknownType + }); + + const object = new IntrospectedStaticClassFunction({ + name: "object", + parameters: [ + anyParam("name"), + anyParam("nick"), + anyParam("blurb"), + anyParam("flags"), new IntrospectedFunctionParameter({ - name: `${type}Type`, - direction: Direction.In, - type: new NativeType("GType | { $gtype: GType }") + name: "objectType", + direction: GirDirection.In, + type: new NativeType("GType | { $gtype: GType }") }) - ] - : []), - ...(defaultValue ? [typeParam("defaultValue", defaultValueType)] : []) - ], - parent: ParamSpec, - return_type: returnType - }); - - if (addGeneric) { - fn.generics.push(new Generic(new GenericType("T"))); + ], + parent: ParamSpec, + return_type: new NativeType("ParamSpec") + }); + + object.generics.push(new Generic(new GenericType("T"))); + + function ParamSpecWithGenerics(type: TypeExpression) { + return new GenerifiedTypeIdentifier("ParamSpec", "GObject", [type]); + } + + ParamSpec.members.push( + // "char": "static char(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("char", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "uchar": "static uchar(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any):ParamSpec;", + generateParamSpec("uchar", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "int": "static int(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("int", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "uint": "static uint(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("uint", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "long": "static long(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("long", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "ulong": "static ulong(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("ulong", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "int64": "static int64(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("int64", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "uint64": "static uint64(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("uint64", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "float": "static float(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("float", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "boolean": "static boolean(name: any, nick: any, blurb: any, flags: any, defaultValue: any): ParamSpec;", + generateParamSpec("boolean", ParamSpecWithGenerics(BooleanType), false, null, true, BooleanType), + // "flags": "static flags(name: any, nick: any, blurb: any, flags: any, flagsType: any, defaultValue: any): ParamSpec;", + generateParamSpec("flags", ParamSpecWithGenerics(NumberType), false, "flags", true), + // "enum": "static enum(name: any, nick: any, blurb: any, flags: any, enumType: any, defaultValue: any): ParamSpec;", + generateParamSpec( + "enum", + ParamSpecWithGenerics(new NativeType("T")), + false, + "enum", + true, + undefined, + true + ), + // "double": "static double(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", + generateParamSpec("double", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), + // "string": "static string(name: any, nick: any, blurb: any, flags: any, defaultValue: any): ParamSpec;", + generateParamSpec("string", ParamSpecWithGenerics(StringType), false, null, true, StringType), + // "boxed": "static boxed(name: any, nick: any, blurb: any, flags: any, boxedType: any): ParamSpec;", + generateParamSpec( + "boxed", + ParamSpecWithGenerics(new NativeType("T")), + false, + "boxed", + false, + undefined, + true + ), + // "object": "static object(name: any, nick: any, blurb: any, flags: any, objectType: any): ParamSpec;", + object, + // "param": "static param(name: any, nick: any, blurb: any, flags: any, paramType: any): ParamSpec;", + generateParamSpec("param", ParamSpec.getType(), false, "param", false) + ); } - return fn; - } - - ParamSpec.fields.push( - new Field({ - name: "override", - isStatic: true, - type: AnyType, - writable: true - }) - ); - - // Get rid of the ParamSpec subtypes. - namespace.assertClass("ParamSpecBoolean").noEmit(); - namespace.assertClass("ParamSpecBoxed").noEmit(); - namespace.assertClass("ParamSpecChar").noEmit(); - namespace.assertClass("ParamSpecDouble").noEmit(); - namespace.assertClass("ParamSpecEnum").noEmit(); - namespace.assertClass("ParamSpecFlags").noEmit(); - namespace.assertClass("ParamSpecFloat").noEmit(); - namespace.assertClass("ParamSpecInt").noEmit(); - namespace.assertClass("ParamSpecInt64").noEmit(); - namespace.assertClass("ParamSpecLong").noEmit(); - namespace.assertClass("ParamSpecObject").noEmit(); - namespace.assertClass("ParamSpecParam").noEmit(); - namespace.assertClass("ParamSpecString").noEmit(); - namespace.assertClass("ParamSpecUChar").noEmit(); - namespace.assertClass("ParamSpecUnichar").noEmit(); - namespace.assertClass("ParamSpecValueArray").noEmit(); - namespace.assertClass("ParamSpecVariant").noEmit(); - namespace.assertClass("ParamSpecUInt").noEmit(); - namespace.assertClass("ParamSpecUInt64").noEmit(); - namespace.assertClass("ParamSpecULong").noEmit(); - namespace.assertClass("ParamSpecGType").noEmit(); - namespace.assertClass("ParamSpecOverride").noEmit(); - namespace.assertClass("ParamSpecPointer").noEmit(); - - // The primary "type" - ParamSpec.addGeneric({ - default: UnknownType - }); - - const object = new IntrospectedStaticClassFunction({ - name: "object", - parameters: [ - anyParam("name"), - anyParam("nick"), - anyParam("blurb"), - anyParam("flags"), - new IntrospectedFunctionParameter({ - name: `objectType`, - direction: Direction.In, - type: new NativeType("GType | { $gtype: GType }") - }) - ], - parent: ParamSpec, - return_type: new NativeType("ParamSpec") - }); - - object.generics.push(new Generic(new GenericType("T"))); - - function ParamSpecWithGenerics(type: TypeExpression) { - return new GenerifiedTypeIdentifier("ParamSpec", "GObject", [type]); - } - - ParamSpec.members.push( - // "char": "static char(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("char", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "uchar": "static uchar(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any):ParamSpec;", - generateParamSpec("uchar", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "int": "static int(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("int", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "uint": "static uint(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("uint", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "long": "static long(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("long", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "ulong": "static ulong(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("ulong", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "int64": "static int64(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("int64", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "uint64": "static uint64(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("uint64", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "float": "static float(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("float", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "boolean": "static boolean(name: any, nick: any, blurb: any, flags: any, defaultValue: any): ParamSpec;", - generateParamSpec("boolean", ParamSpecWithGenerics(BooleanType), false, null, true, BooleanType), - // "flags": "static flags(name: any, nick: any, blurb: any, flags: any, flagsType: any, defaultValue: any): ParamSpec;", - generateParamSpec("flags", ParamSpecWithGenerics(NumberType), false, "flags", true), - // "enum": "static enum(name: any, nick: any, blurb: any, flags: any, enumType: any, defaultValue: any): ParamSpec;", - generateParamSpec( - "enum", - ParamSpecWithGenerics(new NativeType("T")), - false, - "enum", - true, - undefined, - true - ), - // "double": "static double(name: any, nick: any, blurb: any, flags: any, minimum: any, maximum: any, defaultValue: any): ParamSpec;", - generateParamSpec("double", ParamSpecWithGenerics(NumberType), true, null, true, NumberType), - // "string": "static string(name: any, nick: any, blurb: any, flags: any, defaultValue: any): ParamSpec;", - generateParamSpec("string", ParamSpecWithGenerics(StringType), false, null, true, StringType), - // "boxed": "static boxed(name: any, nick: any, blurb: any, flags: any, boxedType: any): ParamSpec;", - generateParamSpec( - "boxed", - ParamSpecWithGenerics(new NativeType("T")), - false, - "boxed", - false, - undefined, - true - ), - // "object": "static object(name: any, nick: any, blurb: any, flags: any, objectType: any): ParamSpec;", - object, - // "param": "static param(name: any, nick: any, blurb: any, flags: any, paramType: any): ParamSpec;", - generateParamSpec("param", ParamSpec.getType(), false, "param", false) - ); - } + { + namespace.members.delete("Closure"); + + namespace.members.set( + "Closure", + new IntrospectedAlias({ + name: "Closure", + type: NativeType.of("(...args: P[]) => R"), + generics: [ + { + name: "R", + type: AnyType + }, + { + name: "P", + type: AnyType + } + ] + }) + ); + } + + { + const Object = namespace.assertClass("Object"); + + const get_property = Object.members.findIndex(m => m.name === "get_property"); + const set_property = Object.members.findIndex(m => m.name === "set_property"); - { - namespace.members.delete("Closure"); - - namespace.members.set( - "Closure", - new IntrospectedAlias({ - name: "Closure", - type: NativeType.of("(...args: P[]) => R"), - generics: [ - { - name: "R", - type: AnyType - }, - { - name: "P", - type: AnyType + Object.members[get_property] = new IntrospectedClassFunction({ + name: "get_property", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "property_name", + type: StringType, + direction: GirDirection.In + }) + ], + return_type: AnyType + }); + + Object.members[set_property] = new IntrospectedClassFunction({ + name: "set_property", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "property_name", + type: StringType, + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "value", + type: AnyType, + direction: GirDirection.In + }) + ], + return_type: VoidType + }); + + Object.members.push( + new IntrospectedStaticClassFunction({ + name: "_classInit", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "klass", + type: AnyType, + direction: GirDirection.In + }) + ], + return_type: AnyType + }), + new IntrospectedClassFunction({ + name: "disconnect", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: NumberType, + direction: GirDirection.In + }) + ], + return_type: VoidType + }), + // TODO: Add per-class set type checking. + new IntrospectedClassFunction({ + name: "set", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "properties", + type: new NativeType("{ [key: string]: any }"), + direction: GirDirection.In + }) + ], + return_type: VoidType + }), + new IntrospectedClassFunction({ + name: "block_signal_handler", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: NumberType, + direction: GirDirection.In + }) + ], + return_type: AnyType + }), + new IntrospectedClassFunction({ + name: "unblock_signal_handler", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "id", + type: NumberType, + direction: GirDirection.In + }) + ], + return_type: AnyType + }), + new IntrospectedClassFunction({ + name: "stop_emission_by_name", + parent: Object, + parameters: [ + new IntrospectedFunctionParameter({ + name: "detailedName", + type: StringType, + direction: GirDirection.In + }) + ], + return_type: AnyType + }) + ); + + function replaceFunction(name: string, ...functions: IntrospectedFunction[]) { + namespace.members.delete(name); + + namespace.members.set(name, functions); } - ] - }) - ); - } - { - const Object = namespace.assertClass("Object"); - - const get_property = Object.members.findIndex(m => m.name === "get_property"); - const set_property = Object.members.findIndex(m => m.name === "set_property"); - - Object.members[get_property] = new IntrospectedClassFunction({ - name: "get_property", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "property_name", - type: StringType, - direction: Direction.In - }) - ], - return_type: AnyType - }); - - Object.members[set_property] = new IntrospectedClassFunction({ - name: "set_property", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "property_name", - type: StringType, - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "value", - type: AnyType, - direction: Direction.In - }) - ], - return_type: VoidType - }); - - Object.members.push( - new IntrospectedStaticClassFunction({ - name: "_classInit", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "klass", - type: AnyType, - direction: Direction.In - }) - ], - return_type: AnyType - }), - new IntrospectedClassFunction({ - name: "disconnect", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: NumberType, - direction: Direction.In - }) - ], - return_type: VoidType - }), - // TODO: Add per-class set type checking. - new IntrospectedClassFunction({ - name: "set", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "properties", - type: new NativeType("{ [key: string]: any }"), - direction: Direction.In - }) - ], - return_type: VoidType - }), - new IntrospectedClassFunction({ - name: "block_signal_handler", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: NumberType, - direction: Direction.In - }) - ], - return_type: AnyType - }), - new IntrospectedClassFunction({ - name: "unblock_signal_handler", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "id", - type: NumberType, - direction: Direction.In - }) - ], - return_type: AnyType - }), - new IntrospectedClassFunction({ - name: "stop_emission_by_name", - parent: Object, - parameters: [ - new IntrospectedFunctionParameter({ - name: "detailedName", - type: StringType, - direction: Direction.In - }) - ], - return_type: AnyType - }) - ); - - function replaceFunction(name: string, ...functions: IntrospectedFunction[]) { - namespace.members.delete(name); - - namespace.members.set(name, functions); - } - - // export function signal_handlers_block_by_func(instance: Object, func: Function); - - replaceFunction( - "signal_handlers_block_by_func", - new IntrospectedFunction({ - name: "signal_handlers_block_by_func", - raw_name: "signal_handlers_block_by_func", - parameters: [ - new IntrospectedFunctionParameter({ - name: "instance", - type: Object.getType(), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "func", - type: AnyFunctionType, - direction: Direction.In - }) - ], - return_type: VoidType - }) - ); - - // export function signal_handlers_unblock_by_func (instance: Object, func: Function); - - replaceFunction( - "signal_handlers_unblock_by_func", - new IntrospectedFunction({ - name: "signal_handlers_unblock_by_func", - raw_name: "signal_handlers_unblock_by_func", - parameters: [ - new IntrospectedFunctionParameter({ - name: "instance", - type: Object.getType(), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "func", - type: AnyFunctionType, - direction: Direction.In - }) - ], - return_type: VoidType - }) - ); - - // export function signal_handlers_disconnect_by_func(instance: Object, func: Function); - - replaceFunction( - "signal_handlers_disconnect_by_func", - new IntrospectedFunction({ - name: "signal_handlers_disconnect_by_func", - raw_name: "signal_handlers_disconnect_by_func", - parameters: [ - new IntrospectedFunctionParameter({ - name: "instance", - type: Object.getType(), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "func", - type: AnyFunctionType, - direction: Direction.In - }) - ], - return_type: VoidType - }) - ); - - // signal_handler_find - - const args = new IntrospectedFunctionParameter({ - name: "args", - direction: Direction.In, - isVarArgs: true, - type: new BinaryType( - new TupleType(Object.getType(), NativeType.of("SignalMatch")), - new TupleType( - Object.getType(), - new TypeIdentifier("SignalMatchType", "GObject"), - NumberType, - new TypeIdentifier("Quark", "GLib"), - new NullableType(new TypeIdentifier("Closure", "GObject")), - new NullableType(ObjectType), - new NullableType(ObjectType) - ) - ) - }); - - const modifiedArgs = [ - new IntrospectedFunctionParameter({ - name: "instance", - direction: Direction.In, - - type: Object.getType() - }), - new IntrospectedFunctionParameter({ - name: "match", - direction: Direction.In, - type: NativeType.of("SignalMatch") - }) - ]; - - const originalArgs = [ - new IntrospectedFunctionParameter({ - name: "instance", - direction: Direction.In, - - type: Object.getType() - }), - new IntrospectedFunctionParameter({ - name: "match", - direction: Direction.In, - type: new TypeIdentifier("SignalMatchType", "GObject") - }), - new IntrospectedFunctionParameter({ - name: "signal_id", - direction: Direction.In, - type: NumberType - }), - new IntrospectedFunctionParameter({ - name: "detail", - type: new TypeIdentifier("Quark", "GLib"), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "closure", - type: new NullableType(new TypeIdentifier("Closure", "GObject")), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "func", - type: new NullableType(ObjectType), - direction: Direction.In - }), - new IntrospectedFunctionParameter({ - name: "object", - type: new NullableType(ObjectType), - direction: Direction.In - }) - ]; - - function originalFunc(name: string) { - return new IntrospectedFunction({ - name, - raw_name: name, - return_type: NumberType, - parameters: originalArgs.map(a => a.copy()) - }); - } - - function func(name: string) { - replaceFunction( - name, - // [name](...args: [Object, SignalMatch] | [Object, SignalMatchType, number, GLib.Quark, Closure | null, object | null, object | null]): number; - new IntrospectedFunction({ - name, - raw_name: name, - return_type: NumberType, - parameters: [args] - }), - // export function [name](instance: Object, match: SignalMatch): number; - new IntrospectedFunction({ - name, - raw_name: name, - return_type: NumberType, - parameters: modifiedArgs.map(a => a.copy()) - }), - // export function [name](instance: Object, mask: SignalMatchType, signal_id: number, detail: GLib.Quark, closure: Closure | null, func: object | null, data: object | null): number - originalFunc(name), - // export function [`_real_${name}`](instance: Object, mask: SignalMatchType, signal_id: number, detail: GLib.Quark, closure: Closure | null, func: object | null, data: object | null): number - originalFunc(`_real_${name}`) - ); - } - - func("signal_handler_find"); - func("signal_handler_block_matched"); - func("signal_handler_block_disconnect_matched"); - func("signal_handler_block_unblock_matched"); + // export function signal_handlers_block_by_func(instance: Object, func: Function); + + replaceFunction( + "signal_handlers_block_by_func", + new IntrospectedFunction({ + name: "signal_handlers_block_by_func", + raw_name: "signal_handlers_block_by_func", + parameters: [ + new IntrospectedFunctionParameter({ + name: "instance", + type: Object.getType(), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "func", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: VoidType + }) + ); + + // export function signal_handlers_unblock_by_func (instance: Object, func: Function); + + replaceFunction( + "signal_handlers_unblock_by_func", + new IntrospectedFunction({ + name: "signal_handlers_unblock_by_func", + raw_name: "signal_handlers_unblock_by_func", + parameters: [ + new IntrospectedFunctionParameter({ + name: "instance", + type: Object.getType(), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "func", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: VoidType + }) + ); + + // export function signal_handlers_disconnect_by_func(instance: Object, func: Function); + + replaceFunction( + "signal_handlers_disconnect_by_func", + new IntrospectedFunction({ + name: "signal_handlers_disconnect_by_func", + raw_name: "signal_handlers_disconnect_by_func", + parameters: [ + new IntrospectedFunctionParameter({ + name: "instance", + type: Object.getType(), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "func", + type: AnyFunctionType, + direction: GirDirection.In + }) + ], + return_type: VoidType + }) + ); + + // signal_handler_find + + const args = new IntrospectedFunctionParameter({ + name: "args", + direction: GirDirection.In, + isVarArgs: true, + type: new BinaryType( + new TupleType(Object.getType(), NativeType.of("SignalMatch")), + new TupleType( + Object.getType(), + new TypeIdentifier("SignalMatchType", "GObject"), + NumberType, + new TypeIdentifier("Quark", "GLib"), + new NullableType(new TypeIdentifier("Closure", "GObject")), + new NullableType(ObjectType), + new NullableType(ObjectType) + ) + ) + }); + + const modifiedArgs = [ + new IntrospectedFunctionParameter({ + name: "instance", + direction: GirDirection.In, + + type: Object.getType() + }), + new IntrospectedFunctionParameter({ + name: "match", + direction: GirDirection.In, + type: NativeType.of("SignalMatch") + }) + ]; + + const originalArgs = [ + new IntrospectedFunctionParameter({ + name: "instance", + direction: GirDirection.In, + + type: Object.getType() + }), + new IntrospectedFunctionParameter({ + name: "match", + direction: GirDirection.In, + type: new TypeIdentifier("SignalMatchType", "GObject") + }), + new IntrospectedFunctionParameter({ + name: "signal_id", + direction: GirDirection.In, + type: NumberType + }), + new IntrospectedFunctionParameter({ + name: "detail", + type: new TypeIdentifier("Quark", "GLib"), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "closure", + type: new NullableType(new TypeIdentifier("Closure", "GObject")), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "func", + type: new NullableType(ObjectType), + direction: GirDirection.In + }), + new IntrospectedFunctionParameter({ + name: "object", + type: new NullableType(ObjectType), + direction: GirDirection.In + }) + ]; + + function originalFunc(name: string) { + return new IntrospectedFunction({ + name, + raw_name: name, + return_type: NumberType, + parameters: originalArgs.map(a => a.copy()) + }); + } + + function func(name: string) { + replaceFunction( + name, + // [name](...args: [Object, SignalMatch] | [Object, SignalMatchType, number, GLib.Quark, Closure | null, object | null, object | null]): number; + new IntrospectedFunction({ + name, + raw_name: name, + return_type: NumberType, + parameters: [args] + }), + // export function [name](instance: Object, match: SignalMatch): number; + new IntrospectedFunction({ + name, + raw_name: name, + return_type: NumberType, + parameters: modifiedArgs.map(a => a.copy()) + }), + // export function [name](instance: Object, mask: SignalMatchType, signal_id: number, detail: GLib.Quark, closure: Closure | null, func: object | null, data: object | null): number + originalFunc(name), + // export function [`_real_${name}`](instance: Object, mask: SignalMatchType, signal_id: number, detail: GLib.Quark, closure: Closure | null, func: object | null, data: object | null): number + originalFunc(`_real_${name}`) + ); + } + + func("signal_handler_find"); + func("signal_handler_block_matched"); + func("signal_handler_block_disconnect_matched"); + func("signal_handler_block_unblock_matched"); + } } - } }; diff --git a/packages/lib/src/newlib/injections/inject.ts b/packages/lib/src/newlib/injections/inject.ts index 1134670c1..91d85b340 100644 --- a/packages/lib/src/newlib/injections/inject.ts +++ b/packages/lib/src/newlib/injections/inject.ts @@ -8,17 +8,17 @@ import { NSRegistry } from "../gir/registry.js"; export type NamespaceInjection = (namespace: IntrospectedNamespace, registry: NSRegistry) => void; function injectDefinitions(registry: NSRegistry) { - return (definition: { namespace: string; version: string; modifier: NamespaceInjection }) => { - const ns = registry.assertNamespace(definition.namespace, definition.version); + return (definition: { namespace: string; version: string; modifier: NamespaceInjection }) => { + const ns = registry.assertNamespace(definition.namespace, definition.version); - definition.modifier(ns, registry); - }; + definition.modifier(ns, registry); + }; } export function inject(registry: NSRegistry) { - const $ = injectDefinitions(registry); + const $ = injectDefinitions(registry); - $(glib); - $(gobject); - $(gio); + $(glib); + $(gobject); + $(gio); } diff --git a/packages/lib/src/newlib/lib.ts b/packages/lib/src/newlib/lib.ts index 7b8909798..54969e80e 100644 --- a/packages/lib/src/newlib/lib.ts +++ b/packages/lib/src/newlib/lib.ts @@ -18,66 +18,66 @@ export { NSRegistry as GirNSRegistry } from "./gir/registry.js"; export { Formatter } from "./formatters/formatter.js"; export function getSanitizedIdentifiers(): ReadonlyMap { - return SanitizedIdentifiers; + return SanitizedIdentifiers; } export function createRegistry(): NSRegistry { - return new NSRegistry(); + return new NSRegistry(); } export interface GeneratedModule { - meta: Metadata; - formattedOutput: string; + meta: Metadata; + formattedOutput: string; } export async function generateModule( - options: GenerationOptions, - registry: NSRegistry, - name: string, - version: string + options: GenerationOptions, + registry: NSRegistry, + name: string, + version: string ): Promise { - const ns = registry.namespace(name, version); + const ns = registry.namespace(name, version); - if (ns) { - const Generator = registry.getGenerator(options.format); + if (ns) { + const Generator = await registry.getGenerator(options.format); - if (!Generator) { - throw new Error(`Invalid output format selected: ${options.format}.`); - } + if (!Generator) { + throw new Error(`Invalid output format selected: ${options.format}.`); + } - const generator = new Generator(ns, options); + const generator = new Generator(ns, options); - let generated: string | null = null; + let generated: string | null = null; - try { - generated = await generator.stringifyNamespace(ns); - } catch (error) { - console.error(`Failed to generate ${ns.name} ${ns.version}...`); + try { + generated = await generator.stringifyNamespace(ns); + } catch (error) { + console.error(`Failed to generate ${ns.name} ${ns.version}...`); - if (options.verbose) { - console.error(error); - } - } + if (options.verbose) { + console.error(error); + } + } - if (!generated) { - return null; - } + if (!generated) { + return null; + } - const meta: Metadata = { - name: ns.name, - api_version: ns.version, - package_version: ns.package_version.join("."), - imports: Object.fromEntries(ns.getImports()) - }; + const meta: Metadata = { + name: ns.name, + api_version: ns.version, + package_version: ns.package_version.join("."), + imports: Object.fromEntries(ns.getImports()) + }; - const formatter = registry.getFormatter(options.format); - const formatted = !options.noPrettyPrint ? formatter.format(generated) : generated; + const formatter = registry.getFormatter(options.format); + const formatted = !options.noPrettyPrint ? formatter.format(generated) : generated; - return { - formattedOutput: formatted, - meta - }; - } + return { + formattedOutput: formatted, + meta + }; + } - return null; + return null; } diff --git a/packages/lib/src/newlib/types.ts b/packages/lib/src/newlib/types.ts index 1f6afa1dd..31b683593 100644 --- a/packages/lib/src/newlib/types.ts +++ b/packages/lib/src/newlib/types.ts @@ -1,47 +1,47 @@ export type PropertyCase = "both" | "camel" | "underscore"; -export type Format = "dts" | "json" | string; +export type Format = "dts" | "json"; export interface Options { - verbose: boolean; + verbose: boolean; } export interface LoadOptions extends Options { - loadDocs: boolean; - propertyCase: PropertyCase; + loadDocs: boolean; + propertyCase: PropertyCase; } export interface TransformOptions extends Options { - inferGenerics: boolean; + inferGenerics: boolean; } -export type OutputFormat = 'file' | 'folder'; +export type OutputFormat = "file" | "folder"; export interface GenerationOptions extends Options { - [key: string]: boolean | string | number | undefined; - outputFormat?: OutputFormat | string; - outputPath?: string; - promisify: boolean; - withDocs: boolean; - format: Format; - versionedOutput: boolean; - versionedImports: boolean; - /** - * A format for versioned imports - * - * @example - * "{namespace}{version}{version-slug}" - */ - versionFormat?: string; - importPrefix: string; - emitMetadata: boolean; - noAdvancedVariants: boolean; - noPrettyPrint: boolean; - noInitTypes: boolean; + [key: string]: boolean | string | number | undefined; + outputFormat?: string; + outputPath?: string; + promisify: boolean; + withDocs: boolean; + format: string; + versionedOutput: boolean; + versionedImports: boolean; + /** + * A format for versioned imports + * + * @example + * "{namespace}{version}{version-slug}" + */ + versionFormat?: string; + importPrefix: string; + emitMetadata: boolean; + noAdvancedVariants: boolean; + noPrettyPrint: boolean; + noInitTypes: boolean; } export interface Metadata { - name: string; - package_version: string; - api_version: string; - imports: { [lib: string]: string }; + name: string; + package_version: string; + api_version: string; + imports: { [lib: string]: string }; } diff --git a/packages/lib/src/newlib/util.ts b/packages/lib/src/newlib/util.ts index 3be2035a9..773946ffc 100644 --- a/packages/lib/src/newlib/util.ts +++ b/packages/lib/src/newlib/util.ts @@ -2,68 +2,68 @@ * A simple two-key map. */ export class TwoKeyMap { - private baseMap = new Map>(); + private baseMap = new Map>(); + + forEach(op: (v: V) => void) { + this.baseMap.forEach(map => { + map.forEach(v => { + op(v); + }); + }); + } - forEach(op: (v: V) => void) { - this.baseMap.forEach(map => { - map.forEach(v => { - op(v); - }); - }); - } + has(key1: K1, key2: K2): boolean { + const obj = this.baseMap.get(key1); - has(key1: K1, key2: K2): boolean { - const obj = this.baseMap.get(key1); + if (!obj) { + return false; + } - if (!obj) { - return false; + return obj.has(key2); } - return obj.has(key2); - } + getIfOnly(key1: K1): readonly [K2, V] | undefined { + const obj = this.baseMap.get(key1); - getIfOnly(key1: K1): readonly [K2, V] | undefined { - const obj = this.baseMap.get(key1); + if (!obj) { + return undefined; + } - if (!obj) { - return undefined; - } + if (obj.size === 1) { + const [k2] = obj.keys(); + const v = obj.get(k2); - if (obj.size === 1) { - const [k2] = obj.keys(); - const v = obj.get(k2); + if (!v) { + return undefined; + } - if (!v) { - return undefined; - } + return [k2, v] as const; + } - return [k2, v] as const; + return undefined; } - return undefined; - } + get(key1: K1, key2: K2): V | undefined { + const obj = this.baseMap.get(key1); - get(key1: K1, key2: K2): V | undefined { - const obj = this.baseMap.get(key1); + if (!obj) { + return undefined; + } - if (!obj) { - return undefined; + return obj.get(key2); } - return obj.get(key2); - } + set(key1: K1, key2: K2, value: V): void { + let obj = this.baseMap.get(key1); - set(key1: K1, key2: K2, value: V): void { - let obj = this.baseMap.get(key1); + if (!obj) { + obj = new Map(); - if (!obj) { - obj = new Map(); + this.baseMap.set(key1, obj); + } - this.baseMap.set(key1, obj); + obj.set(key2, value); } - - obj.set(key2, value); - } } /** @@ -75,10 +75,10 @@ export class TwoKeyMap { * @param predicate */ export function findMap(arr: T[], predicate: (p: T) => K | undefined): K | undefined { - for (const a of arr) { - const val = predicate(a); - if (val !== undefined) return val; - } + for (const a of arr) { + const val = predicate(a); + if (val !== undefined) return val; + } - return undefined; + return undefined; } diff --git a/packages/lib/src/newlib/validators/class.ts b/packages/lib/src/newlib/validators/class.ts index d627cd1f8..d5ccae0d4 100644 --- a/packages/lib/src/newlib/validators/class.ts +++ b/packages/lib/src/newlib/validators/class.ts @@ -1,46 +1,50 @@ import { NativeType, TypeIdentifier } from "../gir.js"; -import { IntrospectedBaseClass, IntrospectedClass, GirInterface, GirRecord } from "../gir/class.js"; +import { IntrospectedBaseClass, IntrospectedClass, IntrospectedInterface, IntrospectedRecord } from "../gir/class.js"; import { IntrospectedError } from "../gir/enum.js"; -import { IntrospectedClassFunction, IntrospectedDirectAllocationConstructor, IntrospectedStaticClassFunction } from "../gir/function.js"; +import { + IntrospectedClassFunction, + IntrospectedDirectAllocationConstructor, + IntrospectedStaticClassFunction +} from "../gir/function.js"; import { resolveTypeIdentifier } from "../gir/util.js"; import { GirVisitor } from "../visitor.js"; const filterIntrospectableClassMembers = (node: T): T => { - node.fields = node.fields.filter(field => field.isIntrospectable); - node.props = node.props.filter(prop => prop.isIntrospectable); - node.callbacks = node.callbacks.filter(prop => prop.isIntrospectable); - node.constructors = node.constructors.filter(prop => prop.isIntrospectable); - node.members = node.members.filter(prop => prop.isIntrospectable); + node.fields = node.fields.filter(field => field.isIntrospectable); + node.props = node.props.filter(prop => prop.isIntrospectable); + node.callbacks = node.callbacks.filter(prop => prop.isIntrospectable); + node.constructors = node.constructors.filter(prop => prop.isIntrospectable); + node.members = node.members.filter(prop => prop.isIntrospectable); - return node; + return node; }; const PROTECTED_FIELD_NAMES = ["parent_instance", "parent", "parent_class", "object_class"]; const filterProtectedFields = (node: T): T => { - const set = new Set(PROTECTED_FIELD_NAMES); + const set = new Set(PROTECTED_FIELD_NAMES); - node.fields = node.fields.filter(f => { - return !set.has(f.name); - }); + node.fields = node.fields.filter(f => { + return !set.has(f.name); + }); - return node; + return node; }; const filterConflictingNamedClassMembers = (node: T): T => { - // Props shadow members - node.members = node.members.filter(m => { - return !node.props.some(prop => prop.name === m.name && !(m instanceof IntrospectedStaticClassFunction)); - }); - - // Props and members shadow fields - node.fields = node.fields.filter( - f => - !node.members.some(n => n.name === f.name && !(n instanceof IntrospectedStaticClassFunction)) && - !node.props.some(n => n.name === f.name) - ); - - return node; + // Props shadow members + node.members = node.members.filter(m => { + return !node.props.some(prop => prop.name === m.name && !(m instanceof IntrospectedStaticClassFunction)); + }); + + // Props and members shadow fields + node.fields = node.fields.filter( + f => + !node.members.some(n => n.name === f.name && !(n instanceof IntrospectedStaticClassFunction)) && + !node.props.some(n => n.name === f.name) + ); + + return node; }; /** @@ -56,15 +60,15 @@ const filterConflictingNamedClassMembers = (nod * @returns */ const fixParamSpecSubtypes = (node: T): T => { - if (node.parent?.namespace === "GObject" && node.parent.name.startsWith("ParamSpec")) { - // We don't assert this import because we don't want to force libraries - // to unnecessarily import GObject. - node.parent = new TypeIdentifier("ParamSpec", "GObject"); + if (node.parent?.namespace === "GObject" && node.parent.name.startsWith("ParamSpec")) { + // We don't assert this import because we don't want to force libraries + // to unnecessarily import GObject. + node.parent = new TypeIdentifier("ParamSpec", "GObject"); - node.noEmit(); - } + node.noEmit(); + } - return node; + return node; }; /** @@ -76,17 +80,17 @@ const fixParamSpecSubtypes = (node: T): T => { * @param node */ const fixMissingParent = (node: T): T => { - const { namespace } = node; + const { namespace } = node; - if (node.parent == null) { - const isGObject = node.someParent(p => p.getType().is("GObject", "Object")); + if (node.parent == null) { + const isGObject = node.someParent(p => p.getType().is("GObject", "Object")); - if (isGObject) { - node.parent = namespace.assertInstalledImport("GObject").assertClass("Object").getType(); + if (isGObject) { + node.parent = namespace.assertInstalledImport("GObject").assertClass("Object").getType(); + } } - } - return node; + return node; }; /** @@ -97,50 +101,50 @@ const fixMissingParent = (node: T): T => { * @param node */ const removeComplexFields = (node: T): T => { - const { namespace } = node; + const { namespace } = node; - node.fields = node.fields.filter(f => { - let type = f.type.deepUnwrap(); + node.fields = node.fields.filter(f => { + const type = f.type.deepUnwrap(); - if (type instanceof NativeType) { - return true; - } + if (type instanceof NativeType) { + return true; + } - if (type instanceof TypeIdentifier) { - // Find the type for the identifier - const classNode = resolveTypeIdentifier(namespace, type); + if (type instanceof TypeIdentifier) { + // Find the type for the identifier + const classNode = resolveTypeIdentifier(namespace, type); - // Don't allow private or disguised fields - if (classNode && classNode.isPrivate) { - return false; - } + // Don't allow private or disguised fields + if (classNode && classNode.isPrivate) { + return false; + } - // Only allow fields pointing to simple structs. - if (classNode && classNode instanceof GirRecord && !classNode.isSimple()) { - return false; - } + // Only allow fields pointing to simple structs. + if (classNode && classNode instanceof IntrospectedRecord && !classNode.isSimple()) { + return false; + } - const en = namespace.assertInstalledImport(type.namespace).getEnum(type.name); + const en = namespace.assertInstalledImport(type.namespace).getEnum(type.name); - if (!(en instanceof IntrospectedError)) { - return true; - } + if (!(en instanceof IntrospectedError)) { + return true; + } - return false; - } + return false; + } - return true; - }); + return true; + }); - return node; + return node; }; const removePrivateFields = (node: T): T => { - node.fields = node.fields.filter(f => { - return !f.isPrivate && !f.name.startsWith("_"); - }); + node.fields = node.fields.filter(f => { + return !f.isPrivate && !f.name.startsWith("_"); + }); - return node; + return node; }; /** @@ -154,103 +158,102 @@ const removePrivateFields = (node: T): T => { * * @param node */ -const resolveMainConstructor = (node: GirRecord): GirRecord => { - const newConstructor = node.constructors.find(c => c.name === "new"); - const zeroArgsConstructor = node.constructors.find(c => c.parameters.length === 0); - const firstConstructor = node.constructors?.[0]; +const resolveMainConstructor = (node: IntrospectedRecord): IntrospectedRecord => { + const newConstructor = node.constructors.find(c => c.name === "new"); + const zeroArgsConstructor = node.constructors.find(c => c.parameters.length === 0); + const firstConstructor = node.constructors?.[0]; - if (node.isForeign()) { - node.mainConstructor = null; + if (node.isForeign()) { + node.mainConstructor = null; - return node; - } + return node; + } - if (zeroArgsConstructor || node.isSimpleWithoutPointers()) { - node.mainConstructor = - new IntrospectedDirectAllocationConstructor(node.fields); + if (zeroArgsConstructor || node.isSimpleWithoutPointers()) { + node.mainConstructor = new IntrospectedDirectAllocationConstructor(node.fields); - return node; - } + return node; + } - const resolvedConstructor = newConstructor ?? firstConstructor; - if (resolvedConstructor) { - node.mainConstructor = resolvedConstructor.copy(); - } + const resolvedConstructor = newConstructor ?? firstConstructor; + if (resolvedConstructor) { + node.mainConstructor = resolvedConstructor.copy(); + } - if (node.isSimple()) { - node.mainConstructor = new IntrospectedDirectAllocationConstructor(node.fields); + if (node.isSimple()) { + node.mainConstructor = new IntrospectedDirectAllocationConstructor(node.fields); - return node; - } + return node; + } - return node; + return node; }; const mergeStaticDefinitions = (node: IntrospectedClass): IntrospectedClass => { - if (!node.staticDefinition) { - return node; - } + if (!node.staticDefinition) { + return node; + } - const { namespace } = node; - const staticDefinition = namespace.getClass(node.staticDefinition); + const { namespace } = node; + const staticDefinition = namespace.getClass(node.staticDefinition); - if (!(staticDefinition instanceof GirRecord)) { - return node; - } - - const staticMethods = staticDefinition.members - .filter(m => m instanceof IntrospectedClassFunction) - .map(m => m.asStaticClassFunction(node)); - - for (const staticMethod of staticMethods) { - if ( - !node.members.some( - member => member.name === staticMethod.name && member instanceof IntrospectedStaticClassFunction - ) - ) { - node.members.push(staticMethod); + if (!(staticDefinition instanceof IntrospectedRecord)) { + return node; + } + + const staticMethods = staticDefinition.members + .filter(m => m instanceof IntrospectedClassFunction) + .map(m => m.asStaticClassFunction(node)); + + for (const staticMethod of staticMethods) { + if ( + !node.members.some( + member => member.name === staticMethod.name && member instanceof IntrospectedStaticClassFunction + ) + ) { + node.members.push(staticMethod); + } } - } - return node; + return node; }; function chainVisitors(node: T, ...args: ((node: T) => T)[]) { - let currentNode = node; + let currentNode = node; - for (const visitor of args) { - currentNode = visitor(currentNode); - } + for (const visitor of args) { + currentNode = visitor(currentNode); + } - return currentNode; + return currentNode; } export class ClassVisitor extends GirVisitor { - visitClass = (node: IntrospectedClass) => - chainVisitors( - node, - fixMissingParent, - fixParamSpecSubtypes, - removeComplexFields, - removePrivateFields, - mergeStaticDefinitions, - filterConflictingNamedClassMembers, - filterIntrospectableClassMembers, - filterProtectedFields - ); - - visitInterface = (node: GirInterface) => chainVisitors(node, filterIntrospectableClassMembers); - - visitRecord = (node: GirRecord) => - chainVisitors( - node, - fixMissingParent, - fixParamSpecSubtypes, - resolveMainConstructor, - removeComplexFields, - removePrivateFields, - filterConflictingNamedClassMembers, - filterIntrospectableClassMembers, - filterProtectedFields - ); + visitClass = (node: IntrospectedClass) => + chainVisitors( + node, + fixMissingParent, + fixParamSpecSubtypes, + removeComplexFields, + removePrivateFields, + mergeStaticDefinitions, + filterConflictingNamedClassMembers, + filterIntrospectableClassMembers, + filterProtectedFields + ); + + visitInterface = (node: IntrospectedInterface) => chainVisitors(node, filterIntrospectableClassMembers); + + visitRecord = (node: IntrospectedRecord) => + chainVisitors( + node, + fixMissingParent, + fixParamSpecSubtypes, + resolveMainConstructor, + removeComplexFields, + removePrivateFields, + filterConflictingNamedClassMembers, + filterIntrospectableClassMembers, + filterProtectedFields + ); } diff --git a/packages/lib/src/newlib/validators/interface.ts b/packages/lib/src/newlib/validators/interface.ts index 685b5fcc1..c4dddce76 100644 --- a/packages/lib/src/newlib/validators/interface.ts +++ b/packages/lib/src/newlib/validators/interface.ts @@ -1,20 +1,22 @@ -import { GirInterface } from "../gir/class.js"; +import { IntrospectedInterface } from "../gir/class.js"; import { GirVisitor } from "../visitor.js"; export class InterfaceVisitor extends GirVisitor { - visitInterface = (node: GirInterface): GirInterface => { + visitInterface = (node: IntrospectedInterface): IntrospectedInterface => { // If an interface does not list a prerequisite type, we fill it with GObject.Object if (!node.noParent && node.parent == null) { const gobject = node.namespace.assertInstalledImport("GObject"); const GObject = gobject.assertClass("Object"); if (!GObject) { - throw new Error(`GObject.Object could not be found while generating ${node.namespace.name}.${node.name}`); + throw new Error( + `GObject.Object could not be found while generating ${node.namespace.name}.${node.name}` + ); } node.parent = GObject.getType(); } return node; - } -} \ No newline at end of file + }; +} diff --git a/packages/lib/src/newlib/visitor.ts b/packages/lib/src/newlib/visitor.ts index 1c89e0e7f..9a44ba2ad 100644 --- a/packages/lib/src/newlib/visitor.ts +++ b/packages/lib/src/newlib/visitor.ts @@ -1,47 +1,49 @@ import { TypeExpression } from "./gir.js"; import { IntrospectedAlias } from "./gir/alias.js"; -import { GirRecord, GirInterface, IntrospectedClass } from "./gir/class.js"; +import { IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from "./gir/class.js"; import { IntrospectedConstant } from "./gir/const.js"; import { GirEnumMember, IntrospectedError, IntrospectedEnum } from "./gir/enum.js"; import { - IntrospectedCallback, - IntrospectedConstructor, - IntrospectedFunctionParameter, - IntrospectedFunction, - IntrospectedClassFunction, - IntrospectedStaticClassFunction, - IntrospectedVirtualClassFunction, - IntrospectedDirectAllocationConstructor + IntrospectedCallback, + IntrospectedConstructor, + IntrospectedFunctionParameter, + IntrospectedFunction, + IntrospectedClassFunction, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction, + IntrospectedDirectAllocationConstructor } from "./gir/function.js"; import { IntrospectedNamespace } from "./gir/namespace.js"; import { GirProperty, Field } from "./gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "./gir/signal.js"; export abstract class GirVisitor { - visitType?: (node: TypeExpression) => TypeExpression; - visitCallback?: (node: IntrospectedCallback) => IntrospectedCallback; - visitAlias?: (node: IntrospectedAlias) => IntrospectedAlias; - visitConstructor?: (node: IntrospectedConstructor) => IntrospectedConstructor; - visitDirectAllocationConstructor?: (node: IntrospectedDirectAllocationConstructor) => IntrospectedDirectAllocationConstructor; - visitConstructorFunction?: (node: IntrospectedConstructor) => IntrospectedConstructor; - visitRecord?: (node: GirRecord) => GirRecord; - visitInterface?: (node: GirInterface) => GirInterface; - visitEnumMember?: (node: GirEnumMember) => GirEnumMember; - visitError?: (node: IntrospectedError) => IntrospectedError; - visitEnum?: (node: IntrospectedEnum) => IntrospectedEnum; - visitConst?: (node: IntrospectedConstant) => IntrospectedConstant; - visitClass?: (node: IntrospectedClass) => IntrospectedClass; - visitParameter?: (node: IntrospectedFunctionParameter) => IntrospectedFunctionParameter; - visitProperty?: (node: GirProperty) => GirProperty; - visitField?: (node: Field) => Field; - visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal; - visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction; - visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction; - visitStaticClassFunction?: (node: IntrospectedStaticClassFunction) => IntrospectedStaticClassFunction; - visitVirtualClassFunction?: (node: IntrospectedVirtualClassFunction) => IntrospectedVirtualClassFunction; - visitNamespace?: (node: IntrospectedNamespace) => IntrospectedNamespace; + visitType?: (node: TypeExpression) => TypeExpression; + visitCallback?: (node: IntrospectedCallback) => IntrospectedCallback; + visitAlias?: (node: IntrospectedAlias) => IntrospectedAlias; + visitConstructor?: (node: IntrospectedConstructor) => IntrospectedConstructor; + visitDirectAllocationConstructor?: ( + node: IntrospectedDirectAllocationConstructor + ) => IntrospectedDirectAllocationConstructor; + visitConstructorFunction?: (node: IntrospectedConstructor) => IntrospectedConstructor; + visitRecord?: (node: IntrospectedRecord) => IntrospectedRecord; + visitInterface?: (node: IntrospectedInterface) => IntrospectedInterface; + visitEnumMember?: (node: GirEnumMember) => GirEnumMember; + visitError?: (node: IntrospectedError) => IntrospectedError; + visitEnum?: (node: IntrospectedEnum) => IntrospectedEnum; + visitConst?: (node: IntrospectedConstant) => IntrospectedConstant; + visitClass?: (node: IntrospectedClass) => IntrospectedClass; + visitParameter?: (node: IntrospectedFunctionParameter) => IntrospectedFunctionParameter; + visitProperty?: (node: GirProperty) => GirProperty; + visitField?: (node: Field) => Field; + visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal; + visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction; + visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction; + visitStaticClassFunction?: (node: IntrospectedStaticClassFunction) => IntrospectedStaticClassFunction; + visitVirtualClassFunction?: (node: IntrospectedVirtualClassFunction) => IntrospectedVirtualClassFunction; + visitNamespace?: (node: IntrospectedNamespace) => IntrospectedNamespace; } export function visit(namespace: IntrospectedNamespace, visitor: GirVisitor) { - namespace.accept(visitor); + namespace.accept(visitor); } diff --git a/packages/lib/src/types/gir-interface-element.ts b/packages/lib/src/types/gir-interface-element.ts index b0a383adc..60f9e007f 100644 --- a/packages/lib/src/types/gir-interface-element.ts +++ b/packages/lib/src/types/gir-interface-element.ts @@ -19,7 +19,7 @@ export interface GirInterfaceElement extends PartOfModule, parser.GirInterfaceEl prerequisite?: GirPrerequisite[] implements?: GirImplements[] function?: GirFunctionElement[] - constructors?: GirConstructorElement[] + constructor?: GirConstructorElement[] method?: GirMethodElement[] 'virtual-method'?: GirVirtualMethodElement[] field?: GirFieldElement[] diff --git a/packages/parser/src/xml.ts b/packages/parser/src/xml.ts index 0f826fdbf..57d770f40 100644 --- a/packages/parser/src/xml.ts +++ b/packages/parser/src/xml.ts @@ -125,7 +125,7 @@ export interface GirAliasElement extends GirInfoElements { export interface GirInterfaceElement extends GirInfoElements { /** Abstract interface to other classes */ - $: { + $: GirInfoAttrs & { //Attributes of an Interface (see definition below) /** name of the interface */ @@ -439,6 +439,8 @@ export interface GirCallbackElement extends GirInfoElements { "c:type"?: string; /** Binary attribute, true if the callback can throw an error */ throws?: GirBoolean; + // TODO: I believe callbacks have this as a valid property + "glib:type-name"?: string; }; /* Other elements a property can contain */ From d6e8f7e0d7fdab5394e6f7575f022303a22a98d8 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 6 Nov 2023 20:48:22 -0800 Subject: [PATCH 11/53] Rework ts-for-gir lib to use gi.ts parsing and transformations --- .ts-for-gir.gio.rc.js | 3 + packages/cli/src/commands/doc.ts | 5 +- packages/cli/src/commands/generate.ts | 28 +- packages/cli/src/config.ts | 2 + packages/cli/src/generation-handler.ts | 51 +- packages/cli/src/module-loader.ts | 2 +- packages/generator-base/src/generator.ts | 10 +- .../src/html-doc-generator.ts | 17 +- .../src/type-definition-generator.ts | 1816 +++++----- .../templates/package.json | 11 +- packages/lib/src/dependency-manager.ts | 2 + packages/lib/src/gir-module.ts | 2948 +++-------------- packages/lib/src/newlib/formatters/default.ts | 4 +- .../lib/src/newlib/formatters/formatter.ts | 2 +- packages/lib/src/newlib/formatters/json.ts | 4 +- .../lib/src/newlib/generators/dts-inline.ts | 9 +- .../lib/src/newlib/generators/dts-modules.ts | 26 +- packages/lib/src/newlib/generators/dts.ts | 51 +- .../lib/src/newlib/generators/generator.ts | 16 +- packages/lib/src/newlib/generators/json.ts | 66 +- packages/lib/src/newlib/generics/meta.ts | 4 +- packages/lib/src/newlib/generics/st.ts | 10 +- packages/lib/src/newlib/generics/visitor.ts | 18 +- packages/lib/src/newlib/gir.ts | 7 +- packages/lib/src/newlib/gir/alias.ts | 33 +- packages/lib/src/newlib/gir/base.ts | 70 +- packages/lib/src/newlib/gir/class.ts | 402 ++- packages/lib/src/newlib/gir/const.ts | 37 +- packages/lib/src/newlib/gir/enum.ts | 114 +- packages/lib/src/newlib/gir/function.ts | 387 ++- packages/lib/src/newlib/gir/namespace.ts | 513 +-- packages/lib/src/newlib/gir/nodes.ts | 60 +- packages/lib/src/newlib/gir/property.ts | 77 +- packages/lib/src/newlib/gir/registry.ts | 3 +- packages/lib/src/newlib/gir/signal.ts | 49 +- packages/lib/src/newlib/gir/util.ts | 9 +- packages/lib/src/newlib/injections/gio.ts | 14 +- packages/lib/src/newlib/injections/glib.ts | 4 + packages/lib/src/newlib/injections/gobject.ts | 18 +- packages/lib/src/newlib/lib.ts | 10 +- packages/lib/src/newlib/types.ts | 47 +- packages/lib/src/newlib/validators/class.ts | 12 +- .../lib/src/newlib/validators/interface.ts | 4 +- packages/lib/src/newlib/visitor.ts | 10 +- packages/lib/src/types/generate-config.ts | 4 + packages/lib/src/types/index.ts | 1 + 46 files changed, 2320 insertions(+), 4670 deletions(-) diff --git a/.ts-for-gir.gio.rc.js b/.ts-for-gir.gio.rc.js index c0141e040..bd10f825f 100644 --- a/.ts-for-gir.gio.rc.js +++ b/.ts-for-gir.gio.rc.js @@ -4,4 +4,7 @@ export default { girDirectories: ['./vala-girs/gir-1.0'], ignore: [], promisify: true, + verbose: true, + package: true, + outdir: './types', } diff --git a/packages/cli/src/commands/doc.ts b/packages/cli/src/commands/doc.ts index b62ee42a1..4a919d974 100644 --- a/packages/cli/src/commands/doc.ts +++ b/packages/cli/src/commands/doc.ts @@ -32,7 +32,7 @@ const handler = async (args: ConfigFlags) => { if (config.environments[i]) { const generateConfig = Config.getGenerateConfig(config, config.environments[i]) const moduleLoader = new ModuleLoader(generateConfig) - const { keep, grouped } = await moduleLoader.getModulesResolved( + const { keep } = await moduleLoader.getModulesResolved( config.modules, config.ignore || [], config.ignoreVersionConflicts, @@ -41,10 +41,11 @@ const handler = async (args: ConfigFlags) => { return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) } const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC) + const registry = moduleLoader.dependencyManager.registry await tsForGir.start( Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module), - Object.values(grouped), + registry, ) } } diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index db10c4f77..10a8aa2de 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -8,8 +8,10 @@ import { GeneratorType } from '@ts-for-gir/generator-base' import { GenerationHandler } from '../generation-handler.js' import { Config } from '../config.js' import { ModuleLoader } from '../module-loader.js' +import prettier from 'prettier' import type { ConfigFlags } from '@ts-for-gir/lib' +import { Formatter } from '@ts-for-gir/lib/lib/newlib/lib.js' const command = 'generate [modules..]' @@ -31,7 +33,7 @@ const handler = async (args: ConfigFlags) => { for (const env of config.environments) { const generateConfig = Config.getGenerateConfig(config, env) const moduleLoader = new ModuleLoader(generateConfig) - const { keep, grouped } = await moduleLoader.getModulesResolved( + const { keep } = await moduleLoader.getModulesResolved( config.modules, config.ignore || [], config.ignoreVersionConflicts, @@ -42,9 +44,10 @@ const handler = async (args: ConfigFlags) => { const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES) const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module) - const girModulesGrouped = Object.values(grouped) + // const girModulesGrouped = Object.values(grouped) - await tsForGir.start(girModules, girModulesGrouped) + moduleLoader.dependencyManager.registry.registerFormatter('dts', new TypeScriptFormatter()) + await tsForGir.start(girModules, moduleLoader.dependencyManager.registry) } } @@ -64,6 +67,25 @@ const examples: ReadonlyArray<[string, string?]> = [ ], ] +class TypeScriptFormatter extends Formatter { + format(input: string): Promise { + try { + return prettier.format(input, { + singleQuote: true, + parser: 'typescript', + printWidth: 120, + tabWidth: 4, + }) + } catch (error) { + return Promise.resolve(input) + // TODO: Don't return invalid TypeScript, useful for debugging for now. + // console.error('Failed to format output...') + // console.error(input) + // throw error + } + } +} + export const generate = { command, description, diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts index 393213cf8..d9e9703ad 100644 --- a/packages/cli/src/config.ts +++ b/packages/cli/src/config.ts @@ -331,6 +331,8 @@ export class Config { npmScope: config.npmScope, package: config.package, packageYarn: config.packageYarn, + noPrettyPrint: false, + noAdvancedVariants: true, } return generateConfig } diff --git a/packages/cli/src/generation-handler.ts b/packages/cli/src/generation-handler.ts index 5b7d70344..d8ef4a3b5 100644 --- a/packages/cli/src/generation-handler.ts +++ b/packages/cli/src/generation-handler.ts @@ -10,13 +10,14 @@ import { } from '@ts-for-gir/lib' import { GeneratorType, Generator } from '@ts-for-gir/generator-base' import { TypeDefinitionGenerator } from '@ts-for-gir/generator-typescript' -import { HtmlDocGenerator } from '@ts-for-gir/generator-html-doc' +// import { HtmlDocGenerator } from '@ts-for-gir/generator-html-doc' -import type { InheritanceTable, GenerateConfig, GirModulesGrouped } from '@ts-for-gir/lib' +import type { GenerateConfig, NSRegistry } from '@ts-for-gir/lib' export class GenerationHandler { log: Logger generator: Generator + constructor( private readonly config: GenerateConfig, type: GeneratorType, @@ -27,54 +28,46 @@ export class GenerationHandler { case GeneratorType.TYPES: this.generator = new TypeDefinitionGenerator(config) break - case GeneratorType.HTML_DOC: - this.generator = new HtmlDocGenerator(config) - break + // case GeneratorType.HTML_DOC: + // this.generator = new HtmlDocGenerator(config) + // break default: throw new Error('Unknown Generator') } } - private finalizeInheritance(inheritanceTable: InheritanceTable): void { - for (const clsName of Object.keys(inheritanceTable)) { - let p: string | string[] = inheritanceTable[clsName][0] - while (p) { - p = inheritanceTable[p] - if (p) { - p = p[0] - inheritanceTable[clsName].push(p) - } - } - } - } - - public async start(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]): Promise { + public async start(girModules: GirModule[], registry: NSRegistry): Promise { this.log.info(START_MODULE(this.config.environment, this.config.buildType)) if (girModules.length == 0) { this.log.error(ERROR_NO_MODULE_SPECIFIED) } - GirModule.allGirModules = girModules - this.log.info(FILE_PARSING_DONE) - const inheritanceTable: InheritanceTable = {} - for (const girModule of girModules) girModule.init(inheritanceTable) + this.log.info(TSDATA_PARSING_DONE) - this.finalizeInheritance(inheritanceTable) + if (this.config.outdir) { + await mkdir(this.config.outdir, { recursive: true }) + } - this.log.info(TSDATA_PARSING_DONE) + // TODO: Put this somewhere that makes sense + registry.transform({ + environment: 'gjs', + inferGenerics: true, + verbose: this.config.verbose, + }) + + await this.generator.start(registry) for (const girModule of girModules) { - if (this.config.outdir) { - await mkdir(this.config.outdir, { recursive: true }) - } this.log.log(` - ${girModule.packageName} ...`) girModule.start(girModules) + + await this.generator.generate(registry, girModule) } - await this.generator.start(girModules, girModulesGrouped, inheritanceTable) + await this.generator.finish(registry) this.log.success(GENERATING_TYPES_DONE) } diff --git a/packages/cli/src/module-loader.ts b/packages/cli/src/module-loader.ts index 04cff26a5..88fdbda8a 100644 --- a/packages/cli/src/module-loader.ts +++ b/packages/cli/src/module-loader.ts @@ -386,7 +386,7 @@ export class ModuleLoader { this.log.log(`Parsing ${dependency.path}...`) const fileContents = await readFile(dependency.path, 'utf8') const result = parser.parseGir(fileContents) - const girModule = new GirModule(result, this.config) + const girModule = GirModule.load(result, this.config, this.dependencyManager.registry) // Figure out transitive module dependencies this.extendDependencyMapByGirModule(girModule) return girModule diff --git a/packages/generator-base/src/generator.ts b/packages/generator-base/src/generator.ts index 26157392e..ce13cb8f6 100644 --- a/packages/generator-base/src/generator.ts +++ b/packages/generator-base/src/generator.ts @@ -1,9 +1,7 @@ -import type { InheritanceTable, GirModulesGrouped, GirModule } from '@ts-for-gir/lib' +import type { GirModule, NSRegistry } from '@ts-for-gir/lib' export interface Generator { - start( - girModules: GirModule[], - girModulesGrouped: GirModulesGrouped[], - inheritanceTable: InheritanceTable, - ): Promise + start(registry: NSRegistry): Promise + generate(registry: NSRegistry, module: GirModule): Promise + finish(registry: NSRegistry): Promise } diff --git a/packages/generator-html-doc/src/html-doc-generator.ts b/packages/generator-html-doc/src/html-doc-generator.ts index 8d626c26f..d262cf8f2 100644 --- a/packages/generator-html-doc/src/html-doc-generator.ts +++ b/packages/generator-html-doc/src/html-doc-generator.ts @@ -2,7 +2,7 @@ import { Logger, DANGER_HTML_DOC_GENERATOR_NOT_IMPLEMENTED } from '@ts-for-gir/lib' import { Generator } from '@ts-for-gir/generator-base' -import type { GenerateConfig, GirModulesGrouped, InheritanceTable, GirModule } from '@ts-for-gir/lib' +import type { GenerateConfig, GirModule, NSRegistry } from '@ts-for-gir/lib' /** * A template that can be used to implement an HTML Documentation Generator @@ -12,11 +12,16 @@ export class HtmlDocGenerator implements Generator { constructor(protected readonly config: GenerateConfig) { this.log = new Logger(config.environment, config.verbose, HtmlDocGenerator.name) } - public async start( - girModules: GirModule[], - girModulesGrouped: GirModulesGrouped[], - inheritanceTable: InheritanceTable, - ) { + + async start(_registry: NSRegistry): Promise { return Promise.resolve(this.log.danger(DANGER_HTML_DOC_GENERATOR_NOT_IMPLEMENTED)) } + + generate(_registry: NSRegistry, _module: GirModule): Promise { + throw new Error('Method not implemented.') + } + + finish(_registry: NSRegistry): Promise { + throw new Error('Method not implemented.') + } } diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 9eabc6d6f..764663e09 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -4,98 +4,228 @@ import { generateIndent, removeNamespace, removeClassModule, - girElementIsIntrospectable, - typesContainsOptional, - typesContainsNullable, Dependency, DependencyManager, NO_TSDATA, WARN_NOT_FOUND_DEPENDENCY_GIR_FILE, - WARN_IGNORE_MULTIPLE_CALLBACKS, - WARN_IGNORE_MULTIPLE_FUNC_DESC, + //WARN_IGNORE_MULTIPLE_CALLBACKS, + //WARN_IGNORE_MULTIPLE_FUNC_DESC, PackageData, + TypeExpression, + NSRegistry, + IntrospectedClass, + IntrospectedRecord, + IntrospectedInterface, + IntrospectedBaseClass, + IntrospectedField, + GirDirection, + TsDoc, + TsDocTag, + upperCamelCase, } from '@ts-for-gir/lib' import { TemplateProcessor } from './template-processor.js' import { PackageDataParser } from './package-data-parser.js' - -import type { +import { writeFile, mkdir } from 'fs/promises' +import { dirname } from 'path' +import { GenerateConfig, - GirClassElement, - GirCallableParamElement, - GirSignalElement, - GirEnumElement, - GirAliasElement, - GirInterfaceElement, - GirUnionElement, - GirModulesGrouped, - GirRecordElement, - GirBitfieldElement, - GirInstanceParameter, GirModule, - TsGenericParameter, - TsType, - TsDoc, - TsFunction, - TsCallback, - TsSignal, - TsMember, - TsVar, - TsProperty, - TsParameter, + IntrospectedFunction, + IntrospectedCallback, + IntrospectedSignal, + IntrospectedProperty, + IntrospectedConstant, } from '@ts-for-gir/lib' +import { + IntrospectedClassCallback, + IntrospectedClassFunction, + IntrospectedConstructor, + IntrospectedDirectAllocationConstructor, + IntrospectedFunctionParameter, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction, +} from '@ts-for-gir/lib/lib/newlib/gir/function.js' +import { IntrospectedNamespaceMember } from '@ts-for-gir/lib/lib/newlib/gir/base.js' +import { + FormatGenerator, + Generic, + GirEnumMember, + IntrospectedAlias, + IntrospectedEnum, + IntrospectedSignalType, + NativeType, +} from '@ts-for-gir/lib/lib/newlib/lib.js' +import { IntrospectedError } from '@ts-for-gir/lib/lib/newlib/gir/enum.js' +import { isInvalid } from '@ts-for-gir/lib/lib/newlib/gir/util.js' + +function printGirDocComment(tsDoc: TsDoc, config: GenerateConfig) { + const desc: string[] = [] + if (config.noComments) { + return desc.join('\n') + } -export class TypeDefinitionGenerator implements Generator { - protected log: Logger - protected dependencyManager: DependencyManager - protected packageData?: PackageDataParser + const text = tsDoc.text - /** Override config, used to override the config temporarily to generate both ESM and CJS for NPM packages */ - protected overrideConfig: Partial = {} + if (text) { + if (text) { + const lines = text.split('\n') + if (lines.length) { + for (const line of lines) { + desc.push(`${line}`) + } + } + } - /** Get the current config, including the override config */ - protected get config(): GenerateConfig { - return { ...this._config, ...this.overrideConfig } + for (const tag of tsDoc.tags) { + if (tag.paramName) { + desc.push(`@${tag.tagName} ${tag.paramName} ${tag.text}`) + } else { + desc.push(`@${tag.tagName} ${tag.text}`) + } + } } + return desc.join('\n') +} + +class ModuleGenerator extends FormatGenerator { + log: Logger + dependencyManager: DependencyManager + packageData?: PackageDataParser + + config: GenerateConfig + moduleTemplateProcessor: TemplateProcessor /** * @param _config The config to use without the override config */ - constructor(protected readonly _config: GenerateConfig) { + constructor(namespace: GirModule, config: GenerateConfig) { + super(namespace, config) + + this.config = config + this.log = new Logger(this.config.environment, this.config.verbose, TypeDefinitionGenerator.name) this.dependencyManager = DependencyManager.getInstance(this.config) if (this.config.package) { this.packageData = new PackageDataParser(this.config) } + const girModule = namespace + let pkgData: PackageData | undefined + if (this.packageData) { + pkgData = this.packageData.get(girModule.packageName) + } + this.moduleTemplateProcessor = new TemplateProcessor( + { + name: girModule.namespace, + namespace: girModule.namespace, + version: girModule.version, + importName: girModule.importName, + girModule, + pkgData, + registry: this.dependencyManager.registry, + }, + girModule.packageName, + girModule.transitiveDependencies, + this.config, + ) } - /** - * - * @param namespace E.g. 'Gtk' - * @param packageName E.g. 'Gtk-3.0' - * @param asExternType Currently only used for node type imports - */ - protected generateModuleDependenciesImport(packageName: string): string[] { - const def: string[] = [] - const dep = this.dependencyManager.get(packageName) + generateClassCallback(node: IntrospectedClassCallback): string[] { + return this.generateCallback(node) + } + generateConstructor(node: IntrospectedConstructor): string[] { + const Parameters = this.generateParameters(node.parameters) - // if (this.config.package) { - // if (this.config.buildType === 'types') { - // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html - // def.push(`/// `) - // } - // } else { - // if (this.config.buildType === 'types') { - // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html - // def.push(`/// `) - // } - // } + return [`constructor(${Parameters});`] + } + generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string[] { + const ConstructorFields = node.parameters.map((param) => param.asField().asString(this)).join('\n') + + return [ + ` + constructor(properties?: Partial<{ + ${ConstructorFields} + }>);`, + ] + } + protected generateParameters(parameters: IntrospectedFunctionParameter[]): string { + return parameters + .flatMap((p) => { + return p.asString(this) + }) + .join(', ') + } - def.push(dep.importDef) + generateConstructorFunction(node: IntrospectedConstructor): string[] { + const { namespace, options } = this + + const Parameters = this.generateParameters(node.parameters) + + const invalid = isInvalid(node.name) + const name = invalid ? `["${node.name}"]` : node.name + const warning = node.getWarning() + return [ + `${warning ? `${warning}\n` : ''}`, + ...this.addGirDocComment(node.doc), + `static ${name}(${Parameters}): ${node + .return() + .resolve(namespace, options) + .rootPrint(namespace, options)};`, + ] + } + generateRecord(node: IntrospectedRecord): string[] { + return this.generateClass(node) + } + generateInterface(node: IntrospectedInterface): string[] { + return this.generateImplementationInterface(node) + } + generateError(node: IntrospectedError): string[] { + const { namespace } = this + const clazz = node.asClass() + + clazz.members = [] + clazz.members.push(...Array.from(node.functions.values())) + + const GLib = namespace.assertInstalledImport('GLib') + const GLibError = GLib.assertClass('Error') + + clazz.superType = GLibError.getType() + + // Manually construct a GLib.Error constructor. + clazz.mainConstructor = new IntrospectedConstructor({ + name: 'new', + parent: clazz, + parameters: [ + new IntrospectedFunctionParameter({ + name: 'options', + type: NativeType.of('{ message: string, code: number}'), + direction: GirDirection.In, + }), + ], + return_type: clazz.getType(), + }) + + return clazz.asString(this) + } - return def + generateSignal(node: IntrospectedSignal, type: IntrospectedSignalType = IntrospectedSignalType.CONNECT): string[] { + switch (type) { + case IntrospectedSignalType.CONNECT: + return node.asConnect(false).asString(this) + case IntrospectedSignalType.CONNECT_AFTER: + return node.asConnect(true).asString(this) + case IntrospectedSignalType.EMIT: + return node.asEmit().asString(this) + } + } + + generateStaticClassFunction(node: IntrospectedStaticClassFunction): string[] { + return this.generateClassFunction(node) + } + generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): string[] { + return this.generateClassFunction(node) } - protected generateExport(type: string, name: string, definition: string, indentCount = 0) { + generateExport(type: string, name: string, definition: string, indentCount = 0) { const exp = !this.config.noNamespace ? '' : 'export ' const indent = generateIndent(indentCount) if (!definition.startsWith(':')) { @@ -104,44 +234,54 @@ export class TypeDefinitionGenerator implements Generator { return `${indent}${exp}${type} ${name}${definition}` } - protected generateProperty(tsProp: TsProperty, onlyStatic: boolean, namespace: string, indentCount = 0) { - if (!tsProp) { - throw new Error('[generateProperty] Not all required properties set!') - } + generateProperty(tsProp: IntrospectedProperty, construct?: boolean, indentCount = 0) { + const desc: string[] = [] + const isStatic = false //tsProp.isStatic + + // if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { + // return desc + // } + + desc.push(...this.addGirDocComment(tsProp.doc, [], indentCount)) + + const indent = generateIndent(indentCount) + const varDesc = this.generateVariable(tsProp) + const staticStr = isStatic ? 'static ' : '' + const readonly = !tsProp.writable ? 'readonly ' : '' + // temporary solution, will be solved differently later + const commentOut = '' + + desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`) + return desc + } + + generateField(tsProp: IntrospectedField, indentCount = 0) { const desc: string[] = [] - const isStatic = tsProp.isStatic + const isStatic = false //tsProp.isStatic - if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { - return desc - } + // if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { + // return desc + // } - if (!tsProp.hasUnresolvedConflict) { - desc.push(...this.addGirDocComment(tsProp.doc, indentCount)) - } + desc.push(...this.addGirDocComment(tsProp.doc, [], indentCount)) const indent = generateIndent(indentCount) - const varDesc = this.generateVariable(tsProp, namespace, 0, false) + const varDesc = this.generateVariable(tsProp, 0) const staticStr = isStatic ? 'static ' : '' - const readonly = tsProp.readonly ? 'readonly ' : '' + const readonly = !tsProp.writable ? 'readonly ' : '' // temporary solution, will be solved differently later - const commentOut = tsProp.hasUnresolvedConflict ? '// Has conflict: ' : '' + const commentOut = '' desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`) return desc } - protected generateProperties( - tsProps: TsProperty[], - onlyStatic: boolean, - namespace: string, - comment: string, - indentCount = 0, - ) { + generateProperties(tsProps: IntrospectedProperty[], comment: string, indentCount = 0) { const def: string[] = [] for (const tsProp of tsProps) { - def.push(...this.generateProperty(tsProp, onlyStatic, namespace, indentCount)) + def.push(...this.generateProperty(tsProp, false, indentCount)) } if (def.length > 0) { @@ -151,201 +291,162 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateVariableCallbackType(tsType: TsType, namespace: string) { - // The type of a callback is a functions definition + generateFields(tsProps: IntrospectedField[], comment: string, indentCount = 0) { + const def: string[] = [] + for (const tsProp of tsProps) { + def.push(...this.generateField(tsProp)) + } - let typeStr = 'any' + if (def.length > 0) { + def.unshift(...this.addInfoComment(comment, indentCount)) + } - const { callbacks } = tsType + return def + } - if (!callbacks.length) return typeStr + // generateVariableCallbackType(tsType: TypeExpression, namespace: string) { + // // The type of a callback is a functions definition - if (callbacks.length > 1) { - this.log.warn(WARN_IGNORE_MULTIPLE_CALLBACKS) - } + // let typeStr = 'any' - const girCallback = callbacks[0] + // const { callbacks } = tsType - if (!girCallback._tsData) { - throw new Error(NO_TSDATA('generateVariableCallbackType')) - } + // if (!callbacks.length) return typeStr - const funcDesc = this.generateFunction(girCallback._tsData, false, namespace, 0) + // if (callbacks.length > 1) { + // this.log.warn(WARN_IGNORE_MULTIPLE_CALLBACKS) + // } - if (girCallback._tsData && funcDesc?.length) { - if (funcDesc.length > 1) { - this.log.warn(WARN_IGNORE_MULTIPLE_FUNC_DESC) - } - typeStr = funcDesc[0] - } + // const girCallback = callbacks[0] - return typeStr - } + // if (!girCallback) { + // throw new Error(NO_TSDATA('generateVariableCallbackType')) + // } + + // const funcDesc = this.generateFunction(girCallback, false, namespace, 0) - protected generateVariable(tsVar: TsProperty | TsVar, namespace: string, indentCount = 0, allowCommentOut = true) { + // if (girCallback && funcDesc?.length) { + // if (funcDesc.length > 1) { + // this.log.warn(WARN_IGNORE_MULTIPLE_FUNC_DESC) + // } + // typeStr = funcDesc[0] + // } + + // return typeStr + // } + + generateVariable(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField, indentCount = 0) { const indent = generateIndent(indentCount) const name = tsVar.name // Constants are not optional - const optional = tsVar.tsTypeName !== 'constant' && typesContainsOptional(tsVar.type) - - if (!name) { + const optional = false + const invalid = isInvalid(name) + const Name = + invalid && (tsVar instanceof IntrospectedProperty || tsVar instanceof IntrospectedField) + ? `"${name}"` + : name + + if (!Name) { throw new Error('[generateVariable] "name" not set!') } + const ComputedName = 'computed' in tsVar && tsVar.computed ? `[${name}]` : Name + const affix = optional ? '?' : '' - const typeStr = this.generateTypes(tsVar.type, namespace) + const typeStr = this.generateTypes(tsVar.type) // temporary solution, will be solved differently later - const commentOut = allowCommentOut && tsVar.hasUnresolvedConflict ? '// Has conflict: ' : '' + // TODO: const commentOut = allowCommentOut && tsVar.hasUnresolvedConflict ? '// Has conflict: ' : '' + const commentOut = '' - return `${indent}${commentOut}${name}${affix}: ${typeStr}` + return `${indent}${commentOut}${ComputedName}${affix}: ${typeStr}` } - protected generateType(tsType: TsType, namespace: string, generateNullable = true) { - let typeName = removeNamespace(tsType.type, namespace) - - if (tsType.callbacks.length) { - typeName = this.generateVariableCallbackType(tsType, namespace) - } - - if (!typeName) { - throw new Error('[generateVariable] "typeName" not set!') - } - - let prefix = tsType.isArray ? '[]' : '' - if (generateNullable && tsType.nullable) { - prefix += ' | null' - } - - // We just use the generic values here - const genericStr = this.generateGenericValues(tsType, namespace) - - return `${typeName}${genericStr}${prefix}` + generateType(tsType: TypeExpression) { + return tsType.print(this.namespace, this.config) } - protected generateTypes(tsTypes: TsType[], namespace: string) { - let def = '' - for (const tsType of tsTypes) { - const separator = tsType.leftSeparator || '|' - const typeStr = this.generateType(tsType, namespace, false) - if (!def) { - def = typeStr - } else { - def += ` ${separator} ${typeStr}` - } - } - const hasNullable = typesContainsNullable(tsTypes) - if (hasNullable) { - if (tsTypes.length > 1) { - def = `(${def}) | null` - } else { - def += ' | null' - } - } - return def - } - - protected generateGenericValues(tsType: TsType, namespace: string) { - // We just use the generic values here - const genericValues = tsType.generics.map((g) => removeNamespace(g.value || '', namespace)).filter((g) => !!g) - const genericStr = tsType.generics.length ? `<${genericValues.join(', ')}>` : '' - return genericStr + generateTypes(tsTypes: TypeExpression) { + return tsTypes.print(this.namespace, this.config) } - /** - * Generates signals from all properties of a base class - * TODO: Build new `GirSignalElement`s in `gir-module.ts` instead of generate the strings directly - * @param girClass - * @param namespace - * @param indentCount - * @returns - */ - protected generateClassPropertySignals( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - indentCount = 1, - ) { - const def: string[] = [] - - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassPropertySignals')) - } - - if (girClass._tsData?.isDerivedFromGObject) { - if (girClass._tsData.propertySignalMethods.length > 0) { - def.push( - ...this.addInfoComment( - `Class property signals of ${girClass._module?.packageName}.${girClass._fullSymName}`, - indentCount, - ), - ) - for (const tsSignalMethod of girClass._tsData.propertySignalMethods) { - if (!tsSignalMethod) { - continue - } - def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount)) - } - } - } - return def - } - - protected generateInParameters( - inParams: GirCallableParamElement[], - instanceParameters: GirInstanceParameter[], - namespace: string, - ) { + // TODO: + // generateGenericValues(tsType: TypeExpression, namespace: string) { + // // We just use the generic values here + // const genericValues = tsType.generics.map((g) => removeNamespace(g.value || '', namespace)).filter((g) => !!g) + // const genericStr = tsType.generics.length ? `<${genericValues.join(', ')}>` : '' + // return genericStr + // } + + // /** + // * Generates signals from all properties of a base class + // * TODO: Build new `GirSignalElement`s in `gir-module.ts` instead of generate the strings directly + // * @param girClass + // * @param namespace + // * @param indentCount + // * @returns + // */ + // generateClassPropertySignals( + // girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, + // namespace: string, + // indentCount = 1, + // ) { + // const def: string[] = [] + + // const isDerivedFromGObject = girClass.someParent( + // (p: IntrospectedBaseClass) => p.namespace.name === 'GObject' && p.name === 'Object', + // ) + + // if (isDerivedFromGObject) { + // if (girClass.propertySignalMethods.length > 0) { + // def.push( + // ...this.addInfoComment( + // `Class property signals of ${girClass._module?.packageName}.${girClass.name}`, + // indentCount, + // ), + // ) + // for (const tsSignalMethod of girClass.propertySignalMethods) { + // if (!tsSignalMethod) { + // continue + // } + // def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount)) + // } + // } + // } + // return def + // } + + generateInParameters(inParams: IntrospectedFunctionParameter[]) { const inParamsDef: string[] = [] // TODO: Should use of a constructor, and even of an instance, be discouraged? - for (const instanceParameter of instanceParameters) { - if (instanceParameter._tsData) { - let { structFor } = instanceParameter._tsData - const { name } = instanceParameter._tsData - const gobject = namespace === 'GObject' || namespace === 'GLib' ? '' : 'GObject.' + // for (const instanceParameter of instanceParameters) { + // if (instanceParameter) { + // let { structFor } = instanceParameter + // const { name } = instanceParameter + // const gobject = namespace === 'GObject' || namespace === 'GLib' ? '' : 'GObject.' - structFor = removeNamespace(structFor, namespace) + // structFor = removeNamespace(structFor, namespace) - const returnTypes = [structFor, 'Function', `${gobject}GType`] - inParamsDef.push(`${name}: ${returnTypes.join(' | ')}`) - } - } + // const returnTypes = [structFor, 'Function', `${gobject}GType`] + // inParamsDef.push(`${name}: ${returnTypes.join(' | ')}`) + // } + // } for (const inParam of inParams) { - if (inParam._tsData) inParamsDef.push(...this.generateParameter(inParam._tsData, namespace)) + inParamsDef.push(...this.generateParameter(inParam)) } return inParamsDef } - protected generateSignals( - girSignals: GirSignalElement[], - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - indentCount = 0, - ) { - const def: string[] = [] - - for (const girSignal of girSignals) { - if (girSignal._tsData?.tsMethods?.length) { - for (const tsSignalMethod of girSignal._tsData?.tsMethods) { - if (!tsSignalMethod) { - continue - } - def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount)) - } - } - } - return def - } - /** * Adds documentation comments * @see https://github.com/microsoft/tsdoc * @param lines * @param indentCount */ - protected addTSDocCommentLines(lines: string[], indentCount = 0): string[] { + addTSDocCommentLines(lines: string[], indentCount = 0): string[] { const def: string[] = [] const indent = generateIndent(indentCount) def.push(`${indent}/**`) @@ -364,15 +465,14 @@ export class TypeDefinitionGenerator implements Generator { * @param overwriteDoc * @returns */ - protected addGirDocComment(tsDoc: TsDoc | undefined, indentCount = 0, overwriteDoc?: Partial) { + addGirDocComment(tsDoc: string | null | undefined, tags: TsDocTag[] = [], indentCount = 0) { const desc: string[] = [] const indent = generateIndent(indentCount) if (this.config.noComments) { return desc } - const text = overwriteDoc?.text || tsDoc?.text - const tags = overwriteDoc?.tags || tsDoc?.tags || [] + const text = tsDoc ? this.namespace.transformation.transformGirDocText(tsDoc) : null if (text) { desc.push(`${indent}/**`) @@ -404,7 +504,7 @@ export class TypeDefinitionGenerator implements Generator { * @param indentCount * @returns */ - protected addInfoComment(comment?: string, indentCount = 0) { + addInfoComment(comment?: string, indentCount = 0) { const def: string[] = [] if (this.config.noDebugComments) { return def @@ -424,7 +524,7 @@ export class TypeDefinitionGenerator implements Generator { * @param indentCount * @returns */ - protected addInlineInfoComment(comment?: string, indentCount = 0) { + addInlineInfoComment(comment?: string, indentCount = 0) { const def: string[] = [] if (this.config.noDebugComments) { return def @@ -436,7 +536,7 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected mergeDescs(descs: string[], comment?: string, indentCount = 1) { + mergeDescs(descs: string[], comment?: string, indentCount = 1) { const def: string[] = [] const indent = generateIndent(indentCount) @@ -451,17 +551,17 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateParameter(tsParam: TsParameter, namespace: string) { + generateParameter(tsParam: IntrospectedFunctionParameter) { if (typeof tsParam?.name !== 'string') { throw new Error(NO_TSDATA('generateParameter')) } const types = tsParam.type const name = tsParam.name - const typeStr = this.generateTypes(types, namespace) - const optional = typesContainsOptional(types) && !tsParam.isRest + const typeStr = this.generateTypes(types) + const optional = tsParam.isOptional && !tsParam.isVarArgs const affix = optional ? '?' : '' - const prefix = tsParam.isRest ? '...' : '' + const prefix = tsParam.isVarArgs ? '...' : '' return [`${prefix}${name}${affix}: ${typeStr}`] } @@ -472,112 +572,97 @@ export class TypeDefinitionGenerator implements Generator { * @param isOut If this generic parameters are out do only generate the type parameter names * @returns */ - protected generateGenericParameters(tsGenerics?: TsGenericParameter[], isOut = false) { - const desc: string[] = [] - if (!tsGenerics?.length) { - return '' - } + generateGenericParameters(nodes: Generic[], withDefaults = true) { + const { namespace, options } = this - for (const tsGeneric of tsGenerics) { - if (!tsGeneric.name) { - continue - } - let genericStr = `${tsGeneric.name}` - if (!isOut && tsGeneric.extends) { - genericStr += ` extends ${tsGeneric.extends}` - } - if (!isOut && tsGeneric.value) { - genericStr += ` = ${tsGeneric.value}` + const list = nodes.map((generic) => { + const Type = generic.type.rootPrint(namespace, options) + + if (generic.defaultType && withDefaults) { + const defaultType = generic.defaultType.rootPrint(namespace, options) + + if (generic.constraint) { + const constraint = generic.constraint.rootPrint(namespace, options) + return `${Type} extends ${constraint} = ${defaultType}` + } + + return `${Type} = ${defaultType}` + } else if (generic.constraint && withDefaults) { + const constraint = generic.constraint.rootPrint(namespace, options) + return `${Type} extends ${constraint}` + } else { + return `${Type}` } - desc.push(genericStr) + }) + + if (list.length > 0) { + return `<${list.join(', ')}>` } - return `<${desc.join(', ')}>` + return '' } - protected generateOutParameterReturn(girParam: GirCallableParamElement, namespace: string) { - const desc: string[] = [] + // generateOutParameterReturn(girParam: GirCallableParamElement, namespace: string) { + // const desc: string[] = [] - if (!girParam._tsData) { - this.log.warn(NO_TSDATA('generateOutParameterReturn')) - return desc - } + // if (!girParam) { + // this.log.warn(NO_TSDATA('generateOutParameterReturn')) + // return desc + // } - const { name } = girParam._tsData - const typeStr = this.generateTypes(girParam._tsData.type, namespace) + // const { name } = girParam + // const typeStr = this.generateTypes(girParam.type, namespace) - desc.push(`/* ${name} */ ${typeStr}`) - return desc - } + // desc.push(`/* ${name} */ ${typeStr}`) + // return desc + // } - protected generateFunctionReturn(tsFunction: TsFunction | TsCallback | TsSignal, namespace: string) { + generateFunctionReturn( + tsFunction: IntrospectedFunction | IntrospectedClassFunction | IntrospectedClassCallback | IntrospectedCallback, + ) { if (tsFunction.name === 'constructor') { return '' } - const overrideReturnType = tsFunction.overrideReturnType - const outParams = tsFunction.outParams - const retTypeIsVoid = tsFunction.retTypeIsVoid - const isPromise = tsFunction.isPromise || false - const typeStr = this.generateTypes(tsFunction.returnTypes, namespace) - - let desc = typeStr - - if (overrideReturnType) { - desc = removeNamespace(overrideReturnType, namespace) - } - // TODO: Transform the outParams to `tsFunction.returnTypes` to move this logic to `gir-module.ts` - else if (outParams.length + (retTypeIsVoid ? 0 : 1) > 1) { - const outParamsDesc: string[] = [] - - if (!retTypeIsVoid) { - outParamsDesc.push(`/* returnType */ ${typeStr}`) - } - - for (const outParam of outParams) { - outParamsDesc.push(...this.generateOutParameterReturn(outParam, namespace)) - } - - desc = outParamsDesc.join(', ') - desc = `[ ${desc} ]` - } else if (outParams.length === 1 && retTypeIsVoid) { - desc = this.generateOutParameterReturn(outParams[0], namespace).join(' ') - } + const typeStr = this.generateType(tsFunction.return()) - if (isPromise) { - desc = `globalThis.Promise<${desc}>` - } + return typeStr + } - return desc + generateClassFunction(node: IntrospectedClassFunction): string[] { + return this.generateFunction(node) } - protected generateFunction( - tsFunction: TsFunction | TsCallback | TsSignal | undefined, - /** If true only generate static functions otherwise generate only non static functions */ - onlyStatic: boolean, - namespace: string, - indentCount = 1, - overloads = true, + generateFunction( + tsFunction: IntrospectedClassFunction | IntrospectedFunction | IntrospectedCallback, + indentCount = 0, ) { const def: string[] = [] const indent = generateIndent(indentCount) - if (!tsFunction) { - this.log.warn(NO_TSDATA('generateFunction')) - return def - } - let { name } = tsFunction - const { isStatic } = tsFunction + const isStatic = tsFunction instanceof IntrospectedStaticClassFunction + const isGlobal = !(tsFunction instanceof IntrospectedClassFunction) + const isArrowType = + tsFunction instanceof IntrospectedCallback || tsFunction instanceof IntrospectedClassCallback - const { isArrowType, isGlobal, inParams, instanceParameters } = tsFunction + const { parameters: inParams } = tsFunction - if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { - return def - } + // if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { + // return def + // } - if (tsFunction.doc && !tsFunction.hasUnresolvedConflict) - def.push(...this.addGirDocComment(tsFunction.doc, indentCount)) + if (tsFunction.doc) + def.push( + ...this.addGirDocComment( + tsFunction.doc, + [ + ...this.namespace.getTsDocInParamTags(tsFunction.parameters), + ...this.namespace.getTsDocReturnTags(tsFunction), + ], + indentCount, + ), + ) const staticStr = isStatic && tsFunction.name !== 'constructor' ? 'static ' : '' @@ -585,7 +670,7 @@ export class TypeDefinitionGenerator implements Generator { const genericStr = this.generateGenericParameters(tsFunction.generics) // temporary solution, will be solved differently later - const commentOut = tsFunction.hasUnresolvedConflict ? '// Has conflict: ' : '' + const commentOut = '' let exportStr = '' // `tsType === 'function'` are a global methods which can be exported @@ -593,7 +678,7 @@ export class TypeDefinitionGenerator implements Generator { exportStr = !this.config.noNamespace ? '' : 'export ' } - const returnType = this.generateFunctionReturn(tsFunction, namespace) + const returnType = this.generateFunctionReturn(tsFunction) let retSep = '' if (returnType) { @@ -605,7 +690,7 @@ export class TypeDefinitionGenerator implements Generator { } } - const inParamsDef: string[] = this.generateInParameters(inParams, instanceParameters, namespace) + const inParamsDef: string[] = this.generateInParameters(inParams) def.push( `${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join( @@ -614,27 +699,25 @@ export class TypeDefinitionGenerator implements Generator { ) // Add overloaded methods - if (overloads && tsFunction.overloads.length > 0) { - def.push(...this.addInfoComment(`Overloads of ${name}`, indentCount)) - for (const func of tsFunction.overloads) { - def.push(...this.generateFunction(func, onlyStatic, namespace, indentCount, false)) - } - } + // if (overloads && tsFunction.overloads.length > 0) { + // def.push(...this.addInfoComment(`Overloads of ${name}`, indentCount)) + // for (const func of tsFunction.overloads) { + // def.push(...this.generateFunction(func, onlyStatic, namespace, indentCount, false)) + // } + // } return def } - protected generateFunctions( - tsFunctions: TsFunction[], - onlyStatic: boolean, - namespace: string, + generateFunctions( + tsFunctions: IntrospectedFunction[] | IntrospectedClassFunction[], indentCount = 1, comment?: string, ) { const def: string[] = [] for (const girFunction of tsFunctions) { - def.push(...this.generateFunction(girFunction, onlyStatic, namespace, indentCount)) + def.push(...this.generateFunction(girFunction, indentCount)) } if (def.length > 0) { @@ -644,34 +727,28 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateCallbackInterface( - tsCallback: TsCallback | TsSignal, - namespace: string, + generateCallback( + tsCallback: IntrospectedCallback | IntrospectedClassCallback, indentCount = 0, classModuleName?: string, ) { const def: string[] = [] - if (!tsCallback?.tsCallbackInterface) { - this.log.warn(NO_TSDATA('generateCallbackInterface')) - return def - } - - def.push(...this.addGirDocComment(tsCallback.doc, indentCount, tsCallback.tsCallbackInterface.overwriteDoc)) + def.push(...this.addGirDocComment(tsCallback.doc, [], indentCount)) const indent = generateIndent(indentCount) const indentBody = generateIndent(indentCount + 1) - const { inParams, instanceParameters } = tsCallback - const returnTypeStr = this.generateTypes(tsCallback.returnTypes, namespace) + const { parameters: inParams } = tsCallback + const returnTypeStr = this.generateTypes(tsCallback.return()) // Get name, remove namespace and remove module class name prefix - let { name } = tsCallback.tsCallbackInterface - const { generics } = tsCallback.tsCallbackInterface - name = removeNamespace(name, namespace) + let { name } = tsCallback + const generics = tsCallback.generics + name = removeNamespace(name, tsCallback.namespace.name) if (classModuleName) name = removeClassModule(name, classModuleName) const genericParameters = this.generateGenericParameters(generics) - const inParamsDef: string[] = this.generateInParameters(inParams, instanceParameters, namespace) + const inParamsDef: string[] = this.generateInParameters(inParams) const interfaceHead = `${name}${genericParameters}` @@ -682,9 +759,8 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateCallbackInterfaces( - tsCallbacks: Array, - namespace: string, + generateCallbackInterfaces( + tsCallbacks: Array, indentCount = 0, classModuleName: string, comment?: string, @@ -692,7 +768,7 @@ export class TypeDefinitionGenerator implements Generator { const def: string[] = [] for (const tsCallback of tsCallbacks) { - def.push(...this.generateCallbackInterface(tsCallback, namespace, indentCount, classModuleName), '') + def.push(...this.generateCallback(tsCallback, indentCount, classModuleName), '') } if (def.length > 0) { @@ -702,124 +778,109 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateEnumeration(girEnum: GirEnumElement | GirBitfieldElement, indentCount = 0) { + generateEnum(girEnum: IntrospectedEnum, indentCount = 0) { const desc: string[] = [] - if (!girElementIsIntrospectable(girEnum)) { - return desc - } - - if (!girEnum._tsData) { + if (!girEnum) { this.log.warn(NO_TSDATA('generateEnumeration')) return desc } - desc.push(...this.addGirDocComment(girEnum._tsData.doc, indentCount)) + desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount)) - const { name } = girEnum._tsData + const { name } = girEnum desc.push(this.generateExport('enum', name, '{', indentCount)) - if (girEnum.member) { - for (const girEnumMember of girEnum.member) { - if (!girEnumMember._tsData) continue - desc.push(...this.generateEnumerationMember(girEnumMember._tsData, indentCount + 1)) + if (girEnum.members) { + for (const girEnumMember of girEnum.members.values()) { + if (!girEnumMember) continue + desc.push(...this.generateEnumMember(girEnumMember, indentCount + 1)) } } desc.push('}') return desc } - protected generateEnumerationMember(tsMember: TsMember, indentCount = 1) { + generateEnumMember(tsMember: GirEnumMember, indentCount = 1) { const desc: string[] = [] - if (!tsMember) { - this.log.warn(NO_TSDATA('generateEnumerationMember')) - return desc - } + desc.push(...this.addGirDocComment(tsMember.doc, [], indentCount)) - desc.push(...this.addGirDocComment(tsMember.doc, indentCount)) + const invalid = isInvalid(tsMember.name) const indent = generateIndent(indentCount) - desc.push(`${indent}${tsMember.name},`) + if (invalid) { + desc.push(`${indent}"${tsMember.name}",`) + } else { + desc.push(`${indent}${tsMember.name},`) + } + return desc } - protected generateConstant(tsConst: TsVar, namespace: string, indentCount = 0) { + generateConst(tsConst: IntrospectedConstant, indentCount = 0) { const desc: string[] = [] - if (!tsConst.hasUnresolvedConflict) { - desc.push(...this.addGirDocComment(tsConst.doc, indentCount)) - } + // if (!tsConst.hasUnresolvedConflict) { + desc.push(...this.addGirDocComment(tsConst.doc, [], indentCount)) + // } const indent = generateIndent(indentCount) const exp = !this.config.noNamespace ? '' : 'export ' - const varDesc = this.generateVariable(tsConst, namespace, 0) + const varDesc = this.generateVariable(tsConst, 0) desc.push(`${indent}${exp}const ${varDesc}`) return desc } - protected generateAlias(girAlias: GirAliasElement, namespace: string, indentCount = 0) { + generateAlias(girAlias: IntrospectedAlias, indentCount = 0) { const desc: string[] = [] - if (!girElementIsIntrospectable(girAlias)) { - return '' - } - - if (!girAlias._tsData) { - this.log.warn(NO_TSDATA('generateAlias')) - return desc - } const indent = generateIndent(indentCount) const exp = !this.config.noNamespace ? '' : 'export ' - const type = removeNamespace(girAlias._tsData.type, namespace) - desc.push(`${indent}${exp}type ${girAlias._tsData.name} = ${type}`) + desc.push(`${indent}${exp}type ${girAlias.name} = ${girAlias.type.print(this.namespace, this.config)}`) return desc } - protected generateConstructPropsInterface( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, + generateConstructPropsInterface( + girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 0, ) { const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateConstructPropsInterface')) - } - - if (!girClass._tsData.isDerivedFromGObject) { + if (!girClass.someParent((p: IntrospectedBaseClass) => p.namespace.name === 'GObject' && p.name === 'Object')) { return def } const indent = generateIndent(indentCount) const exp = !this.config.noNamespace ? '' : 'export ' let ext = '' + const resolution = girClass.resolveParents() + const superType = resolution.node + const iSuperTypes = 'implements' in resolution ? resolution.implements() : [] - if (girClass._tsData.inheritConstructPropInterfaceNames.length) { - const constructPropInterfaceNames = girClass._tsData.inheritConstructPropInterfaceNames.map((n) => - removeNamespace(n, namespace), - ) - ext = `extends ${constructPropInterfaceNames.join(', ')} ` + if (superType || iSuperTypes.length > 0) { + ext = `extends ${[ + superType.getType().print(this.namespace, this.config), + ...iSuperTypes.map((i) => i.node.getType().print(this.namespace, this.config)), + ].join(', ')} ` } // Remove namespace and class module name const constructPropInterfaceName = removeClassModule( - removeNamespace(girClass._tsData.constructPropInterfaceName, namespace), - girClass._tsData.name, + removeNamespace(`${girClass.name}ConstructorProps`, girClass.namespace.name), + girClass.name, ) def.push(...this.addInfoComment('Constructor properties interface', indentCount)) // START BODY - { + if (girClass.mainConstructor) { def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext}{`) def.push( - ...this.generateProperties( - girClass._tsData.constructProps.map((cp) => cp._tsData).filter((cp) => !!cp) as TsProperty[], - false, - namespace, - `Own constructor properties of ${girClass._module.packageName}.${girClass._fullSymName}`, + ...this.generateFields( + girClass.mainConstructor.parameters.map((param) => param.asField()), + `Own constructor properties of ${girClass.namespace.packageName}.${girClass.name}`, indentCount + 1, ), ) @@ -830,23 +891,13 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateClassFields( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - onlyStatic: boolean, - namespace: string, - indentCount = 1, - ) { + generateClassFields(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1) { const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassFields')) - } def.push( - ...this.generateProperties( - girClass._tsData.fields.map((f) => f._tsData).filter((f) => !!f) as TsProperty[], - onlyStatic, - namespace, - `Own fields of ${girClass._module.packageName}.${girClass._fullSymName}`, + ...this.generateFields( + girClass.fields, + `Own fields of ${girClass.namespace.packageName}.${girClass.name}`, indentCount, ), ) @@ -854,34 +905,13 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateClassProperties( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - onlyStatic: boolean, - namespace: string, - indentCount = 1, - ) { + generateClassProperties(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1) { const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassProperties')) - } - - def.push( - ...this.generateProperties( - girClass._tsData.properties.map((p) => p._tsData).filter((p) => !!p) as TsProperty[], - onlyStatic, - namespace, - `Own properties of ${girClass._module.packageName}.${girClass._fullSymName}`, - indentCount, - ), - ) - def.push( ...this.generateProperties( - girClass._tsData.conflictProperties, - onlyStatic, - namespace, - `Conflicting properties`, + girClass.props, + `Own properties of ${girClass.namespace.packageName}.${girClass.name}`, indentCount, ), ) @@ -889,88 +919,73 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateClassMethods( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - onlyStatic: boolean, - namespace: string, + generateClassStaticMethods( + girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1, ) { const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassMethods')) - } - def.push( ...this.generateFunctions( - girClass._tsData.methods.map((girFunc) => girFunc._tsData).filter((tsFunc) => !!tsFunc) as TsFunction[], - onlyStatic, - namespace, + [...girClass.members].filter((member) => member instanceof IntrospectedStaticClassFunction), indentCount, - `Owm ${onlyStatic ? 'static ' : ''}methods of ${girClass._module.packageName}.${girClass._fullSymName}`, + `Owm methods of ${girClass.namespace.packageName}.${girClass.name}`, ), ) + return def + } + + generateClassMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1) { + const def: string[] = [] + def.push( ...this.generateFunctions( - girClass._tsData.conflictMethods, - onlyStatic, - namespace, + [...girClass.members].filter( + (member) => + !(member instanceof IntrospectedStaticClassFunction) && + !(member instanceof IntrospectedVirtualClassFunction), + ), indentCount, - `Conflicting ${onlyStatic ? 'static ' : ''}methods`, + `Owm methods of ${girClass.namespace.packageName}.${girClass.name}`, ), ) return def } - protected generateClassConstructors( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, + generateClassConstructors( + girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1, ) { const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassConstructors')) - } + // if (!girClass || !girClass.name || !girClass._module) { + // throw new Error(NO_TSDATA('generateClassConstructors')) + // } // Constructors - def.push( - ...this.generateFunctions( - girClass._tsData.constructors - .map((girFunc) => girFunc._tsData) - .filter((tsFunc) => !!tsFunc) as TsFunction[], - true, - namespace, - indentCount, - ), - ) + if (girClass.mainConstructor instanceof IntrospectedDirectAllocationConstructor) + def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor)) + else if (girClass.mainConstructor instanceof IntrospectedConstructor) + def.push(...this.generateConstructor(girClass.mainConstructor)) + // _init method - def.push( - ...this.generateFunctions( - girClass._tsData.constructors - .map((girFunc) => girFunc._tsData) - .filter((tsFunc) => !!tsFunc) as TsFunction[], - false, - namespace, - indentCount, - ), - ) - // Pseudo constructors - def.push( - ...this.generateFunctions( - girClass._tsData.staticFunctions - .map((girFunc) => girFunc._tsData) - .filter((tsFunc) => !!tsFunc) as TsFunction[], - true, - namespace, - indentCount, - ), - ) + def.push(...girClass.constructors.flatMap((constructor) => this.generateConstructorFunction(constructor))) + // // Pseudo constructors + // def.push( + // ...this.generateFunctions( + // girClass.staticFunctions + // .map((girFunc) => girFunc) + // .filter((tsFunc) => !!tsFunc) as IntrospectedFunction[], + // true, + // namespace, + // indentCount, + // ), + // ) if (def.length) { def.unshift( ...this.addInfoComment( - `Constructors of ${girClass._module.packageName}.${girClass._fullSymName}`, + `Constructors of ${girClass.namespace.packageName}.${girClass.name}`, indentCount, ), ) @@ -983,51 +998,43 @@ export class TypeDefinitionGenerator implements Generator { * Instance methods, vfunc_ prefix * @param girClass */ - protected generateClassVirtualMethods( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, + generateClassVirtualMethods( + girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1, ) { const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassVirtualMethods')) - } def.push( ...this.generateFunctions( - girClass._tsData.virtualMethods - .map((girFunc) => girFunc._tsData) - .filter((tsFunc) => !!tsFunc) as TsFunction[], - false, - namespace, + [...girClass.members.values()].filter((fn) => fn instanceof IntrospectedVirtualClassFunction), indentCount, - `Own virtual methods of ${girClass._module.packageName}.${girClass._fullSymName}`, + `Own virtual methods of ${girClass.namespace.packageName}.${girClass.name}`, ), ) return def } - protected generateClassSignalInterfaces( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - indentCount = 0, - ) { + generateClassSignalInterfaces(girClass: IntrospectedClass, indentCount = 0) { const def: string[] = [] - if (!girClass._tsData) { + if (!girClass) { throw new Error(NO_TSDATA('generateClassSignalInterface')) } - const tsSignals = girClass._tsData.signals - .map((signal) => signal._tsData) - .filter((signal) => !!signal) as TsSignal[] + const tsSignals = girClass.signals.map((signal) => signal).filter((signal) => !!signal) def.push( ...this.generateCallbackInterfaces( - tsSignals, - namespace, + tsSignals.map((signal) => { + return new IntrospectedClassCallback({ + name: upperCamelCase(signal.name), + parameters: signal.parameters, + return_type: signal.return_type, + parent: signal.parent, + }) + }), indentCount, - girClass._tsData.name, + girClass.name, 'Signal callback interfaces', ), ) @@ -1035,45 +1042,36 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected generateClassSignals( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - ) { - const def: string[] = [] - if (!girClass._tsData || !girClass._fullSymName || !girClass._module) { - throw new Error(NO_TSDATA('generateClassSignals')) - } + // generateClassSignals(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface) { + // const def: string[] = [] + // if (!girClass || !girClass.name || !girClass._module) { + // throw new Error(NO_TSDATA('generateClassSignals')) + // } - const signalDescs = this.generateSignals(girClass._tsData.signals, girClass, namespace, 0) + // const signalDescs = this.generateSignals(girClass, girClass, 0) - def.push( - ...this.mergeDescs( - signalDescs, - `Own signals of ${girClass._module.packageName}.${girClass._fullSymName}`, - 1, - ), - ) + // def.push( + // ...this.mergeDescs(signalDescs, `Own signals of ${girClass.namespace.packageName}.${girClass.name}`, 1), + // ) - return def - } + // return def + // } - protected generateClassModules( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - indentCount = 0, - ) { + generateClassModules(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 0) { const def: string[] = [] const bodyDef: string[] = [] - if (!girClass._tsData) return def + if (!girClass) return def const indent = generateIndent(indentCount) const exp = !this.config.noNamespace ? '' : 'export ' - // Signal interfaces - bodyDef.push(...this.generateClassSignalInterfaces(girClass, namespace, indentCount + 1)) + if ('signals' in girClass) { + // Signal interfaces + bodyDef.push(...this.generateClassSignalInterfaces(girClass, indentCount + 1)) + } // Properties interface for construction - bodyDef.push(...this.generateConstructPropsInterface(girClass, namespace, indentCount + 1)) + bodyDef.push(...this.generateConstructPropsInterface(girClass, indentCount + 1)) if (!bodyDef.length) { return [] @@ -1081,7 +1079,7 @@ export class TypeDefinitionGenerator implements Generator { // START BODY { - def.push(`${indent}${exp}module ${girClass._tsData.name} {`) + def.push(`${indent}${exp}module ${girClass.name} {`) // Properties interface for construction def.push(...bodyDef) @@ -1099,20 +1097,19 @@ export class TypeDefinitionGenerator implements Generator { * @param girClass * @param namespace */ - protected generateImplementationInterface( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - ) { + generateImplementationInterface(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface) { const def: string[] = [] - if (!girClass._tsData) return def + if (!girClass) return def - const genericParameters = this.generateGenericParameters(girClass._tsData.generics) - const implementationNames = girClass._tsData.parents - .filter((implementation) => implementation.type !== 'parent') - .map((implementation) => implementation.localParentName) + const genericParameters = this.generateGenericParameters(girClass.generics) + const resolution = girClass.resolveParents() + const implementationNames = + 'implements' in resolution + ? resolution.implements().map((i) => i.node.getType().print(this.namespace, this.config)) + : [] const ext = implementationNames.length ? ` extends ${implementationNames.join(', ')}` : '' - const interfaceHead = `${girClass._tsData.name}${genericParameters}${ext}` + const interfaceHead = `${girClass.name}${genericParameters}${ext}` // START INTERFACE { @@ -1121,22 +1118,25 @@ export class TypeDefinitionGenerator implements Generator { // START BODY { // Properties - def.push(...this.generateClassProperties(girClass, false, namespace)) + def.push(...this.generateClassProperties(girClass)) // Fields - def.push(...this.generateClassFields(girClass, false, namespace)) + def.push(...this.generateClassFields(girClass)) + + // Methods + // TODO def.push(...this.generateClassStaticMethods(girClass)) // Methods - def.push(...this.generateClassMethods(girClass, false, namespace)) + def.push(...this.generateClassMethods(girClass)) // Virtual methods - def.push(...this.generateClassVirtualMethods(girClass, namespace)) + def.push(...this.generateClassVirtualMethods(girClass)) // Signals - def.push(...this.generateClassSignals(girClass, namespace)) + // TODO: def.push(...this.generateClassSignals(girClass)) // TODO: Generate `GirSignalElement`s instead of generate the signal definition strings directly - def.push(...this.generateClassPropertySignals(girClass, namespace)) + // TODO: def.push(...this.generateClassPropertySignals(girClass)) } // END BODY @@ -1148,33 +1148,45 @@ export class TypeDefinitionGenerator implements Generator { return def } + protected extends(node: IntrospectedBaseClass) { + const { namespace: ns, options } = this + if (node.superType) { + const ResolvedType = node.superType.resolveIdentifier(ns, options) + const Type = ResolvedType?.print(ns, options) + + if (Type) { + return ` extends ${Type}` + } + + throw new Error( + `Unable to resolve type: ${node.superType.name} from ${node.superType.namespace} in ${node.namespace.name} ${node.namespace.version}`, + ) + } + + return '' + } + /** * Represents a record, GObject class or interface as a Typescript class * @param girClass * @param namespace */ - protected generateClass( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - namespace: string, - ) { + generateClass(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface) { const def: string[] = [] - if (!girClass._tsData) return def - - def.push(...this.generateClassModules(girClass, namespace)) + def.push(...this.generateClassModules(girClass)) - def.push(...this.generateImplementationInterface(girClass, namespace)) + // def.push(...this.generateImplementationInterface(girClass)) - def.push(...this.addGirDocComment(girClass._tsData.doc, 0)) + def.push(...this.addGirDocComment(girClass.doc, [], 0)) - const genericParameters = this.generateGenericParameters(girClass._tsData.generics) - const parentName = girClass._tsData.parents.find((parent) => parent.type === 'parent')?.localParentName - const ext = parentName ? ` extends ${parentName}` : '' - const classHead = `${girClass._tsData.name}${genericParameters}${ext}` + const genericParameters = this.generateGenericParameters(girClass.generics) + const ext = this.extends(girClass) + const classHead = `${girClass.name}${genericParameters}${ext}` // START CLASS { - if (girClass._tsData.isAbstract) { + if (girClass instanceof IntrospectedClass && girClass.isAbstract) { def.push(this.generateExport('abstract class', classHead, '{')) } else { def.push(this.generateExport('class', classHead, '{')) @@ -1183,16 +1195,19 @@ export class TypeDefinitionGenerator implements Generator { // START BODY { // Static Properties - def.push(...this.generateClassProperties(girClass, true, namespace)) + def.push(...this.generateClassProperties(girClass)) // Static Fields - def.push(...this.generateClassFields(girClass, true, namespace)) + def.push(...this.generateClassFields(girClass)) // Constructors - def.push(...this.generateClassConstructors(girClass, namespace)) + def.push(...this.generateClassConstructors(girClass)) + + // Methods + def.push(...this.generateClassStaticMethods(girClass)) // Static Methods - def.push(...this.generateClassMethods(girClass, true, namespace)) + def.push(...this.generateClassMethods(girClass)) } // END BODY @@ -1204,20 +1219,16 @@ export class TypeDefinitionGenerator implements Generator { return def } - protected async exportModuleJS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise { - const template = 'module.js' - let target = `${girModule.importName}.js` + async stringifyNamespace(node: GirModule): Promise { + return (await this.generateNamespace(node))?.join('\n') ?? null + } - if (this.overrideConfig.moduleType) { - if (this.overrideConfig.moduleType === 'cjs') { - target = `${girModule.importName}.cjs` - } else { - target = `${girModule.importName}.mjs` - } - } + async exportModuleJS(girModule: GirModule): Promise { + const template = 'module.js' + const target = `${girModule.importName}.js` if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, target, @@ -1227,28 +1238,17 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportModuleAmbientTS( - moduleTemplateProcessor: TemplateProcessor, - girModule: GirModule, - ): Promise { + async exportModuleAmbientTS(girModule: GirModule): Promise { const template = 'module-ambient.d.ts' - let target = `${girModule.importName}-ambient.d.ts` - - if (this.overrideConfig.moduleType) { - if (this.overrideConfig.moduleType === 'cjs') { - target = `${girModule.importName}-ambient.d.cts` - } else { - target = `${girModule.importName}-ambient.d.mts` - } - } + const target = `${girModule.importName}-ambient.d.ts` if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, target, @@ -1258,28 +1258,17 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportModuleAmbientJS( - moduleTemplateProcessor: TemplateProcessor, - girModule: GirModule, - ): Promise { + protected async exportModuleAmbientJS(girModule: GirModule): Promise { const template = 'module-ambient.js' - let target = `${girModule.importName}-ambient.js` - - if (this.overrideConfig.moduleType) { - if (this.overrideConfig.moduleType === 'cjs') { - target = `${girModule.importName}-ambient.cjs` - } else { - target = `${girModule.importName}-ambient.mjs` - } - } + const target = `${girModule.importName}-ambient.js` if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, target, @@ -1289,28 +1278,17 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportModuleImportTS( - moduleTemplateProcessor: TemplateProcessor, - girModule: GirModule, - ): Promise { + protected async exportModuleImportTS(girModule: GirModule): Promise { const template = 'module-import.d.ts' - let target = `${girModule.importName}-import.d.ts` - - if (this.overrideConfig.moduleType) { - if (this.overrideConfig.moduleType === 'cjs') { - target = `${girModule.importName}-import.d.cts` - } else { - target = `${girModule.importName}-import.d.mts` - } - } + const target = `${girModule.importName}-import.d.ts` if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, target, @@ -1320,28 +1298,17 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportModuleImportJS( - moduleTemplateProcessor: TemplateProcessor, - girModule: GirModule, - ): Promise { + protected async exportModuleImportJS(girModule: GirModule): Promise { const template = 'module-import.js' - let target = `${girModule.importName}-import.js` - - if (this.overrideConfig.moduleType) { - if (this.overrideConfig.moduleType === 'cjs') { - target = `${girModule.importName}-import.cjs` - } else { - target = `${girModule.importName}-import.mjs` - } - } + const target = `${girModule.importName}-import.js` if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, target, @@ -1351,24 +1318,87 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportModuleTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise { + async exportModuleTS(): Promise { + const { namespace: girModule } = this + const output = await this.generateNamespace(girModule) + + if (!output) { + this.log.error('Failed to generate') + return + } + + // const template = 'module.d.ts' + // const explicitTemplate = `${girModule.importName}.d.ts` + + const target = `${girModule.importName}.d.ts` + + const formatter = this.dependencyManager.registry.getFormatter('dts') + + let contents!: string + try { + contents = this.config.noPrettyPrint ? output.join('\n') : await formatter.format(output.join('\n')) + } catch (error) { + console.error(error) + contents = output.join('\n') + } + + if (this.config.outdir) { + const outputPath = this.moduleTemplateProcessor.getOutputPath(this.config.outdir, target) + console.log(outputPath, target) + // write template result file + await mkdir(dirname(outputPath), { recursive: true }) + await writeFile(outputPath, contents, { encoding: 'utf8', flag: 'w' }) + } else { + this.log.log(contents) + } + } + + /** + * + * @param namespace E.g. 'Gtk' + * @param packageName E.g. 'Gtk-3.0' + * @param asExternType Currently only used for node type imports + */ + protected generateModuleDependenciesImport(packageName: string): string[] { + const def: string[] = [] + const dep = this.dependencyManager.get(packageName) + + // if (this.config.package) { + // if (this.config.buildType === 'types') { + // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html + // def.push(`/// `) + // } + // } else { + // if (this.config.buildType === 'types') { + // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html + // def.push(`/// `) + // } + // } + + def.push(dep.importDef) + + return def + } + + async generateNamespace(girModule: GirModule): Promise { + const moduleTemplateProcessor = this.moduleTemplateProcessor const template = 'module.d.ts' const explicitTemplate = `${girModule.importName}.d.ts` - let target = `${girModule.importName}.d.ts` + // let target = `${girModule.importName}.d.ts` - if (this.overrideConfig.moduleType) { - if (this.overrideConfig.moduleType === 'cjs') { - target = `${girModule.importName}.d.cts` - } else { - target = `${girModule.importName}.d.mts` - } - } + // if (this.overrideConfig.moduleType) { + // if (this.overrideConfig.moduleType === 'cjs') { + // target = `${girModule.importName}.d.cts` + // } else { + // target = `${girModule.importName}.d.mts` + // } + // } const out: string[] = [] @@ -1404,138 +1434,73 @@ export class TypeDefinitionGenerator implements Generator { // Newline out.push('') - if (girModule.ns.enumeration) - for (const girEnum of girModule.ns.enumeration) out.push(...this.generateEnumeration(girEnum)) - - if (girModule.ns.bitfield) - for (const girBitfield of girModule.ns.bitfield) out.push(...this.generateEnumeration(girBitfield)) - - if (girModule.ns.constant) - for (const girConst of girModule.ns.constant) { - if (!girConst._tsData) continue - out.push(...this.generateConstant(girConst._tsData, girModule.namespace, 0)) - } - - if (girModule.ns.function) - for (const girFunc of girModule.ns.function) { - if (!girFunc._tsData) { - // this.log.warn(NO_TSDATA('exportModuleTS functions')) - continue - } - out.push(...this.generateFunction(girFunc._tsData, false, girModule.namespace, 0)) - } - - if (girModule.ns.callback) - for (const girCallback of girModule.ns.callback) { - if (!girCallback._tsData) continue - out.push(...this.generateCallbackInterface(girCallback._tsData, girModule.namespace)) - } - - if (girModule.ns.interface) - for (const girIface of girModule.ns.interface) - if (girIface._module) { - out.push(...this.generateClass(girIface, girIface._module.namespace)) - } + if (girModule.members) + for (const m of girModule.members.values()) + out.push( + ...(Array.isArray(m) ? m : [m]).flatMap( + (m) => (m as IntrospectedNamespaceMember).asString(this as FormatGenerator) ?? [], + ), + ) // Extra interfaces if a template with the module name (e.g. '../templates/gobject-2-0.d.ts') is found // E.g. used for GObject-2.0 to help define GObject classes in js; // these aren't part of gi. if (moduleTemplateProcessor.exists(explicitTemplate)) { - const { append, prepend } = await moduleTemplateProcessor.load(explicitTemplate, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(explicitTemplate, {}, this.config) // TODO push prepend and append to the right position out.push(append + prepend) } - if (girModule.ns.class) - for (const gitClass of girModule.ns.class) - if (gitClass._module) { - out.push(...this.generateClass(gitClass, gitClass._module.namespace)) - } - - if (girModule.ns.record) - for (const girRecord of girModule.ns.record) - if (girRecord._module) { - out.push(...this.generateClass(girRecord, girRecord._module.namespace)) - } - - if (girModule.ns.union) - for (const girUnion of girModule.ns.union) - if (girUnion._module) { - out.push(...this.generateClass(girUnion, girUnion._module.namespace)) - } - - if (girModule.ns.alias) - // GType is not a number in GJS - for (const girAlias of girModule.ns.alias) - if (girModule.packageName !== 'GObject-2.0' || girAlias.$.name !== 'Type') - out.push(...this.generateAlias(girAlias, girModule.namespace, 1)) - if (this.config.environment === 'gjs') { // Properties added to every GIRepositoryNamespace // https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L186-190 out.push( - ...this.generateConstant( - { - doc: { - text: 'Name of the imported GIR library', - tags: [ - { - text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188', - tagName: 'see', - paramName: '', - }, - ], - }, - name: '__name__', - type: [ + ...this.generateConst( + new IntrospectedConstant({ + // TODO: + doc: printGirDocComment( { - type: 'string', - optional: false, - nullable: false, - callbacks: [], - generics: [], - isArray: false, - isFunction: false, - isCallback: false, + text: 'Name of the imported GIR library', + tags: [ + { + text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188', + tagName: 'see', + paramName: '', + }, + ], }, - ], - isInjected: false, - tsTypeName: 'constant', - girTypeName: 'constant', - }, - girModule.namespace, + this.config, + ), + namespace: this.namespace, + value: null, + name: '__name__', + type: new NativeType('string'), + // isInjected: false, + // tsTypeName: 'constant', + // girTypeName: 'constant', + }), 0, ), - ...this.generateConstant( - { - doc: { - text: 'Version of the imported GIR library', - tags: [ - { - text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189', - tagName: 'see', - paramName: '', - }, - ], - }, - name: '__version__', - type: [ + ...this.generateConst( + new IntrospectedConstant({ + doc: printGirDocComment( { - type: 'string', - optional: false, - nullable: false, - callbacks: [], - generics: [], - isArray: false, - isFunction: false, - isCallback: false, + text: 'Version of the imported GIR library', + tags: [ + { + text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189', + tagName: 'see', + paramName: '', + }, + ], }, - ], - isInjected: false, - tsTypeName: 'constant', - girTypeName: 'constant', - }, - girModule.namespace, + this.config, + ), + namespace: this.namespace, + name: '__version__', + type: new NativeType('string'), + value: null, + }), 0, ), ) @@ -1548,27 +1513,22 @@ export class TypeDefinitionGenerator implements Generator { out.push(`export default ${girModule.namespace};`) } - const outResult = out.join('\n') // End of file + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) - if (this.config.outdir) { - await moduleTemplateProcessor.create(template, this.config.outdir, target, true, outResult, {}, this.config) - } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) - this.log.log(append + '\n' + outResult + prepend) - } + return [prepend, ...out, append] } - protected async exportNPMPackage(moduleTemplateProcessor: TemplateProcessor, girModuleImportName: string) { - await this.exportNPMPackageJson(moduleTemplateProcessor) - await this.exportNPMReadme(moduleTemplateProcessor, girModuleImportName) - await this.exportTSConfig(moduleTemplateProcessor) - await this.exportTypeDoc(moduleTemplateProcessor) + async exportNPMPackage(girModuleImportName: string) { + await this.exportNPMPackageJson() + await this.exportNPMReadme(girModuleImportName) + await this.exportTSConfig() + await this.exportTypeDoc() } - protected async exportNPMPackageJson(moduleTemplateProcessor: TemplateProcessor) { + async exportNPMPackageJson() { const template = 'package.json' if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, template, // output filename @@ -1578,22 +1538,22 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportNPMReadme(moduleTemplateProcessor: TemplateProcessor, girModuleImportName: string) { + async exportNPMReadme(girModuleImportName: string) { // E.g. `README-GJS.md` or `README-GTK-4.0.md` let template = girModuleImportName ? `README-${girModuleImportName.toUpperCase()}.md` : 'README.md' const outputFilename = 'README.md' - if (!moduleTemplateProcessor.exists(template)) { + if (!this.moduleTemplateProcessor.exists(template)) { template = 'README.md' } if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, outputFilename, @@ -1603,15 +1563,15 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportTSConfig(moduleTemplateProcessor: TemplateProcessor) { + async exportTSConfig() { const template = 'tsconfig.json' if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, template, // output filename @@ -1621,15 +1581,15 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportTypeDoc(moduleTemplateProcessor: TemplateProcessor) { + async exportTypeDoc() { const template = 'typedoc.json' if (this.config.outdir) { - await moduleTemplateProcessor.create( + await this.moduleTemplateProcessor.create( template, this.config.outdir, template, // output filename @@ -1639,99 +1599,103 @@ export class TypeDefinitionGenerator implements Generator { this.config, ) } else { - const { append, prepend } = await moduleTemplateProcessor.load(template, {}, this.config) + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) this.log.log(append + prepend) } } - protected async exportModule( - girModule: GirModule, - girModules: GirModule[], - girModulesGrouped: GirModulesGrouped[], - ) { - let pkgData: PackageData | undefined - if (this.packageData) { - pkgData = this.packageData.get(girModule.packageName) + async exportModule(registry: NSRegistry, girModule: GirModule) { + // let pkgData: PackageData | undefined + // if (this.packageData) { + // pkgData = this.packageData.get(girModule.packageName) + // } + // const moduleTemplateProcessor = new TemplateProcessor( + // { + // name: girModule.namespace, + // namespace: girModule.namespace, + // version: girModule.version, + // importName: girModule.importName, + // girModule, + // girModules, + // girModulesGrouped, + // pkgData, + // }, + // girModule.packageName, + // girModule.transitiveDependencies, + // this.config, + // ) + + await this.exportModuleTS() + if (this.config.buildType === 'lib') { + await this.exportModuleJS(girModule) } - const moduleTemplateProcessor = new TemplateProcessor( - { - name: girModule.namespace, - namespace: girModule.namespace, - version: girModule.version, - importName: girModule.importName, - girModule, - girModules, - girModulesGrouped, - pkgData, - }, - girModule.packageName, - girModule.transitiveDependencies, - this.config, - ) - await this.exportModuleTS(moduleTemplateProcessor, girModule) + await this.exportModuleAmbientTS(girModule) if (this.config.buildType === 'lib') { - await this.exportModuleJS(moduleTemplateProcessor, girModule) + await this.exportModuleAmbientJS(girModule) } - if (this.config.environment === 'gjs') { - await this.exportModuleAmbientTS(moduleTemplateProcessor, girModule) - - if (this.config.buildType === 'lib') { - await this.exportModuleAmbientJS(moduleTemplateProcessor, girModule) - } - } - await this.exportModuleImportTS(moduleTemplateProcessor, girModule) + await this.exportModuleImportTS(girModule) if (this.config.buildType === 'lib') { - await this.exportModuleImportJS(moduleTemplateProcessor, girModule) + await this.exportModuleImportJS(girModule) } if (this.config.package) { - this.setOverrideConfigForOtherModuleType() - await this.exportModuleTS(moduleTemplateProcessor, girModule) - if (this.config.buildType === 'lib') { - await this.exportModuleJS(moduleTemplateProcessor, girModule) - } - this.resetOverrideConfig() + await this.exportNPMPackage(girModule.importName) } + } +} + +export class TypeDefinitionGenerator implements Generator { + log: Logger + dependencyManager: DependencyManager + packageData?: PackageDataParser + module!: ModuleGenerator + + /** + * @param _config The config to use without the override config + */ + constructor(readonly config: GenerateConfig) { + this.log = new Logger(this.config.environment, this.config.verbose, TypeDefinitionGenerator.name) + this.dependencyManager = DependencyManager.getInstance(this.config) if (this.config.package) { - await this.exportNPMPackage(moduleTemplateProcessor, girModule.importName) + this.packageData = new PackageDataParser(this.config) } } /** - * We build both module types if we build an NPM package, - * so we need to switch the module type and use the default noNamespace value for the module type + * + * @param namespace E.g. 'Gtk' + * @param packageName E.g. 'Gtk-3.0' + * @param asExternType Currently only used for node type imports */ - protected setOverrideConfigForOtherModuleType() { - if (this.config.moduleType === 'esm') { - this.overrideConfig.moduleType = 'cjs' - this.overrideConfig.noNamespace = true - } else { - this.overrideConfig.moduleType = 'esm' - this.overrideConfig.noNamespace = false - } - } + generateModuleDependenciesImport(packageName: string): string[] { + const def: string[] = [] + const dep = this.dependencyManager.get(packageName) - protected resetOverrideConfig() { - this.overrideConfig = {} + // if (this.config.package) { + // if (this.config.buildType === 'types') { + // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html + // def.push(`/// `) + // } + // } else { + // if (this.config.buildType === 'types') { + // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html + // def.push(`/// `) + // } + // } + + def.push(dep.importDef) + + return def } - protected async exportGjs( - dependencies: Dependency[], - girModules: GirModule[], - girModulesGrouped: GirModulesGrouped[], - ) { + async exportGjs(dependencies: Dependency[], registry: NSRegistry) { if (!this.config.outdir) return const packageName = 'Gjs' - const templateProcessor = new TemplateProcessor( - { girModules: girModules, girModulesGrouped }, - packageName, - dependencies, - this.config, - ) + const templateProcessor = new TemplateProcessor(registry, packageName, dependencies, this.config) // TS await templateProcessor.create('gjs.d.ts', this.config.outdir, 'gjs.d.ts') @@ -1747,89 +1711,6 @@ export class TypeDefinitionGenerator implements Generator { await templateProcessor.create('cairo.js', this.config.outdir, 'cairo.js') } - // If you build an NPM package, we also build the Gjs module for the other module type - if (this.config.package) { - this.setOverrideConfigForOtherModuleType() - // TS - await templateProcessor.create( - 'gjs.d.ts', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'gjs.d.cts' : 'gjs.d.mts', - undefined, - undefined, - undefined, - this.config, - ) - await templateProcessor.create( - 'gettext.d.ts', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'gettext.d.cts' : 'gettext.d.mts', - undefined, - undefined, - undefined, - this.config, - ) - await templateProcessor.create( - 'system.d.ts', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'system.d.cts' : 'system.d.mts', - undefined, - undefined, - undefined, - this.config, - ) - await templateProcessor.create( - 'cairo.d.ts', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'cairo.d.cts' : 'cairo.d.mts', - undefined, - undefined, - undefined, - this.config, - ) - - // JS - if (this.config.buildType === 'lib') { - await templateProcessor.create( - 'gjs.js', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'gjs.cjs' : 'gjs.mjs', - undefined, - undefined, - undefined, - this.config, - ) - await templateProcessor.create( - 'gettext.js', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'gettext.cjs' : 'gettext.mjs', - undefined, - undefined, - undefined, - this.config, - ) - await templateProcessor.create( - 'system.js', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'system.cjs' : 'system.mjs', - undefined, - undefined, - undefined, - this.config, - ) - await templateProcessor.create( - 'cairo.js', - this.config.outdir, - this.overrideConfig.moduleType === 'cjs' ? 'cairo.cjs' : 'cairo.mjs', - undefined, - undefined, - undefined, - this.config, - ) - } - this.resetOverrideConfig() - } - // Import ambient types await templateProcessor.create('ambient.d.ts', this.config.outdir, 'ambient.d.ts') if (this.config.buildType === 'lib') { @@ -1855,24 +1736,27 @@ export class TypeDefinitionGenerator implements Generator { // Package if (this.config.package) { - await this.exportNPMPackage(templateProcessor, 'Gjs') + await this.module.exportNPMPackage('Gjs') } } - public async start(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[] = []) { - this.dependencyManager.addAll(girModules) + public async generate(registry: NSRegistry, module: GirModule) { + this.module = new ModuleGenerator(module, this.config) + await this.module.exportModuleTS() + } + + public async start() { + // this.dependencyManager.addAll(girModules) if (this.config.package && this.packageData) { await this.packageData.start() } + } - for (const girModule of girModules) { - await this.exportModule(girModule, girModules, girModulesGrouped) - } - + public async finish(registry: NSRegistry) { if (this.config.environment === 'gjs') { // GJS internal stuff - await this.exportGjs(this.dependencyManager.core(), girModules, girModulesGrouped) + await this.exportGjs(this.dependencyManager.core(), registry) } } } diff --git a/packages/generator-typescript/templates/package.json b/packages/generator-typescript/templates/package.json index 9155cfa07..a9cd3c69d 100644 --- a/packages/generator-typescript/templates/package.json +++ b/packages/generator-typescript/templates/package.json @@ -95,9 +95,14 @@ _%> <%_ } _%> }, <%_ } _%> - <%_ if (entryPointName === 'gjs') { _%> - "./ambient": "./ambient.d.ts", - "./dom": "./dom.d.ts", + "./ambient": { + "types": "./ambient.d.ts", + "default": "./ambient.js" + }, + "./dom": { + "types": "./dom.d.ts", + "default": "./dom.js" + }, <%_ } else {_%> "./ambient": { "types": "./<%- entryPointName %>-ambient.d.ts", diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index 94b382f5e..9b4593c14 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -4,10 +4,12 @@ import { Transformation } from './transformation.js' import type { Dependency, GenerateConfig, GirInclude } from './types/index.js' import type { GirModule } from './gir-module.js' +import { GirNSRegistry } from './newlib/lib.js' export class DependencyManager { protected log: Logger protected transformation: Transformation + registry = new GirNSRegistry() cache: { [packageName: string]: Dependency } = {} diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index b44651dae..07111bd05 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -1,133 +1,90 @@ // TODO move this class into a web-worker? https://www.npmjs.com/package/web-worker - -import { - Transformation, - FULL_TYPE_MAP, - PRIMITIVE_TYPE_MAP, - ARRAY_TYPE_MAP, - IGNORE_GIR_TYPE_TS_DOC_TYPES, -} from './transformation.js' -import { STATIC_NAME_ALREADY_EXISTS, MAX_CLASS_PARENT_DEPTH } from './constants.js' +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { Transformation, IGNORE_GIR_TYPE_TS_DOC_TYPES } from './transformation.js' import { Logger } from './logger.js' import { Injector } from './injection/injector.js' import { GirFactory } from './gir-factory.js' import { ConflictResolver } from './conflict-resolver.js' import { DependencyManager } from './dependency-manager.js' -import { - NO_TSDATA, - WARN_NOT_FOUND_TYPE, - WARN_CONSTANT_ALREADY_EXPORTED, - WARN_DUPLICATE_SYMBOL, - WARN_DUPLICATE_PARAMETER, - WARN_DUPLICATE_ENUM_IDENTIFIER, -} from './messages.js' -import { - isEqual, - find, - clone, - girBool, - removeNamespace, - addNamespace, - girElementIsIntrospectable, - underscores, -} from './utils.js' +import { find } from './utils.js' import { SymTable } from './symtable.js' import { LibraryVersion } from './library-version.js' -import { GirDirection } from './types/index.js' import type { Dependency, GirRepository, - GirNamespace, - GirAliasElement, - GirEnumElement, - GirMemberElement, GirFunctionElement, - GirClassElement, - GirArrayType, GirType, - GirCallableParams, - GirCallableParamElement, GirVirtualMethodElement, GirSignalElement, - GirCallableReturn, - GirRecordElement, GirCallbackElement, GirConstantElement, - GirBitfieldElement, - GirFieldElement, GirMethodElement, - GirPropertyElement, - GirAnyElement, - GirUnionElement, - GirInstanceParameter, - GirInterfaceElement, GirConstructorElement, GirDocElement, - TypeGirFunction, - GirTypeName, - TypeGirVariable, - TypeGirClass, - TypeGirEnumerationMember, - LocalNameCheck, - LocalNameType, - LocalName, - LocalNames, TsDoc, TsDocTag, - TsClass, - TsMethod, - TsFunction, - TsProperty, - TsVar, - TsParameter, - TsInstanceParameter, - TsCallbackInterface, - TsMember, - TsEnum, - TsAlias, - TsType, - TsGenericParameter, - TsCallback, - InheritanceTable, ParsedGir, + GirInfoAttrs, GenerateConfig, - ClassParent, - InjectionParameter, - TsSignal, + GirNSMember, + IntrospectedFunctionParameter, + IntrospectedClassFunction, PromisifyFunc, } from './types/index.js' +import { + ClosureType, + TypeIdentifier, + PromiseType, + VoidType, + BooleanType, + TupleType, + BinaryType, + NullableType, + ObjectType, +} from './newlib/gir.js' +import { IntrospectedAlias } from './newlib/gir/alias.js' +import { IntrospectedBase, IntrospectedNamespaceMember } from './newlib/gir/base.js' +import { + IntrospectedBaseClass, + IntrospectedClass, + IntrospectedRecord, + IntrospectedInterface, +} from './newlib/gir/class.js' +import { IntrospectedConstant } from './newlib/gir/const.js' +import { IntrospectedEnum, IntrospectedError } from './newlib/gir/enum.js' +import { IntrospectedFunction, IntrospectedCallback, IntrospectedClassCallback } from './newlib/gir/function.js' +import { NSRegistry } from './newlib/gir/registry.js' +import { isPrimitiveType } from './newlib/gir/util.js' +import { LoadOptions } from './newlib/types.js' +import { GirVisitor } from './newlib/visitor.js' export class GirModule { - /** - * Array of all gir modules - */ - static allGirModules: GirModule[] = [] /** * E.g. 'Gtk' */ - namespace: string + namespace!: string /** * E.g. '4.0' */ - version = '0.0' + version: string /** * E.g. 'Gtk-4.0' */ - packageName: string + packageName!: string /** * E.g. 'Gtk40' * Is used in the generated index.d.ts, for example: `import * as Gtk40 from "./Gtk-4.0.js";` */ - importNamespace: string + importNamespace!: string - importName: string + importName!: string /** * The version of the library as an object. * E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`' */ - libraryVersion: LibraryVersion + libraryVersion!: LibraryVersion dependencies: Dependency[] = [] private _transitiveDependencies: Dependency[] = [] @@ -144,24 +101,22 @@ export class GirModule { return [...new Set([...this.dependencies, ...this.transitiveDependencies])] } - repo: GirRepository - ns: GirNamespace = { $: { name: '', version: '0.0' } } /** * Used to find namespaces that are used in other modules */ - symTable: SymTable + symTable!: SymTable - transformation: Transformation + transformation!: Transformation girFactory = new GirFactory() dependencyManager: DependencyManager - conflictResolver: ConflictResolver + conflictResolver!: ConflictResolver - log: Logger + log!: Logger - inject: Injector + inject!: Injector extends?: string @@ -171,30 +126,34 @@ export class GirModule { */ constNames: { [varName: string]: GirConstantElement } = {} - constructor( - xml: ParsedGir, - private readonly config: GenerateConfig, - ) { - this.repo = xml.repository[0] + readonly name: string + readonly c_prefixes: string[] - if (!this.repo.namespace || !this.repo.namespace.length) { - throw new Error(`Namespace not found!`) - } + private imports: Map = new Map() + default_imports: Map = new Map() + + private _members?: Map + private _enum_constants?: Map + private _resolve_names: Map = new Map() + __dts__references?: string[] + + package_version!: readonly [string, string] | readonly [string, string, string] + parent!: NSRegistry + config: GenerateConfig + + constructor(repo: GirRepository, name: string, version: string, prefixes: string[], config: GenerateConfig) { + this.name = name + this.version = version + this.c_prefixes = [...prefixes] + this.package_version = ['0', '0'] + this.config = config this.dependencyManager = DependencyManager.getInstance(this.config) - this.dependencies = this.dependencyManager.fromGirIncludes(this.repo.include || []) - this.ns = this.repo.namespace[0] - this.namespace = this.ns.$.name - this.version = this.ns.$.version - this.packageName = `${this.namespace}-${this.version}` - this.libraryVersion = new LibraryVersion(this.ns.constant, this.version) - this.transformation = new Transformation(config) - this.log = new Logger(config.environment, config.verbose, this.packageName || 'GirModule') - this.conflictResolver = new ConflictResolver(config.environment, config.verbose) - this.inject = new Injector(this.config.environment) - this.importNamespace = this.transformation.transformModuleNamespaceName(this.packageName) - this.importName = this.transformation.transformImportName(this.packageName) - this.symTable = new SymTable(this.config, this.packageName, this.namespace) + this.dependencies = this.dependencyManager.fromGirIncludes(repo.include || []) + } + + get ns() { + return this } private checkTransitiveDependencies(transitiveDependencies: Dependency[]) { @@ -256,48 +215,33 @@ export class GirModule { return tags } - private getTsDocReturnTags( - girElement?: - | GirCallbackElement - | GirConstructorElement - | GirFunctionElement - | GirMethodElement - | GirSignalElement - | GirVirtualMethodElement, - ): TsDocTag[] { - const girReturnValue = girElement?.['return-value']?.[0] - if (!girReturnValue || !girReturnValue.doc?.[0]?._) { + getTsDocReturnTags(girElement?: IntrospectedFunction | IntrospectedClassFunction): TsDocTag[] { + const girReturnValue = girElement?.returnTypeDoc + if (!girReturnValue) { return [] } const returnTag: TsDocTag = { tagName: 'returns', paramName: '', - text: this.transformation.transformGirDocTagText(girReturnValue.doc[0]._), + text: this.transformation.transformGirDocTagText(girReturnValue), } return [returnTag] } - private getTsDocInParamTags(inParams?: GirCallableParamElement[]): TsDocTag[] { + getTsDocInParamTags(inParams?: IntrospectedFunctionParameter[]): TsDocTag[] { const tags: TsDocTag[] = [] if (!inParams?.length) { return tags } for (const inParam of inParams) { - if (!inParam._tsData) { - throw new Error(NO_TSDATA('getTsDocInParamTags')) - } - if (!inParam._tsData?.doc) { - inParam._tsData.doc = this.getTsDoc(inParam) - } - if (inParam._tsData?.name) { + if (inParam.name) { tags.push({ - paramName: inParam._tsData.name, + paramName: inParam.name, tagName: 'param', - text: inParam._tsData.doc.text - ? this.transformation.transformGirDocTagText(inParam._tsData.doc.text) - : '', + text: + typeof inParam.doc === 'string' ? this.transformation.transformGirDocTagText(inParam.doc) : '', }) } } @@ -365,32 +309,6 @@ export class GirModule { } } - /** - * Functions and methods of a class - */ - private annotateMethods( - girClass: GirClassElement | GirRecordElement | GirInterfaceElement, - girFuncs: - | GirMethodElement[] - | GirFunctionElement[] - | GirConstructorElement[] - | GirVirtualMethodElement[] - | GirSignalElement[], - ): void { - if (Array.isArray(girFuncs)) - for (const girFunc of girFuncs) { - if (girFunc?.$?.name) { - // girFunc._girType = girType - // girFunc._tsType = tsType - girFunc._class = girClass - const nsName = girClass ? girClass._fullSymName : this.namespace - if (nsName) girFunc._fullSymName = `${nsName}.${girFunc.$.name}` - this.annotateFunctionArguments(girFunc) - this.annotateFunctionReturn(girFunc) - } - } - } - /** * Variables which are not part of a class */ @@ -402,794 +320,7 @@ export class GirModule { } } } - - private annotateFields( - girClass: GirClassElement | GirRecordElement | GirInterfaceElement | null, - girVars: GirPropertyElement[], - ): void - - private annotateFields( - girClass: GirClassElement | GirRecordElement | GirInterfaceElement | null, - girVars: GirFieldElement[], - ): void - - /** - * Fields are variables which are part of a class - * @see https://www.typescriptlang.org/docs/handbook/2/classes.html#fields - */ - private annotateFields( - girClass: GirClassElement | GirRecordElement | GirInterfaceElement, - girVars: GirPropertyElement[] | GirFieldElement[], - ): void { - for (const girVar of girVars) { - const nsName = girClass ? girClass._fullSymName : this.namespace - girVar._module = this - if (girClass) { - girVar._class = girClass - } - - if (girVar.$ && girVar.$.name && nsName) { - girVar._fullSymName = `${nsName}.${girVar.$.name}` - } - } - } - - private annotateClass(girClass: GirClassElement, girTypeName: 'class'): void - private annotateClass(girClass: GirRecordElement, girTypeName: 'record'): void - private annotateClass(girClass: GirInterfaceElement, girTypeName: 'interface'): void - - private annotateClass(girClass: GirClassElement | GirRecordElement | GirInterfaceElement) { - girClass._module = this - girClass._fullSymName = `${this.namespace}.${girClass.$.name}` - - const constructors = Array.isArray(girClass.constructor) ? girClass.constructor : [] - const signals = ((girClass as GirClassElement | GirInterfaceElement).signal || - girClass['glib:signal'] || - []) as GirSignalElement[] - const functions = girClass.function || [] - const methods = girClass.method || [] - const vMethods = (girClass as GirClassElement)['virtual-method'] || new Array() - const properties = girClass.property - const fields = girClass.field - - this.annotateMethods(girClass, constructors) - this.annotateMethods(girClass, functions) - this.annotateMethods(girClass, methods) - this.annotateMethods(girClass, vMethods) - this.annotateMethods(girClass, signals) - if (properties) this.annotateFields(girClass, properties) - if (fields) this.annotateFields(girClass, fields) - } - - /** - * Annotates the custom `_module`, `_fullSymName` and `_girType` properties. - * Also registers the element on the `symTable`. - * @param girElements - * @param girType - */ - private annotateAndRegisterGirElement(girElements: GirAnyElement[]): void { - for (const girElement of girElements) { - if (girElement?.$ && girElement.$.name) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument - if (!girElementIsIntrospectable(girElement as any)) continue - - girElement._module = this - girElement._fullSymName = `${this.namespace}.${girElement.$.name}` - if (this.symTable.get(this.allDependencies, girElement._fullSymName)) { - this.log.warn(WARN_DUPLICATE_SYMBOL(girElement._fullSymName)) - } - - this.symTable.set(this.allDependencies, girElement._fullSymName, girElement) - } - } - } - - /** - * TODO: find better name for this method - * @param girVar - * @param fullTypeName - * @returns e.g. - * ```ts - * { - * namespace: "Gtk", - * resValue: "Gtk.Widget" - * } - * - */ - private fullTypeLookup( - girVar: - | GirCallableParamElement - | GirCallableReturn - | GirFieldElement - | GirAliasElement - | GirPropertyElement - | GirConstantElement, - fullTypeName: string | null, - ) { - let resValue = '' - let namespace = '' - - if (!fullTypeName) { - return { - value: resValue, - fullTypeName, - namespace, - } - } - - // Fully qualify our type name - if (!fullTypeName.includes('.')) { - let tryFullTypeName = '' - - if (!resValue && girVar._module && girVar._module !== this) { - tryFullTypeName = `${girVar._module.namespace}.${fullTypeName}` - resValue = this.fullTypeLookupWithNamespace(tryFullTypeName).value - if (resValue) { - fullTypeName = tryFullTypeName - namespace = girVar._module.namespace - } - } - - if (!resValue) { - tryFullTypeName = `${this.namespace}.${fullTypeName}` - resValue = this.fullTypeLookupWithNamespace(tryFullTypeName).value - if (resValue) { - fullTypeName = tryFullTypeName - namespace = this.namespace - } - } - - const girClass = ( - girVar as - | GirCallableParamElement - | GirCallableReturn - | GirFieldElement - | GirAliasElement - | GirPropertyElement - )._class as GirClassElement | undefined - - if (!resValue && girClass?._module?.namespace && girClass._module !== this) { - tryFullTypeName = `${girClass._module.namespace}.${fullTypeName}` - resValue = this.fullTypeLookupWithNamespace(tryFullTypeName).value - if (resValue) { - fullTypeName = tryFullTypeName - namespace = girClass?._module?.namespace - } - } - } - - if (!resValue && fullTypeName) { - resValue = this.fullTypeLookupWithNamespace(fullTypeName).value - } - - return { - value: resValue, - namespace, - } - } - - /** - * this method needs to be refactored, an array can also be an array of an array for example - * @param girVar - * @returns - */ - getArrayData( - girVar: - | GirCallableReturn - | GirAliasElement - | GirFieldElement - | GirCallableParamElement - | GirPropertyElement - | GirConstantElement, - ) { - let arrayType: GirType | null = null - let arrCType: string | undefined - let isArray = false - let overrideTypeName: string | undefined - let typeArray: GirType[] | undefined - - let collection: GirArrayType[] | GirType[] | undefined - - if ((girVar as GirCallableReturn | GirFieldElement).array) { - collection = (girVar as GirCallableReturn | GirFieldElement).array - } else if (/^GLib.S?List$/.test(girVar.type?.[0].$?.name || '')) { - // This converts GLib.List / GLib.SList to T[] - collection = girVar.type - } - - if (collection && collection.length > 0) { - isArray = true - typeArray = collection[0].type - if (collection[0].$) { - const ea = collection[0].$ - arrCType = ea['c:type'] - } - } - - if (typeArray && typeArray?.length > 0) { - arrayType = typeArray[0] - } - - if (this.config.environment == 'gjs' && isArray && arrayType?.$?.name && ARRAY_TYPE_MAP[arrayType.$.name]) { - isArray = false - overrideTypeName = ARRAY_TYPE_MAP[arrayType.$.name] as string | undefined - } - - return { - arrCType, - arrayType, - isArray, - overrideTypeName, - } - } - - /** - * Get the typescript type of a GirElement like a `GirPropertyElement` or `GirCallableReturn` - * @param girVar - */ - private getTsType( - girVar: - | GirCallableReturn - | GirAliasElement - | GirFieldElement - | GirCallableParamElement - | GirPropertyElement - | GirConstantElement, - tsClass: TsClass | null, - girTypeName: GirTypeName, - defaults: Partial = {}, - ) { - let type: GirType | undefined = girVar.type?.[0] - let fullTypeName: string | null = null - let typeName = defaults.type || '' - let isFunction = defaults.isFunction || false - let isCallback = defaults.isCallback || false - const nullable = this.typeIsNullable(girVar, girTypeName) || defaults.nullable || false - const optional = this.typeIsOptional(girVar, girTypeName) || defaults.optional || false - - const girCallbacks: GirCallbackElement[] = [] - const array = this.getArrayData(girVar) - - if (array.overrideTypeName) { - typeName = array.overrideTypeName - } - - if (array.arrayType) { - type = array.arrayType - } - - const cType = type?.$ ? type.$['c:type'] : array.arrCType - fullTypeName = type?.$?.name || null - const callbacks = (girVar as GirFieldElement).callback - - if (!typeName && callbacks?.length) { - for (const girCallback of callbacks) { - if (!girElementIsIntrospectable(girCallback)) continue - - if (!girCallback._tsData) { - const tsCallback = this.getFunctionTsData(girCallback, 'callback', tsClass, { - isStatic: false, - isArrowType: true, - isGlobal: false, - isVirtual: false, - returnType: null, - generics: [], - }) - - if (!tsCallback) continue - - girCallback._tsData = { - ...tsCallback, - girTypeName: 'callback', - tsTypeName: this.girFactory.girTypeNameToTsTypeName('callback', false), - tsCallbackInterface: this.getCallbackInterfaceTsData(girCallback), - doc: this.getTsDoc(girCallback), - overloads: [], - } - } - - if (girCallback._tsData) { - girCallbacks.push(girCallback) - isFunction = true - isCallback = true - } - } - } - - if (!isFunction) { - const res = this.fullTypeLookup(girVar, fullTypeName) - if (res.value) { - typeName = res.value - fullTypeName = typeName - } - } - - if (!typeName && type?.$?.name && PRIMITIVE_TYPE_MAP[type.$.name]) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - typeName = PRIMITIVE_TYPE_MAP[type.$.name] - } - - if (cType) { - const parsedCType = PRIMITIVE_TYPE_MAP[cType] as string | undefined - if (!typeName && parsedCType) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - typeName = parsedCType - } - } - - if (!typeName) { - typeName = 'any' - const logName = cType || fullTypeName || girVar.$.name || '' - this.log.warn(WARN_NOT_FOUND_TYPE(logName)) - } - - // TODO: transform array to type with generics? - const tsType = this.girFactory.newTsType({ - ...defaults, - type: typeName, - optional, - nullable, - callbacks: girCallbacks, - isArray: array.isArray, - isFunction, - isCallback, - }) - - return tsType - } - - /** - * - * @param girFunc - * @returns - */ - private getReturnType( - girFunc: - | GirMethodElement - | GirFunctionElement - | GirConstructorElement - | GirCallbackElement - | GirSignalElement - | GirVirtualMethodElement, - tsClass: TsClass | null, - generics: TsGenericParameter[] = [], - ) { - const girTypeName = 'callable-return' - let outArrayLengthIndex = -1 - - if (girFunc['return-value'] && girFunc['return-value'].length > 1) { - throw new Error('Several return values found!') - } - - // There are no multiple return values, so we always use index 0 - const girVar = girFunc['return-value']?.[0] || null - - // We still use an array to allow multiple return values for later - const returnTypes: TsType[] = [] - - if (girVar) { - returnTypes.push(this.getTsType(girVar, tsClass, girTypeName, { generics })) - - outArrayLengthIndex = girVar.array && girVar.array[0].$?.length ? Number(girVar.array[0].$.length) : -1 - } else { - returnTypes.push(this.girFactory.newTsType({ type: 'void', generics })) - } - - const retTypeIsVoid = returnTypes.length === 1 && returnTypes[0].type === 'void' - - return { returnTypes, outArrayLengthIndex, retTypeIsVoid } - } - - private setParameterTsData( - girParam: GirCallableParamElement, - girParams: GirCallableParamElement[], - paramNames: string[], - skip: GirCallableParamElement[], - parent: TsFunction | TsSignal, - ) { - const girTypeName = 'callable-param' - // I think it's safest to force inout params to have the - // same type for in and out - const tsType = this.getTsType(girParam, parent.parent, girTypeName) - // const optDirection = girParam.$.direction - - if (girParam._tsData) { - // this.log.warn('[setParameterTsData] _tsData already set!') - return girParam._tsData - } - - if (tsType.isCallback) { - throw new Error('Callback type is not implemented here') - } - - let paramName = this.transformation.transformParameterName(girParam, false) - - if (paramNames.includes(paramName)) { - this.log.warn(WARN_DUPLICATE_PARAMETER(paramName, girParam._fullSymName)) - paramName += '_' - } - paramNames.push(paramName) - - // In Typescript no optional parameters are allowed if the following ones are not optional - if (tsType.optional) { - const index = girParams.indexOf(girParam) - const following = girParams - .slice(index) - .filter(() => skip.indexOf(girParam) === -1) - .filter((p) => p.$.direction !== GirDirection.Out) - - if (following.some((p) => !this.typeIsOptional(p, girTypeName))) { - tsType.optional = false - } - } - - const tsParam: TsParameter = { - name: paramName, - type: [tsType], - isRest: false, - girTypeName, - doc: this.getTsDoc(girParam), - parent, - } - - girParam._tsData = tsParam - - // // TODO: remove this, wee need a special solution for Gio.AsyncReadyCallback instead - girParam = this.inject.toParameterType(girParam) - - return girParam._tsData - } - - private getInstanceParameterTsData(instanceParameter: GirInstanceParameter): TsInstanceParameter | undefined { - const typeName = instanceParameter.type?.[0]?.$?.name || undefined - const rec = typeName ? this.ns.record?.find((r) => r.$.name == typeName) : undefined - const structFor = rec?.$['glib:is-gtype-struct-for'] - if (structFor && instanceParameter.$.name) { - // TODO: Should use of a constructor, and even of an instance, be discouraged? - return { - name: instanceParameter.$.name, - structFor, - } - } - return undefined - } - - private setParametersTsData( - outArrayLengthIndex: number, - girParams: GirCallableParams[] = [], - parent: TsFunction | TsCallback, - ) { - const outParams: GirCallableParamElement[] = [] - const inParams: GirCallableParamElement[] = [] - const paramNames: string[] = [] - const instanceParameters: GirInstanceParameter[] = [] - - if (girParams && girParams.length > 0) { - for (const girParam of girParams) { - const params = girParam?.parameter || [] - - // Instance parameter needs to be exposed for class methods (see comment above getClassMethods()) - const instanceParameter = girParams[0]['instance-parameter']?.[0] - if (instanceParameter) { - instanceParameter._tsData = this.getInstanceParameterTsData(instanceParameter) - if (instanceParameter._tsData) { - instanceParameters.push(instanceParameter) - } - } - if (params.length) { - const skip = outArrayLengthIndex === -1 ? [] : [params[outArrayLengthIndex]] - - this.processParams(params, skip, (girVar) => this.arrayLengthIndexLookup(girVar)) - this.processParams(params, skip, (girVar) => this.closureDataIndexLookup(girVar)) - this.processParams(params, skip, (girVar) => this.destroyDataIndexLookup(girVar)) - - for (const param of params) { - if (skip.includes(param)) { - continue - } - - param._tsData = this.setParameterTsData(param, params, paramNames, skip, parent) - - const optDirection = param.$.direction - if ( - optDirection === GirDirection.Out || - optDirection === GirDirection.Inout || - optDirection === GirDirection.InOut - ) { - outParams.push(param) - if (optDirection === GirDirection.Out) continue - } - inParams.push(param) - } - } - } - } - - return { outParams, paramNames, inParams, instanceParameters } - } - - private getVariableTsData( - girVar: GirPropertyElement, - girTypeName: 'property', - tsTypeName: 'property' | 'constructor-property' | 'static-property', - tsClass: TsClass | null, - optional: boolean, - nullable: boolean, - allowQuotes: boolean, - ): GirPropertyElement['_tsData'] - - private getVariableTsData( - girVar: GirConstantElement, - girTypeName: 'constant', - tsTypeName: 'constant', - tsClass: TsClass | null, - optional: boolean, - nullable: boolean, - allowQuotes: boolean, - ): GirConstantElement['_tsData'] - - private getVariableTsData( - girVar: GirFieldElement, - girTypeName: 'field', - tsTypeName: 'property' | 'static-property', - tsClass: TsClass | null, - optional: boolean, - nullable: boolean, - allowQuotes: boolean, - ): GirFieldElement['_tsData'] - - private getVariableTsData( - girVar: GirPropertyElement | GirFieldElement | GirConstantElement, - girTypeName: 'property' | TypeGirVariable | 'field', - tsTypeName: 'constant' | 'property' | 'constructor-property' | 'static-property', - tsClass: TsClass | null, - optional = false, - nullable = false, - allowQuotes = false, - generics: TsGenericParameter[] = [], - ) { - if (!girVar.$.name) return undefined - if ( - !girVar || - !girVar.$ || - !girBool(girVar.$.introspectable, true) || - girBool((girVar as GirFieldElement).$.private) - ) { - return undefined - } - - if (girVar._tsData) { - // this.log.warn('[getVariableTsData] _tsData already set!') - return girVar._tsData - } - - let name = girVar.$.name - - if (tsTypeName === 'constructor-property') { - name = this.transformation.transformConstructorPropertyName(girVar.$.name, allowQuotes) - } else { - switch (girTypeName) { - case 'property': - name = this.transformation.transformPropertyName(girVar.$.name, allowQuotes) - break - case 'constant': - name = this.transformation.transformConstantName(girVar.$.name, allowQuotes) - break - case 'field': - name = this.transformation.transformFieldName(girVar.$.name, allowQuotes) - break - } - } - - // Use the out type because it can be a union which isn't appropriate - // for a property - const tsType = this.getTsType(girVar, tsClass, girTypeName, { optional, nullable, generics }) - - const tsData: TsProperty | TsVar = { - name, - type: [tsType], - isInjected: false, - girTypeName, - tsTypeName, - doc: this.getTsDoc(girVar), - } - - tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName)) - - return tsData - } - - private getPropertyTsData( - girProp: GirPropertyElement, - girTypeName: 'property', - tsTypeName: 'property' | 'constructor-property' | 'static-property', - tsClass: TsClass, - construct?: boolean, - optional?: boolean, - nullable?: boolean, - indentCount?: number, - ): TsProperty | undefined - - private getPropertyTsData( - girProp: GirFieldElement, - girTypeName: 'field', - tsTypeName: 'property' | 'static-property', - tsClass: TsClass, - construct?: boolean, - optional?: boolean, - nullable?: boolean, - indentCount?: number, - ): TsVar | undefined - - /** - * - * @param girProp - * @param girTypeName - * @param tsTypeName - * @param construct construct means include the property even if it's construct-only, - * @param optional optional means if it's construct-only it will also be marked optional (?) - * @param nullable - * @returns - */ - private getPropertyTsData( - girProp: GirPropertyElement | GirFieldElement, - girTypeName: 'property' | 'field', - tsTypeName: 'constructor-property' | 'property' | 'static-property', - tsClass: TsClass, - construct = false, - optional?: boolean, - nullable?: boolean, - ): TsProperty | undefined { - if (!girBool(girProp.$.writable) && construct) return undefined - if (girBool((girProp as GirFieldElement).$.private)) return undefined - - if (girProp._tsData) { - // this.log.warn('[getPropertyTsData] _tsData already set!') - return girProp._tsData as TsProperty - } - - if (optional === undefined) optional = this.typeIsOptional(girProp, girTypeName) - if (nullable === undefined) nullable = this.typeIsNullable(girProp, girTypeName) - const readonly = !construct && this.typeIsReadonly(girProp) - - let tsData: TsProperty | undefined - - switch (girTypeName) { - case 'property': - tsData = this.getVariableTsData( - girProp as GirPropertyElement, - girTypeName, - tsTypeName, - tsClass, - construct && optional, - construct && nullable, - true, - ) as TsProperty - break - case 'field': - if (tsTypeName !== 'property') { - throw new Error(`Wrong tsType: "${tsTypeName}" for girType: "${girTypeName}`) - } - tsData = this.getVariableTsData( - girProp as GirFieldElement, - girTypeName, - tsTypeName, - tsClass, - construct && optional, - construct && nullable, - true, - ) as TsProperty - break - default: - throw new Error(`Unknown property type: ${girTypeName as string}`) - } - - if (!tsData?.name) { - return undefined - } - - tsData = { - ...tsData, - readonly, - } - return tsData - } - - /** - * - * @param girFunc - * @param prefix E.g. vfunc - * @param overrideReturnType - * @param isArrowType - * @param indentCount - */ - private getFunctionTsData( - girFunc: - | GirMethodElement - | GirFunctionElement - | GirConstructorElement - | GirCallbackElement - | GirVirtualMethodElement, - girTypeName: GirTypeName, - tsClass: TsClass | null, - overwrite: { - isStatic: boolean - isArrowType: boolean - isGlobal: boolean - isVirtual: boolean - isInjected?: boolean - returnType: string | null - generics: TsGenericParameter[] - }, - ): TsFunction | undefined { - if (!girFunc || !girFunc.$ || !girBool(girFunc.$.introspectable, true) || girFunc.$['shadowed-by']) { - return undefined - } - - let hasUnresolvedConflict: boolean | undefined - - // TODO: Fix that we overwrite tsData every time seems wrong to me, but if I just return the already defined `_tsData` leads to problems with the overload methods - if (girFunc._tsData) { - hasUnresolvedConflict = girFunc._tsData?.hasUnresolvedConflict // WORKAROUND do not overwrite conflicts - } - - let name = girFunc.$.name - const { returnTypes, outArrayLengthIndex, retTypeIsVoid } = this.getReturnType(girFunc, tsClass) - - const shadows = (girFunc as GirMethodElement).$.shadows - - if (shadows) { - name = shadows - } - - // Overwrites - overwrite.isStatic = overwrite.isStatic || girTypeName === 'static-function' || girTypeName === 'constructor' - overwrite.isGlobal = overwrite.isGlobal || girTypeName === 'function' - overwrite.isVirtual = overwrite.isVirtual || girTypeName === 'virtual' - overwrite.isInjected = overwrite.isInjected || false - - // Function name transformation by environment - name = this.transformation.transformFunctionName(name, overwrite.isVirtual) - - const tsData: TsFunction = { - isArrowType: overwrite.isArrowType, - isStatic: overwrite.isStatic, - isGlobal: overwrite.isGlobal, - isVirtual: overwrite.isVirtual, - isInjected: overwrite.isInjected, - returnTypes, - retTypeIsVoid, - name, - overrideReturnType: overwrite.returnType || undefined, - inParams: [], - outParams: [], - instanceParameters: [], - generics: overwrite.generics, - hasUnresolvedConflict, - girTypeName: girTypeName as TypeGirFunction, - tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName as TypeGirFunction, overwrite.isStatic), - doc: this.getTsDoc(girFunc as GirDocElement), - overloads: [], - parent: tsClass, - } - - const { inParams, outParams, instanceParameters } = this.setParametersTsData( - outArrayLengthIndex, - girFunc.parameters, - tsData, - ) - - tsData.inParams.push(...inParams) - tsData.outParams.push(...outParams) - tsData.instanceParameters.push(...instanceParameters) - - tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName)) - tsData.doc.tags.push(...this.getTsDocInParamTags(tsData?.inParams)) - tsData.doc.tags.push(...this.getTsDocReturnTags(girFunc)) - - return tsData - } - + overloadPromisifiedFunctions(girFunctions: GirFunctionElement[]): void { if (!this.config.promisify) return @@ -1282,1685 +413,530 @@ export class GirModule { } } - private getCallbackInterfaceTsData(girCallback: GirCallbackElement | GirConstructorElement) { - if (!girElementIsIntrospectable(girCallback)) return undefined - - const namespace = this.namespace + registerResolveName(resolveName: string, namespace: string, name: string) { + this._resolve_names.set(resolveName, new TypeIdentifier(name, namespace)) + } - const tsDataInterface: TsCallbackInterface = { - name: `${namespace}.${girCallback.$.name}`, - generics: [], + get members(): Map { + if (!this._members) { + this._members = new Map() } - return tsDataInterface + return this._members } - private setCallbackTsData(girCallback: GirCallbackElement, tsClass: TsClass | null) { - const tsFunction = this.getFunctionTsData(girCallback, 'callback', tsClass, { - isStatic: false, - isArrowType: true, - isGlobal: false, - isVirtual: false, - returnType: null, - generics: [], - }) - if (tsFunction) { - const tsCallback: TsCallback = { - ...tsFunction, - girTypeName: 'callback', - tsTypeName: this.girFactory.girTypeNameToTsTypeName('callback', false), - tsCallbackInterface: this.getCallbackInterfaceTsData(girCallback), - overloads: [], - } - girCallback._tsData = tsCallback - - this.inject.toCallback(girCallback) + get enum_constants(): Map { + if (!this._enum_constants) { + this._enum_constants = new Map() } - return girCallback._tsData + + return this._enum_constants } - private getSignalCallbackInterfaceTsData( - girCallback: GirSignalElement, - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - if (!girElementIsIntrospectable(girCallback)) return undefined + accept(visitor: GirVisitor) { + for (const key of [...this.members.keys()]) { + const member = this.members.get(key) - if (!girClass._tsData || !girClass._module) { - throw new Error(NO_TSDATA('getSignalCallbackTsData')) - } + if (!member) continue - const className = girClass._tsData.name - const signalName = girCallback.$.name - const signalInterfaceName = this.transformation.transformSignalInterfaceName(signalName) - const namespace = girClass._module.namespace - - const tsDataInterface: TsCallbackInterface = { - name: `${namespace}.${className}.${signalInterfaceName}SignalCallback`, - generics: [], - overwriteDoc: { - text: `Signal callback interface for \`${signalName}\``, - tags: [], - }, + if (Array.isArray(member)) { + this.members.set( + key, + member.map((m) => { + return m.accept(visitor) + }), + ) + } else { + this.members.set(key, member.accept(visitor)) + } } - return tsDataInterface + return this } - private getConstructorFunctionTsData(parentClass: TsClass, girConstructor: GirConstructorElement) { - if (!girElementIsIntrospectable(girConstructor)) return - - const constructorTypeName = addNamespace(parentClass.name, parentClass.namespace) + getImportsForCPrefix(c_prefix: string): GirModule[] { + return this.parent.namespacesForPrefix(c_prefix) + } - return this.getFunctionTsData(girConstructor, 'constructor', parentClass, { - isStatic: true, - isArrowType: false, - isGlobal: false, - isVirtual: false, - returnType: constructorTypeName, - generics: [], - }) + hasImport(name: string): boolean { + return this.default_imports.has(name) || this.imports.has(name) } - private getSignalCallbackTsData( - girSignalFunc: GirSignalElement, - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - if (!girClass._tsData) { - throw new Error(NO_TSDATA('getSignalCallbackTsData')) + private _getImport(name: string): GirModule | null { + let version = this.default_imports.get(name) ?? this.imports.get(name) + + if (name === this.name) { + return this } - if (girSignalFunc._tsData) { - return girSignalFunc._tsData + // TODO: Clean this up, but essentially try to resolve import versions + // using transitive imports (e.g. use GtkSource to find the version of Gtk) + if (!version) { + const entries = [...this.default_imports.entries()].flatMap(([_name]) => { + const namespace = this._getImport(_name) + + return [...(namespace?.default_imports.entries() ?? [])] + }) + + version = Object.fromEntries(entries)[name] } - // Leads to errors here - // if (!girElementIsIntrospectable(girSignalFunc)) return undefined - - const name = this.transformation.transform('signalName', girSignalFunc.$.name) - - const { returnTypes, outArrayLengthIndex, retTypeIsVoid } = this.getReturnType(girSignalFunc, girClass._tsData) - - const tsCallback: TsCallback = { - name, // TODO: 'callback'? - returnTypes, - isArrowType: true, - isStatic: false, - isGlobal: false, - isVirtual: false, - isInjected: false, - retTypeIsVoid, - inParams: [], - instanceParameters: [], - outParams: [], - generics: [], - girTypeName: 'callback', - tsTypeName: this.girFactory.girTypeNameToTsTypeName('callback', false), - doc: this.getTsDoc(girSignalFunc), - overloads: [], - parent: girClass._tsData, + if (!version) { + version = this.parent.assertDefaultVersionOf(name) } - const { inParams, outParams, instanceParameters } = this.setParametersTsData( - outArrayLengthIndex, - girSignalFunc.parameters, - tsCallback, - ) + const namespace = this.parent.namespace(name, version) - if (this.config.environment === 'gjs') { - inParams.unshift( - this.girFactory.newGirCallableParamElement( - { - name: '$obj', - type: [ - { - type: girClass._tsData.name, - }, - ], - }, - tsCallback, - ), - ) + if (namespace) { + if (!this.imports.has(namespace.name)) { + this.imports.set(namespace.name, namespace.version) + } } - tsCallback.inParams.push(...inParams) - tsCallback.outParams.push(...outParams) - tsCallback.instanceParameters.push(...instanceParameters) + return namespace + } - tsCallback.doc.tags.push(...this.getTsDocGirElementTags(tsCallback.tsTypeName, tsCallback.girTypeName)) - tsCallback.doc.tags.push(...this.getTsDocInParamTags(tsCallback?.inParams)) - tsCallback.doc.tags.push(...this.getTsDocReturnTags(girSignalFunc)) + getInstalledImport(name: string): GirModule | null { + let version = this.default_imports.get(name) ?? this.imports.get(name) - return tsCallback - } + if (name === this.name) { + return this + } - /** - * Generates signal methods like `connect`, `connect_after` and `emit` on Gjs or `connect`, `on`, `once`, `off` and `emit` an node-gtk - * for a default gir signal element - * @param girSignal - * @returns - */ - private getClassSignalMethodsTsData(girSignal: GirSignalElement, parentClass: TsClass) { - if (!girSignal._tsData) { - throw new Error(NO_TSDATA('getClassSignalMethodsTsData')) + if (!version) { + version = this.parent.defaultVersionOf(name) ?? undefined } - const inParams = girSignal._tsData.inParams.slice(1).map((inParam) => { - const injectParam: InjectionParameter = { - ...inParam._tsData, - type: inParam._tsData?.type || [], - name: inParam._tsData?.name || 'unknown', + if (!version) { + return null + } + + const namespace = this.parent.namespace(name, version) + + if (namespace) { + if (!this.imports.has(namespace.name)) { + this.imports.set(namespace.name, namespace.version) } - return injectParam - }) + } - return this.girFactory.newTsSignalMethods( - girSignal._tsData?.name, - girSignal._tsData?.tsCallbackInterface?.name, - inParams, - parentClass, - this.config.environment, - false, - ) + return namespace } - /** - * Generates signal methods for the GObject properties of a gir class element - * @param girClass - */ - private getClassPropertySignalsMethods( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - if (!girClass._tsData) { - throw new Error(NO_TSDATA('getClassPropertySignalsMethods')) - } - - const tsMethods: TsMethod[] = [] - - const propertyNames = this.getClassNonStaticPropertyNames(girClass) - const namespacePrefix = this.namespace === 'GObject' ? '' : 'GObject.' - - // TODO: Signals: Generate SignalMethods instead of direct types - for (const propertyName of propertyNames) { - let callbackType = 'any' - if (this.config.environment === 'gjs') { - const objParam = `$obj: ${girClass._tsData.name}` - // TODO: create arrowType object instead of a pure string type, see Pango-1.0.Pango.FontMapClass.load_font for an example - callbackType = `((${objParam}, pspec: ${namespacePrefix}ParamSpec) => void)` - } - tsMethods.push( - ...this.girFactory.newTsSignalMethods( - `notify::${propertyName}`, - callbackType, - [], - girClass._tsData, - this.config.environment, - ), - ) - } - - return tsMethods - } - - private getGeneralSignalsMethods(parentClass: TsClass) { - return this.girFactory.newTsSignalMethods(undefined, undefined, [], parentClass, this.config.environment, true) - } - - private setSignalTsData( - girSignal: GirSignalElement, - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - if (!girClass._tsData) { - throw NO_TSDATA('setSignalTsData') - } - - if (!girSignal._tsData) { - girSignal._tsData = { - ...this.getSignalCallbackTsData(girSignal, girClass), - tsCallbackInterface: this.getSignalCallbackInterfaceTsData(girSignal, girClass), - tsMethods: [], - girTypeName: 'signal', - tsTypeName: this.girFactory.girTypeNameToTsTypeName('signal', false), - doc: this.getTsDoc(girSignal), - overloads: [], - } - - girSignal._tsData.doc.tags.push( - ...this.getTsDocGirElementTags(girSignal._tsData.tsTypeName, girSignal._tsData.girTypeName), - ) - // TODO: this are the callback parameters - girSignal._tsData.doc.tags.push(...this.getTsDocInParamTags(girSignal._tsData?.inParams)) - girSignal._tsData.doc.tags.push(...this.getTsDocReturnTags(girSignal)) - - if (!girSignal._tsData) { - throw NO_TSDATA('setSignalTsData') - } - - girSignal._tsData.tsMethods = this.getClassSignalMethodsTsData(girSignal, girClass._tsData) - } - - return girSignal._tsData - } - - private fixEnumerationDuplicateIdentifier(girEnum: GirEnumElement | GirBitfieldElement) { - if (!girElementIsIntrospectable(girEnum)) return girEnum - - if (!girEnum._tsData) { - throw new Error(NO_TSDATA('fixEnumerationDuplicateIdentifier')) - } + assertInstalledImport(name: string): GirModule { + const namespace = this._getImport(name) - if (!girEnum.member?.length) { - return girEnum + if (!namespace) { + throw new Error(`Failed to import ${name} in ${this.name}, not installed or accessible.`) } - const memberNames: string[] = [] - - for (const girEnumMember of girEnum.member) { - if (!girEnumMember._tsData) { - throw new Error(NO_TSDATA('fixEnumerationDuplicateIdentifier')) - } - if (memberNames.find((name) => name === girEnumMember._tsData?.name)) { - const renamed = '_' + girEnumMember._tsData.name - this.log.warn(WARN_DUPLICATE_ENUM_IDENTIFIER(girEnumMember._tsData.name, renamed)) - girEnumMember._tsData.name = renamed - } - memberNames.push(girEnumMember._tsData.name) - } - return girEnum + return namespace } - private getEnumerationMemberTsData(girEnumMember: GirMemberElement, girTypeName: TypeGirEnumerationMember) { - const memberName = girEnumMember.$.name || girEnumMember.$['glib:nick'] || girEnumMember.$['c:identifier'] - if (!girElementIsIntrospectable(girEnumMember, memberName)) return undefined - - if (girEnumMember._tsData) { - // this.log.warn('[getEnumerationMemberTsData] _tsData already set!') - return girEnumMember._tsData - } - - const name = this.transformation.transformEnumMember(memberName) - const tsData: TsMember = { - name, - girTypeName, - tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false), - doc: this.getTsDoc(girEnumMember), - } - - tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName)) - - return tsData + getImports(): [string, string][] { + return [...this.imports.entries()].sort(([[a], [b]]) => a.localeCompare(b)) } - private getEnumerationTsData(girEnum: GirEnumElement | GirBitfieldElement, girTypeName: 'bitfield' | 'enum') { - if (!girElementIsIntrospectable(girEnum)) return undefined - - if (girEnum._tsData) { - // this.log.warn('[getEnumerationMemberTsData] _tsData already set!') - return girEnum._tsData - } - - // E.g. the NetworkManager-1.0 has enum names starting with 80211 - const name = this.transformation.transformEnumName(girEnum) - - const tsData: TsEnum = { - name, - girTypeName, - tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false), - doc: this.getTsDoc(girEnum), - } - - tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName)) - - return tsData + addImport(ns_name: string) { + this._getImport(ns_name) } - private getAliasTsData(girAlias: GirAliasElement, tsClass: TsClass | null) { - if (!girElementIsIntrospectable(girAlias)) return undefined - - const girTypeName = 'alias' - - if (girAlias._tsData) { - // this.log.warn('[getEnumerationMemberTsData] _tsData already set!') - return girAlias._tsData - } + getMembers(name: string): IntrospectedNamespaceMember[] { + const members = this.members.get(name) - const { type: typeName } = this.getTsType(girAlias, tsClass, girTypeName) - const name = girAlias.$.name - const tsData: TsAlias = { - name, - type: typeName, - girTypeName, - tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false), + if (Array.isArray(members)) { + return [...members] } - return tsData + return members ? [members] : [] } - private getConstantTsData(girConst: GirConstantElement, tsClass: TsClass | null) { - if (!girElementIsIntrospectable(girConst)) return undefined + getMemberWithoutOverrides(name: string) { + if (this.members.has(name)) { + const member = this.members.get(name) - if (girConst._tsData) { - // this.log.warn('[getConstantTsData] _tsData already set!') - return girConst._tsData - } - - let tsData: TsVar | undefined = this.getVariableTsData( - girConst, - 'constant', - 'constant', - tsClass, - false, - false, - false, - ) - if (tsData?.name) { - if (!this.constNames[tsData.name]) { - this.constNames[tsData.name] = girConst - } else { - this.log.warn(WARN_CONSTANT_ALREADY_EXPORTED(tsData.name)) - tsData = undefined + if (!Array.isArray(member)) { + return member } - } - return tsData - } - // FIXME: https://github.com/gjsify/ts-for-gir/issues/145 - // FIXME: https://github.com/gjsify/ts-for-gir/issues/131 - private getClassConstructPropsTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - constructPropNames: LocalNames, - ) { - const constructProps: GirPropertyElement[] = [] - const girProperties = (girClass as GirClassElement | GirInterfaceElement).property - if (!girProperties?.length) { - return constructProps + return null } - for (const girProp of girProperties) { - if (!girElementIsIntrospectable(girProp) || !girProp.$.name) continue - // Do not modify the original girProp, create a new one by clone `girProp` to `girConstrProp` - const girConstrProp = clone(girProp) - - if (!girClass._tsData) continue - - if (!girConstrProp._tsData) { - girConstrProp._tsData = this.getPropertyTsData( - girConstrProp, - 'property', - 'constructor-property', - girClass._tsData, - true, - true, - true, - 0, - ) - } - - if (!girConstrProp._tsData) { - continue - } - - const localName = this.checkOrSetLocalName(girConstrProp, constructPropNames, 'property') - if (!localName?.added) { - continue - } + const resolvedName = this._resolve_names.get(name) + if (resolvedName) { + const member = this.members.get(resolvedName.name) - if (girConstrProp._fullSymName) { - this.symTable.set(this.allDependencies, girConstrProp._fullSymName, girConstrProp) + if (!Array.isArray(member)) { + return member } - constructProps.push(girConstrProp) - - // Clone property with the name in underscores, see https://github.com/gjsify/ts-for-gir/issues/138 - // const underscoresProperty = this.clonePropertyForUnderscores(girConstrProp) - // if (underscoresProperty && underscoresProperty._fullSymName) { - // girProperties.push(underscoresProperty) - // this.symTable.set(this.allDependencies, underscoresProperty._fullSymName, underscoresProperty) - // } } - return constructProps + return null } - /** - * Some class/static methods are defined in a separate record which is not - * exported, but the methods are available as members of the JS constructor. - * In gjs one can use an instance of the object, a JS constructor or a GType - * as the method's instance-parameter. - * @see https://discourse.gnome.org/t/using-class-methods-like-gtk-widget-class-get-css-name-from-gjs/4001 - * @param girClass - */ - private getClassRecordMethods( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ): GirMethodElement[] { - const girMethods: GirMethodElement[] = [] - - if (!girClass.$.name) return girMethods - const fName = girClass.$.name + 'Class' - let rec = this.ns.record?.find((r) => r.$.name == fName) - if (!rec || !this.isGtypeStructFor(girClass, rec)) { - rec = this.ns.record?.find((r) => this.isGtypeStructFor(girClass, r)) - fName == rec?.$.name - } - if (!rec) return girMethods - - // Record methods - const methods = rec.method || [] - - for (const girMethod of methods) { - if (!girElementIsIntrospectable(girMethod) || !girClass._tsData) continue - - if (!girMethod._tsData) - girMethod._tsData = this.getFunctionTsData(girMethod, 'static-function', girClass._tsData, { - isStatic: true, - isArrowType: false, - isGlobal: false, - isVirtual: false, - returnType: null, - generics: [], - }) - - if (!girMethod._tsData) continue + assertClass(name: string): IntrospectedBaseClass { + const clazz = this.getClass(name) - if (girMethod._tsData) { - if (girMethod._fullSymName) this.symTable.set(this.allDependencies, girMethod._fullSymName, girMethod) - girMethods.push(girMethod) - } + if (!clazz) { + throw new Error(`Class ${name} does not exist in namespace ${this.name}.`) } - this.overloadPromisifiedFunctions(methods) - - return girMethods - } - - /** - * Instance methods - * @param girClass - * @param localNames - */ - private getClassMethodsTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - localNames: LocalNames, - ) { - const girMethods: GirMethodElement[] = [] - if (girClass.method) { - for (const girMethod of girClass.method) { - if (!girElementIsIntrospectable(girMethod) || !girClass._tsData) continue - - if (!girMethod._tsData) - girMethod._tsData = this.getFunctionTsData(girMethod, 'method', girClass._tsData, { - isStatic: false, - isArrowType: false, - isGlobal: false, - isVirtual: false, - returnType: null, - generics: [], - }) - - if (!girMethod._tsData) continue - - const localName = this.checkOrSetLocalName(girMethod, localNames, 'method') - if (localName?.added && localName.method) { - if (girMethod._fullSymName) - this.symTable.set(this.allDependencies, girMethod._fullSymName, girMethod) - girMethods.push(localName.method) - } - } - - this.overloadPromisifiedFunctions(girClass.method) - } - return girMethods + return clazz } - private getClassFieldsTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - localNames: LocalNames, - ) { - const girFields: GirFieldElement[] = [] - if (!girClass._tsData) { - this.log.warn(NO_TSDATA('setClassFieldsTsData')) - return girFields - } - - if (girClass.field) { - for (const girField of girClass.field) { - if (!girElementIsIntrospectable(girField)) continue - if (!girField._tsData) - girField._tsData = this.getVariableTsData( - girField, - 'field', - 'property', - girClass._tsData, - false, - false, - false, - ) - - if (!girField._tsData) { - continue - } + getClass(name: string): IntrospectedBaseClass | null { + const member = this.getMemberWithoutOverrides(name) - const localName = this.checkOrSetLocalName(girField, localNames, 'field') - if (localName?.added && localName.field) { - if (girField._fullSymName) this.symTable.set(this.allDependencies, girField._fullSymName, girField) - girFields.push(localName.field) - } - } + if (member instanceof IntrospectedBaseClass) { + return member } - - return girFields + return null } - private getGObjectProperties(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement) { - const girProperties: GirPropertyElement[] = [] - if (girClass._fullSymName && !STATIC_NAME_ALREADY_EXISTS.includes(girClass._fullSymName)) { - // Records, classes and interfaces all have a static name - const type = this.girFactory.newTsType({ type: 'string' }) - const staticNameProp = this.girFactory.newGirProperty({ - isStatic: true, - name: 'name', - type: [type], - girTypeName: 'property', - }) - girProperties.push(staticNameProp) - } + getEnum(name: string): IntrospectedEnum | null { + const member = this.getMemberWithoutOverrides(name) - if (girClass._tsData?.isDerivedFromGObject && girClass._module) { - if (this.config.environment === 'gjs') { - const type = this.girFactory.newTsType({ - // TODO: Type not as string - type: 'GObject.GType', - generics: this.girFactory.newGenerics([ - { - value: girClass._tsData.name, - }, - ]), - }) - const staticGTypeProp = this.girFactory.newGirProperty({ - isStatic: true, - name: '$gtype', - type: [type], - girTypeName: 'property', - }) - girProperties.push(staticGTypeProp) - } + if (member instanceof IntrospectedEnum) { + return member } - - return girProperties + return null } - /** - * Create a clone object of a property with the name in upper camel case - * See github.com/gjsify/ts-for-gir/issues/138 - * @param girProperty - * @returns - */ - private clonePropertyForUnderscores(girProperty: GirPropertyElement) { - // Only for GJS - if (this.config.environment === 'node') { - return undefined - } - - const propertyName = girProperty._tsData?.name - - if (!propertyName) { - return undefined - } - - const underscoresPropertyName = underscores(propertyName) - - // Nothing has changed - if (underscoresPropertyName === propertyName) { - return undefined - } + getAlias(name: string): IntrospectedAlias | null { + const member = this.getMemberWithoutOverrides(name) - const upperCamelCaseGirProperty = clone(girProperty) - upperCamelCaseGirProperty._tsData = clone(upperCamelCaseGirProperty._tsData) - if (!upperCamelCaseGirProperty._tsData) { - return undefined + if (member instanceof IntrospectedAlias) { + return member } - upperCamelCaseGirProperty._tsData.name = underscoresPropertyName - - upperCamelCaseGirProperty._fullSymName = upperCamelCaseGirProperty._fullSymName?.replace( - propertyName, - underscoresPropertyName, - ) - - return upperCamelCaseGirProperty + return null } - private getClassPropertiesTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - localNames: LocalNames, - ) { - const girProperties: GirPropertyElement[] = [] - const properties = (girClass as GirClassElement | GirInterfaceElement).property - if (properties) { - for (const girProperty of properties) { - if (!girElementIsIntrospectable(girProperty) || !girClass._tsData) continue - - girProperty._tsData = this.getPropertyTsData(girProperty, 'property', 'property', girClass._tsData) - if (!girProperty._tsData) continue - - { - const localName = this.checkOrSetLocalName(girProperty, localNames, 'property') - if (localName?.added && localName.property) { - if (girProperty._fullSymName) { - this.symTable.set(this.allDependencies, girProperty._fullSymName, girProperty) - } - - girProperties.push(localName.property) - } - } - - // Add a new property with the name in lower camel case, see https://github.com/gjsify/ts-for-gir/issues/138 - // { - // const underscoresProperty = this.clonePropertyForUnderscores(girProperty) - // if (underscoresProperty) { - // const localName = this.checkOrSetLocalName(underscoresProperty, localNames, 'property') - - // if (localName?.added && localName.property) { - // if (underscoresProperty._fullSymName) { - // this.symTable.set( - // this.allDependencies, - // underscoresProperty._fullSymName, - // underscoresProperty, - // ) - // } - - // girProperties.push(localName.property) - // } - // } - // } - } - } - return girProperties + hasSymbol(name: string) { + return this.members.has(name) } - private getClassNonStaticPropertyNames( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - const propertyNames: string[] = [] - - if (!girClass._tsData) { - return propertyNames - } - - const girProperties = girClass._tsData.properties - - if (girProperties.length > 0) { - for (const girProperty of girProperties) { - if (!girElementIsIntrospectable(girProperty)) continue - if ( - girProperty.$.name && - !propertyNames.includes(girProperty.$.name) && - !girProperty._tsData?.isStatic - ) { - propertyNames.push(girProperty.$.name) - } - } - } - - // Extended property names - for (const fullSymName of Object.keys(girClass._tsData.inherit)) { - const girProperties = girClass._tsData.inherit[fullSymName]?.class.properties - if (girProperties.length > 0) { - for (const girProperty of girProperties) { - if (!girElementIsIntrospectable(girProperty)) continue - if ( - girProperty.$.name && - !propertyNames.includes(girProperty.$.name) && - !girProperty._tsData?.isStatic - ) { - propertyNames.push(girProperty.$.name) - } - } - } - } - - // Implemented property names - for (const fullSymName of Object.keys(girClass._tsData.implements)) { - const girProperties = girClass._tsData.implements[fullSymName]?.interface.properties - if (girProperties.length > 0) { - for (const girProperty of girProperties) { - if (!girElementIsIntrospectable(girProperty)) continue - if ( - girProperty._tsData && - girProperty.$.name && - !propertyNames.includes(girProperty.$.name) && - !girProperty._tsData?.isStatic - ) { - propertyNames.push(girProperty.$.name) - } - } - } - } - - return propertyNames - } + resolveSymbolFromTypeName(name: string): string | null { + const resolvedName = this._resolve_names.get(name) - private getClassConstructorsTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - if (!girClass._tsData) { - throw new Error(NO_TSDATA('getClassConstructorsTsData')) - } - const girConstructors: GirConstructorElement[] = [] - - // JS constructor(s) - if (girClass._tsData?.isDerivedFromGObject) { - const constructorInParam: InjectionParameter = { - name: 'config', - type: [ - { - optional: true, - type: girClass._tsData.constructPropInterfaceName, - }, - ], - } - const realConstructor = this.girFactory.newGirFunction( - { - name: 'constructor', - isStatic: true, - inParams: [constructorInParam], - girTypeName: 'constructor', - }, - girClass._tsData, - ) - const initConstructor = this.girFactory.newGirFunction( - { - name: '_init', - inParams: [constructorInParam], - girTypeName: 'method', - }, - girClass._tsData, - ) - girConstructors.push(realConstructor, initConstructor) + if (!resolvedName) { + return null } - if (Array.isArray(girClass.constructor)) { - for (const girConstructor of girClass.constructor) { - if (!girElementIsIntrospectable(girConstructor)) continue - - girConstructor._tsData = this.getConstructorFunctionTsData(girClass._tsData, girConstructor) - - if (!girConstructor._tsData?.name) continue - - // Also add `new` pseudo constructors - const ADD_NEW_PSEUDO_CONSTRUCTOR = true - - // Inject an additional real constructor if static new(...) exists - if (girConstructor._tsData.name === 'new') { - const realConstructor = clone(girConstructor) - realConstructor._tsData = clone(realConstructor._tsData) - - if (realConstructor._tsData) { - realConstructor._tsData.overloads = [] - realConstructor.$.name = 'constructor' - realConstructor._tsData.name = 'constructor' - girConstructors.push(realConstructor) - } - - if (ADD_NEW_PSEUDO_CONSTRUCTOR) { - girConstructors.push(girConstructor) - } - } else { - girConstructors.push(girConstructor) - } - } + const member = this.members.get(resolvedName.name) + if (member instanceof IntrospectedBase) { + return member.name } - return girConstructors + return null } - private getClassVirtualMethodsTsData( - girClass: GirClassElement | GirInterfaceElement | GirUnionElement | GirRecordElement, - ) { - const methods: GirVirtualMethodElement[] = - (girClass as GirClassElement | GirInterfaceElement)['virtual-method'] || [] - const girMethods: GirVirtualMethodElement[] = [] - - for (const girVMethod of methods) { - if (!girElementIsIntrospectable(girVMethod) || !girClass._tsData) continue - - girVMethod._tsData = this.getFunctionTsData(girVMethod, 'virtual', girClass._tsData, { - isStatic: false, - isArrowType: false, - isGlobal: false, - isVirtual: true, - returnType: null, - generics: [], - }) - if (!girVMethod._tsData) continue - - if (girVMethod?._tsData?.name) { - girMethods.push(girVMethod) - } + findClassCallback(name: string): [string | null, string] { + const clazzes = Array.from(this.members.values()).filter( + (m): m is IntrospectedBaseClass => m instanceof IntrospectedBaseClass, + ) + const res = clazzes + .map<[IntrospectedBaseClass, IntrospectedClassCallback | undefined]>((m) => [ + m, + m.callbacks.find((c) => c.name === name || c.resolve_names.includes(name)), + ]) + .find((r): r is [IntrospectedBaseClass, IntrospectedClassCallback] => r[1] != null) + + if (res) { + return [res[0].name, res[1].name] + } else { + return [null, name] } - - return girMethods } /** - * - * @param girClass This is the class / interface the `parentClass` implements signals from - * @returns + * This is an internal method to add TypeScript + * comments when overrides use parts of the TypeScript standard + * libraries that are newer than default. */ - private getClassSignalsTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) { - const girSignals: GirSignalElement[] = [] - - const signals: GirSignalElement[] = - (girClass as GirClassElement | GirInterfaceElement).signal || - (girClass as GirClassElement | GirInterfaceElement)['glib:signal'] || - [] - if (signals) { - for (const girSignal of signals) { - girSignal._tsData = this.setSignalTsData(girSignal, girClass) - if (!girSignal._tsData) continue - if (girSignal._fullSymName) this.symTable.set(this.allDependencies, girSignal._fullSymName, girSignal) - - girSignals.push(girSignal) - } - } - return girSignals - } - - getClassParentObject( - parentName: string, - namespace: string, - type: 'parent' | 'prerequisite' | 'implements', - ): ClassParent { - let qualifiedParentName: string - let parentModName: string - - // WORKAROUND: Fix wrong parent names - if ( - (this.packageName === 'GstAudio-0.10' || this.packageName === 'ClutterGst-1.0') && - (parentName === 'GstBase.BaseTransform' || - parentName === 'GstBase.BaseSink' || - parentName === 'GstBase.PushSrc') - ) { - const rename = parentName.replace('GstBase.', 'Gst.') - this.log.warn(`[getClassParentObject] Rename parent class "${parentName}" -> "${rename}"`) - parentName = rename - } - - if (parentName === 'GraniteServicesSettingsSerializable') { - parentName = 'ServicesSettingsSerializable' - this.log.warn( - `[getClassParentObject] Rename parent class "GraniteServicesSettingsSerializable" -> "ServicesSettingsSerializable"`, - ) - } - - if (parentName.indexOf('.') < 0) { - qualifiedParentName = namespace + '.' + parentName - parentModName = namespace - } else { - qualifiedParentName = parentName - const split = parentName.split('.') - parentName = split[split.length - 1] - parentModName = split.slice(0, split.length - 1).join('.') - } - const localParentName = parentModName == namespace ? parentName : qualifiedParentName - - const dependencyExists = !!this.symTable.get(this.allDependencies, qualifiedParentName) - - const cls = this.getClassParent({ - qualifiedParentName, - parentName, - }) - - return { - qualifiedParentName, - localParentName, - type, - parentName, - cls, - dependencyExists, - // TODO: are there other types that can be inherited or implemented? - girTypeName: type === 'parent' ? 'class' : 'interface', - } - } - - private getClassParents(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement) { - const parents: ClassParent[] = [] - - if (!girClass._module?.namespace) { - throw new Error('Namespace not found!') - } - - if (!girClass._tsData) { - throw new Error(NO_TSDATA('getClassParents')) - } - - const prerequisites = (girClass as GirInterfaceElement)?.prerequisite - const implmts = (girClass as GirInterfaceElement)?.implements - - if (implmts) { - for (const implement of implmts) { - const parentName = implement.$?.name - if (!parentName) continue - const parent = this.getClassParentObject(parentName, girClass._module.namespace, 'implements') - if (parent.dependencyExists) { - parents.push(parent) - } - } - } - - if (prerequisites) { - for (const prerequisite of prerequisites) { - const parentName = prerequisite.$?.name - if (!parentName) continue - const parent = this.getClassParentObject(parentName, girClass._module.namespace, 'prerequisite') - if (parent.dependencyExists) { - parents.push(parent) - } - } - } - - if ((girClass as GirClassElement).$.parent) { - const parentName = (girClass as GirClassElement).$.parent - if (parentName) { - const parent = this.getClassParentObject(parentName, girClass._module.namespace, 'parent') - if (parent.dependencyExists) { - parents.push(parent) - } - } - } - - // Please reply: Do all interfaces always inherit from GObject.Object? - // If this is a interface and GObject.Object is not in the parents array, add GObject.Object to the parents - if (girClass._tsData.girTypeName === 'interface' && girClass._fullSymName !== 'GObject.Object') { - if (!parents.find((parent) => parent.qualifiedParentName === 'GObject.Object')) { - // TODO make sure this class exists in symTable - const gObjectObjectCls = - this.symTable.getByHand('GObject-2.0.GObject.Object') || undefined - const parent: ClassParent = { - qualifiedParentName: 'GObject.Object', - localParentName: girClass._module.namespace === 'GObject' ? 'Object' : 'GObject.Object', - type: 'parent', - parentName: 'Object', - cls: gObjectObjectCls, - dependencyExists: !!gObjectObjectCls, - girTypeName: 'class', - } - if (parent.dependencyExists) { - parents.push(parent) - } - } - } - - return parents - } - - private setClassBaseTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - girTypeName: TypeGirClass, - ) { - if (!girClass?.$?.name) return undefined - - const girModule: GirModule = girClass._module ? girClass._module : this - let className = this.transformation.transformClassName(girClass.$.name) - /** - * E.g. 'Gtk' - */ - const namespace = girModule.namespace - /** - * E.g. '3.0' - */ - const version = girModule.version - - let qualifiedName: string - if (!className.includes('.')) { - qualifiedName = namespace + '.' + className - } else { - qualifiedName = className - const split = className.split('.') - className = split[split.length - 1] - } - - girClass._tsData = { - name: className, - qualifiedName, - parents: [], - namespace, - version, - isAbstract: this.isAbstractClass(girClass), - localNames: {}, - constructPropNames: {}, - inheritConstructPropInterfaceNames: [], - constructPropInterfaceName: `${namespace}.${className}.ConstructorProperties`, - fields: [], - properties: [], - conflictProperties: [], - constructProps: [], - propertySignalMethods: [], - methods: [], - conflictMethods: [], - virtualMethods: [], - constructors: [], - staticFunctions: [], - signals: [], - generics: [], - inherit: {}, - implements: {}, - girTypeName, - tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false), - doc: this.getTsDoc(girClass), - } - - girClass._tsData.doc.tags.push( - ...this.getTsDocGirElementTags(girClass._tsData.tsTypeName, girClass._tsData.girTypeName), - ) - - girClass._tsData.parents = this.getClassParents(girClass) - - if (girClass._tsData.parents.length) { - for (const parent of girClass._tsData.parents) { - girClass._tsData.inheritConstructPropInterfaceNames.push( - `${parent.qualifiedParentName}.ConstructorProperties`, - ) - } - } - - girClass._tsData.isDerivedFromGObject = this.isDerivedFromGObject(girClass) - - return girClass._tsData + ___dts___addReference(reference: string) { + this.__dts__references ??= [] + this.__dts__references.push(reference) } - private setClassTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - girTypeName: TypeGirClass, - ): TsClass | undefined { - if (!girClass?.$?.name) return undefined + static load(repo: ParsedGir, config: GenerateConfig, registry: NSRegistry): GirModule { + const ns = repo.repository[0]?.namespace?.[0] - if (girClass._tsData) { - return girClass._tsData - } + if (!ns) throw new Error(`Missing namespace in ${repo.repository[0].package[0].$.name}`) - girClass._tsData = this.setClassBaseTsData(girClass, girTypeName) - if (!girClass._tsData) { - return undefined - } + const modName = ns.$['name'] + const version = ns.$['version'] - // BASE + // TODO: Hardcoding HarfBuzz here leads to issues when loading... + // Hardcode harfbuzz version for now... + // if (modName === 'HarfBuzz' && version === '0.0') { + // version = '2.0' + // } - if (girClass._tsData.isDerivedFromGObject) { - girClass._tsData.constructProps.push( - ...this.getClassConstructPropsTsData(girClass, girClass._tsData.constructPropNames), - ) + const options: LoadOptions = { + loadDocs: !config.noComments, + propertyCase: 'both', + environment: 'gjs', + verbose: config.verbose, } - girClass._tsData.constructors.push(...this.getClassConstructorsTsData(girClass)) - girClass._tsData.staticFunctions.push(...this.getClassStaticFunctionsTsData(girClass, girClass._tsData)) - - girClass._tsData.fields.push(...this.getClassFieldsTsData(girClass, girClass._tsData.localNames)) - - girClass._tsData.properties.push(...this.getClassPropertiesTsData(girClass, girClass._tsData.localNames)) - girClass._tsData.methods.push(...this.getClassMethodsTsData(girClass, girClass._tsData.localNames)) - girClass._tsData.virtualMethods.push(...this.getClassVirtualMethodsTsData(girClass)) - girClass._tsData.signals.push(...this.getClassSignalsTsData(girClass)) - - girClass._tsData.properties.push(...this.getGObjectProperties(girClass)) - - // Copy fields, properties, methods, virtual methods and signals from inheritance tree - this.traverseInheritanceTree(girClass, girClass._tsData.girTypeName, (extendsCls, depth) => { - if (!girClass._tsData || !extendsCls._tsData || !extendsCls._fullSymName || !extendsCls._module) { - return - } - - if (girClass._fullSymName === extendsCls._fullSymName) { - return - } - - const key = extendsCls._module.packageName + '.' + extendsCls._fullSymName - if (girClass._tsData.inherit[key]) return - - girClass._tsData.inherit[key] = { - depth, - class: extendsCls._tsData, - } - }) - - // Copy properties, methods and signals from implemented interface - this.forEachInterface(girClass, girClass._tsData.girTypeName, (iface, depth) => { - if (!girClass._tsData || !iface._tsData || !iface._fullSymName || !iface._module) { - return - } - - if (girClass._fullSymName === iface._fullSymName) { - return - } - - const key = iface._module.packageName + '.' + iface._fullSymName - if (girClass._tsData.implements[key]) return - - girClass._tsData.implements[key] = { - depth, - interface: iface._tsData, - } - }) - - this.inject.toClass(girClass) - - girClass._tsData.propertySignalMethods.push( - ...this.getClassPropertySignalsMethods(girClass), - ...this.getGeneralSignalsMethods(girClass._tsData), - ) - - if (this.config.fixConflicts) { - this.conflictResolver.repairClass(girClass) + if (!modName) { + throw new Error('Invalid GIR file: no namespace name specified.') } - return girClass._tsData - } - - private isDerivedFromGObject( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ): boolean { - if (typeof girClass._tsData?.isDerivedFromGObject === 'boolean') return girClass._tsData.isDerivedFromGObject - let ret = false - - const onClassOrInterface = ( - cls: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ) => { - if (cls._tsData?.isDerivedFromGObject === true || cls._fullSymName === 'GObject.Object') { - ret = true - } + if (!version) { + throw new Error('Invalid GIR file: no version name specified.') } - if (!girClass._tsData) throw new Error(NO_TSDATA('isDerivedFromGObject')) - this.traverseInheritanceTree(girClass, girClass._tsData.tsTypeName, onClassOrInterface) - this.forEachInterface(girClass, girClass._tsData.tsTypeName, onClassOrInterface) - return ret - } - private getClassParent(parent: Pick) { - let parentPtr: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement | undefined = - undefined - if (this.symTable.get(this.allDependencies, parent.qualifiedParentName)) { - parentPtr = - (this.symTable.get(this.allDependencies, parent.qualifiedParentName) as GirClassElement) || undefined - } + const c_prefix = ns.$?.['c:symbol-prefixes']?.split(',') ?? [] - if (!parentPtr && parent.parentName == 'Object') { - parentPtr = (this.symTable.getByHand('GObject-2.0.GObject.Object') as GirClassElement) || undefined + if (options.verbose) { + console.debug(`Parsing ${modName}...`) } - return parentPtr - } - - private traverseInheritanceTree( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - gitTypeName: TypeGirClass, - callback: ( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - depth: number, - ) => void, - depth = 0, - recursive = true, - ): void { - if (!girClass.$.name) return - if (!girClass._tsData) girClass._tsData = this.setClassTsData(girClass, gitTypeName) - if (!girClass._tsData) return - - callback(girClass, depth) - - const parents = girClass._tsData.parents - if (recursive && parents.length) { - ++depth - - if (depth >= MAX_CLASS_PARENT_DEPTH) { - this.log.error('[traverseInheritanceTree] Maximum recursion depth reached') - return - } + const building = new GirModule(repo.repository[0], modName, version, c_prefix, config) + building.parent = registry + // Set the namespace object here to prevent re-parsing the namespace if + // another namespace imports it. + registry.mapping.set(modName, version, building) - for (const parent of parents) { - if (!parent.parentName || parent.type !== 'parent') { - continue - } + const includes = repo.repository[0].include || [] - if (parent.cls) { - if (parent.cls === girClass) { - this.log.warn('[traverseInheritanceTree] A class cannot inherit itself') - continue + includes + .map((i) => [i.$.name, i.$.version] as const) + .forEach(([name, version]) => { + if (version) { + if (options.verbose) { + console.debug(`Adding dependency ${name} ${version}...`) } - this.traverseInheritanceTree(parent.cls, parent.girTypeName, callback, depth, recursive) - } - } - } - } - - private forEachInterface( - girIface: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - girTypeName: TypeGirClass, - callback: ( - cls: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - depth: number, - ) => void, - recursive = true, - depth = 0, - ): void { - if (!girIface.$.name) return - if (!girIface._tsData) girIface._tsData = this.setClassTsData(girIface, girTypeName) - if (!girIface._tsData) { - throw new Error(NO_TSDATA('forEachInterface')) - } - - const parents = girIface._tsData.parents - if (parents.length) { - ++depth - for (const parent of parents) { - if (!parent.parentName || parent.type === 'parent') { - continue - } - - if (parent.cls) { - callback(parent.cls as GirInterfaceElement, depth) - // iface's prerequisite is also an interface, or it's - // a class and we also want to recurse classes - - if (recursive) - this.forEachInterface( - parent.cls as GirInterfaceElement, - parent.girTypeName, - callback, - recursive, - depth, - ) - } - } - } - } - - /** - * - * @param girElement - * @param localNames Can be (constructor) properties, fields or methods - * @param type - */ - private checkOrSetLocalName( - girElement: - | GirMethodElement - | GirPropertyElement - | GirFieldElement - | GirConstructorElement - | GirFunctionElement, - localNames: LocalNames, - type: LocalNameType, - ): LocalNameCheck | null { - let isOverloadable = false - - if (!girElement._tsData) { - return null - } - - const name = girElement._tsData?.name - - if (!name) { - return null - } - - // Methods are overloadable by typescript - // TODO Add support for properties - if (type === 'method') { - isOverloadable = true - } - - // Only names of the same type are overloadable - if (localNames[name]?.type && localNames[name].type !== type) { - // In GIO there are some methods and properties with the same name - // E.g. on `WebKit2.WebView.isLoading` and `WebKit2.WebView.isLoading()` - // See Gjs doc https://gjs-docs.gnome.org/webkit240~4.0_api/webkit2.webview#property-is_loading - // TODO prefer functions over properties (Overwrite the properties with the functions if they have the same name) - - return null - } - - // If name is found in localNames this variable was already defined - if (localNames?.[name]?.[type]?._tsData) { - // Ignore duplicates with the same type - // TODO should we use `this.functionSignaturesMatch` here? - - if (type === 'method') { - const tsMethod1 = (girElement as GirMethodElement)._tsData - const tsMethod2 = (localNames[name][type] as GirMethodElement)._tsData - if (!tsMethod1 || !tsMethod2) { - return null + building.default_imports.set(name, version) } - // if (ConflictResolver.functionConflict(tsMethod1, tsMethod2)) { - // return null - // } - } else { - // TODO better handling of property and field - if (isEqual(localNames[name][type]?._tsData, girElement._tsData)) { - return null - } - } - - // Ignore if current method is not overloadable - if (!isOverloadable) { - return null - } - } + }) - localNames[name] = localNames[name] || {} - const localName: LocalName = { - ...localNames[name], - [type]: girElement, - type, + const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { + return !building.hasImport(el.name) } - localNames[name] = localName - return { ...localName, added: true } - } - - private isGtypeStructFor( - e: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - rec: GirRecordElement, - ) { - const isFor = rec.$['glib:is-gtype-struct-for'] - return isFor && isFor == e.$.name - } - - /** - * E.g GObject.ObjectClass is a abstract class and required by UPowerGlib-1.0, UDisks-2.0 and others - * @param girClass - * @returns `true` if this is this a abstract class. - */ - private isAbstractClass(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement) { - return girClass.$?.['glib:is-gtype-struct-for'] ? true : false - } - - /** - * - * @param girClass - * @returns - */ - private getOtherStaticFunctions( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - ): GirFunctionElement[] { - const girFunctions: GirFunctionElement[] = [] - - if (!girClass._tsData) return girFunctions - - if (girClass.function?.length) { - for (const girFunction of girClass.function) { - girFunction._tsData = this.getFunctionTsData(girFunction, 'static-function', girClass._tsData, { - isStatic: true, - isArrowType: false, - isGlobal: false, - isVirtual: false, - returnType: null, - generics: [], + if (ns.enumeration) { + // Get the requested enums + ns.enumeration + ?.map((enumeration) => { + if (enumeration.$['glib:error-domain']) { + return IntrospectedError.fromXML(enumeration, building, options) + } else { + return IntrospectedEnum.fromXML(enumeration, building, options) + } }) - - if (!girFunction._tsData?.name) continue - if (girFunction._tsData.name.startsWith('new')) continue - - girFunctions.push(girFunction) - } - } - return girFunctions - } - - private getStaticNewFunctions( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - parentClass: TsClass, - ): Array { - const girFunctions: Array = [] - if (girClass.function?.length) { - for (const girFunction of girClass.function) { - girFunction._tsData = this.getConstructorFunctionTsData(parentClass, girFunction) - if (!girFunction._tsData?.name.startsWith('new')) continue - girFunctions.push(girFunction) - } + .forEach((c) => building.members.set(c.name, c)) + } + + // Constants + if (ns.constant) { + ns.constant + ?.filter(isIntrospectable) + .map((constant) => IntrospectedConstant.fromXML(constant, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + // Get the requested functions + if (ns.function) { + ns.function + ?.filter(isIntrospectable) + .map((func) => IntrospectedFunction.fromXML(func, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + if (ns.callback) { + ns.callback + ?.filter(isIntrospectable) + .map((callback) => IntrospectedCallback.fromXML(callback, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + if (ns['glib:boxed']) { + ns['glib:boxed'] + ?.filter(isIntrospectable) + .map( + (boxed) => + new IntrospectedAlias({ + name: boxed.$['glib:name'], + namespace: building, + type: new NullableType(ObjectType), + }), + ) + .forEach((c) => building.members.set(c.name, c)) } - return girFunctions - } - - /** - * Static methods, and - * @param girClass - * @param constructorTypeName Used to overwrite the constructor return type - * @param useReference This value should be `false` for inherited and implemented classes / interfaces. - * Otherwise other modules would overwrite the return value of the constructor methods - */ - private getClassStaticFunctionsTsData( - girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, - parentClass: TsClass, - ) { - const girStaticFuncs: Array = [] - girStaticFuncs.push(...this.getStaticNewFunctions(girClass, parentClass)) - girStaticFuncs.push(...this.getOtherStaticFunctions(girClass)) - girStaticFuncs.push(...this.getClassRecordMethods(girClass)) - - return girStaticFuncs - } - - private setModuleTsData() { - if (this.ns.enumeration) { - for (const girEnum of this.ns.enumeration) { - if (girEnum.member) { - for (const girEnumMember of girEnum.member) { - girEnumMember._tsData = this.getEnumerationMemberTsData(girEnumMember, 'enum-member') - if (!girEnumMember._tsData) continue - } - } - girEnum._tsData = this.getEnumerationTsData(girEnum, 'enum') - this.fixEnumerationDuplicateIdentifier(girEnum) - if (!girEnum._tsData) continue - } + // Bitfield is a type of enum + if (ns.bitfield) { + ns.bitfield + ?.filter(isIntrospectable) + .map((field) => IntrospectedEnum.fromXML(field, building, options, true)) + .forEach((c) => building.members.set(c.name, c)) } - if (this.ns.bitfield) - for (const girBitfield of this.ns.bitfield) { - if (girBitfield.member) - for (const girEnumMember of girBitfield.member) { - girEnumMember._tsData = this.getEnumerationMemberTsData(girEnumMember, 'bitfield-member') - } - girBitfield._tsData = this.getEnumerationTsData(girBitfield, 'bitfield') - if (!girBitfield._tsData) continue - this.fixEnumerationDuplicateIdentifier(girBitfield) - } - - if (this.ns.constant) - for (const girConst of this.ns.constant) { - girConst._tsData = this.getConstantTsData(girConst, null) - if (!girConst._tsData) continue - } - - if (this.ns.function) { - for (const girFunc of this.ns.function) { - girFunc._tsData = this.getFunctionTsData(girFunc, 'function', null, { - isStatic: false, - isArrowType: false, - isGlobal: true, - isVirtual: false, - returnType: null, - generics: [], + // The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y) + // to the name of the enum (Button) to resolve references (Gtk.Button.Y) + Array.from(building.members.values()) + .filter((m): m is IntrospectedEnum => m instanceof IntrospectedEnum) + .forEach((m) => { + m.members.forEach((member) => { + building.enum_constants.set(member.c_identifier, [m.name, member.name] as const) }) - if (!girFunc._tsData) continue - } + }) - this.overloadPromisifiedFunctions(this.ns.function) + // Get the requested classes + if (ns.class) { + ns.class + ?.filter(isIntrospectable) + .map((klass) => IntrospectedClass.fromXML(klass, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + if (ns.record) { + ns.record + ?.filter(isIntrospectable) + .map((record) => IntrospectedRecord.fromXML(record, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + if (ns.union) { + ns.union + ?.filter(isIntrospectable) + .map((union) => IntrospectedRecord.fromXML(union, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + if (ns.interface) { + ns.interface + ?.map((inter) => IntrospectedInterface.fromXML(inter, building, options)) + .filter(importConflicts) + .forEach((c) => building.members.set(c.name, c)) + } + + if (ns.alias) { + type NamedType = GirType & { $: { name: string } } + + ns.alias + ?.filter(isIntrospectable) + // Avoid attempting to alias non-introspectable symbols. + .map((b) => { + b.type = b.type + ?.filter((t): t is NamedType => !!(t && t.$.name)) + .map((t) => { + if ( + t.$.name && + !building.hasSymbol(t.$.name) && + !isPrimitiveType(t.$.name) && + !t.$.name.includes('.') + ) { + return { $: { name: 'unknown', 'c:type': 'unknown' } } as GirType + } + + return t + }) + + return b + }) + .map((alias) => IntrospectedAlias.fromXML(alias, building, options)) + .filter((alias): alias is IntrospectedAlias => alias != null) + .forEach((c) => building.members.set(c.name, c)) } - if (this.ns.callback) - for (const girCallback of this.ns.callback) { - girCallback._tsData = this.setCallbackTsData(girCallback, null) - } - - if (this.ns.interface) - for (const girIface of this.ns.interface) { - girIface._tsData = this.setClassTsData(girIface, 'interface') - } - - if (this.ns.class) - for (const girClass of this.ns.class) { - girClass._tsData = this.setClassTsData(girClass, 'class') - if (!girClass._tsData) continue - } - - if (this.ns.record) - for (const girRecord of this.ns.record) { - girRecord._tsData = this.setClassTsData(girRecord, 'record') - if (!girRecord._tsData) continue - } + building.namespace = building.ns.name + building.version = building.ns.version + building.packageName = `${building.namespace}-${building.version}` + building.libraryVersion = new LibraryVersion(ns.constant, building.version) + building.transformation = new Transformation(config) - if (this.ns.union) - for (const girUnion of this.ns.union) { - girUnion._tsData = this.setClassTsData(girUnion, 'union') - if (!girUnion._tsData) continue - } + building.log = new Logger(config.environment, config.verbose, building.packageName || 'GirModule') + building.conflictResolver = new ConflictResolver(config.environment, config.verbose) + building.inject = new Injector(building.config.environment) + building.importNamespace = building.transformation.transformModuleNamespaceName(building.packageName) + building.importName = building.transformation.transformImportName(building.packageName) + building.symTable = new SymTable(building.config, building.packageName, building.namespace) - if (this.ns.alias) { - for (const girAlias of this.ns.alias) { - // GType is not a number in GJS - if (this.packageName !== 'GObject-2.0' || girAlias.$.name !== 'Type') - girAlias._tsData = this.getAliasTsData(girAlias, null) - if (!girAlias._tsData) continue - } - } + return building } /** - * TODO: find better name for this method - * @param fullTypeName - * @returns + * Start processing the typescript data */ - private fullTypeLookupWithNamespace(fullTypeName: string) { - let resValue = '' - let namespace = '' - - // Check overwrites first - if (!resValue && fullTypeName && FULL_TYPE_MAP(this.config.environment, fullTypeName)) { - resValue = FULL_TYPE_MAP(this.config.environment, fullTypeName) || '' - } - - // Only use the fullTypeName as the type if it is found in the symTable - if (!resValue && this.symTable.get(this.allDependencies, fullTypeName)) { - if (fullTypeName.startsWith(this.namespace + '.')) { - resValue = removeNamespace(fullTypeName, this.namespace) - resValue = this.transformation.transformTypeName(resValue) - // TODO: check if resValue is a class, enum or interface before transformClassName - resValue = this.transformation.transformClassName(resValue) - namespace = this.namespace - resValue = namespace + '.' + resValue - } else { - const resValues = fullTypeName.split('.') - resValues.map((name) => this.transformation.transformTypeName(name)) - // TODO: check if resValues[resValues.length - 1] is a class, enum, interface before transformClassName - resValues[resValues.length - 1] = this.transformation.transformClassName( - resValues[resValues.length - 1], - ) - resValue = resValues.join('.') - namespace = resValues[0] + public start(girModules: GirModule[]) { + // GObject and Gio are following the version of GLib + if (this.namespace === 'GObject' || this.namespace === 'Gio') { + const glibModule = girModules.find((girModule) => girModule.namespace === 'GLib') + if (glibModule) { + this.libraryVersion = glibModule.libraryVersion } } - - return { - value: resValue, - namespace, - } } +} - private loadInheritance(inheritanceTable: InheritanceTable): void { - // Class hierarchy - for (const girClass of this.ns.class ? this.ns.class : []) { - let parent: string | null = null - if (girClass.$ && girClass.$.parent) parent = girClass.$.parent - if (!parent) continue - if (!girClass._fullSymName) continue - - if (!parent.includes('.')) { - parent = addNamespace(parent, this.namespace) - } - - const className = girClass._fullSymName - - const arr: string[] = inheritanceTable[className] || [] - arr.push(parent) - inheritanceTable[className] = arr - } +export const isIntrospectable = (e: { $?: GirInfoAttrs }) => + !e || !e.$ || !e.$.introspectable || e.$.introspectable === '1' +export const isDeprecated = (e: { $: GirInfoAttrs }) => e && e.$ && e.$.deprecated === '1' +export const deprecatedVersion = (e: { $: GirInfoAttrs }) => e?.$?.['deprecated-version'] +export const introducedVersion = (e: { $: GirInfoAttrs }) => e?.$?.version - // Class interface implementations - for (const girClass of this.ns.class ? this.ns.class : []) { - if (!girClass._fullSymName) continue +export function promisifyNamespaceFunctions(namespace: GirModule) { + return namespace.members.forEach((node) => { + if (!(node instanceof IntrospectedFunction)) return - const names: string[] = [] + if (node.parameters.length < 1) return - if (girClass.implements) { - for (const girImplements of girClass.implements) { - if (girImplements.$.name) { - let name: string = girImplements.$.name - if (!name.includes('.')) { - name = girClass._fullSymName.substring(0, girClass._fullSymName.indexOf('.') + 1) + name - } - names.push(name) - } - } - } + const last_param = node.parameters[node.parameters.length - 1] - if (names.length > 0) { - const className = girClass._fullSymName - const arr: string[] = inheritanceTable[className] || [] - inheritanceTable[className] = arr.concat(names) - } - } - } + if (!last_param) return - private loadTypes(): void { - if (this.ns.bitfield) this.annotateAndRegisterGirElement(this.ns.bitfield) - if (this.ns.callback) this.annotateAndRegisterGirElement(this.ns.callback) - if (this.ns.class) this.annotateAndRegisterGirElement(this.ns.class) - if (this.ns.constant) this.annotateAndRegisterGirElement(this.ns.constant) - if (this.ns.enumeration) this.annotateAndRegisterGirElement(this.ns.enumeration) - if (this.ns.function) this.annotateAndRegisterGirElement(this.ns.function) - if (this.ns.interface) this.annotateAndRegisterGirElement(this.ns.interface) - if (this.ns.record) this.annotateAndRegisterGirElement(this.ns.record) - if (this.ns.union) this.annotateAndRegisterGirElement(this.ns.union) - if (this.ns.alias) this.annotateAndRegisterGirElement(this.ns.alias) - - if (this.ns.callback) for (const girCallback of this.ns.callback) this.annotateFunctionArguments(girCallback) - - for (const girClass of this.ns.class || []) { - this.annotateClass(girClass, 'class') - } - for (const girClass of this.ns.record || []) { - this.annotateClass(girClass, 'record') - } - for (const girClass of this.ns.interface || []) { - this.annotateClass(girClass, 'interface') - } + const last_param_unwrapped = last_param.type.unwrap() - if (this.ns.function) this.annotateFunctions(this.ns.function) - if (this.ns.callback) this.annotateFunctions(this.ns.callback) + if (!(last_param_unwrapped instanceof ClosureType)) return - if (this.ns.constant) this.annotateVariables(this.ns.constant) - } + const internal = last_param_unwrapped.type - /** - * Before processing the typescript data, each module should be initialized first. - * This is done in the `GenerationHandler`. - */ - public init(inheritanceTable: InheritanceTable) { - this.loadTypes() - this.loadInheritance(inheritanceTable) - } + if (internal instanceof TypeIdentifier && internal.is('Gio', 'AsyncReadyCallback')) { + const async_res = [ + ...Array.from(namespace.members.values()).filter( + (m): m is IntrospectedFunction => m instanceof IntrospectedFunction, + ), + ].find((m) => m.name === `${node.name.replace(/_async$/, '')}_finish` || m.name === `${node.name}_finish`) + + if (async_res) { + const async_parameters = node.parameters.slice(0, -1).map((p) => p.copy()) + const sync_parameters = node.parameters.map((p) => p.copy({ isOptional: false })) + const output_parameters = async_res.output_parameters + + let async_return = new PromiseType(async_res.return()) + + if (output_parameters.length > 0) { + const raw_return = async_res.return() + if (raw_return.equals(VoidType) || raw_return.equals(BooleanType)) { + const [output_type, ...output_types] = output_parameters.map((op) => op.type) + async_return = new PromiseType(new TupleType(output_type, ...output_types)) + } else { + const [...output_types] = output_parameters.map((op) => op.type) + async_return = new PromiseType(new TupleType(raw_return, ...output_types)) + } + } - /** - * Start processing the typescript data - */ - public start(girModules: GirModule[]) { - // GObject and Gio are following the version of GLib - if (this.namespace === 'GObject' || this.namespace === 'Gio') { - const glibModule = girModules.find((girModule) => girModule.namespace === 'GLib') - if (glibModule) { - this.libraryVersion = glibModule.libraryVersion + namespace.members.set(node.name, [ + node.copy({ + parameters: async_parameters, + return_type: async_return, + }), + node.copy({ + parameters: sync_parameters, + }), + node.copy({ + return_type: new BinaryType(async_return, node.return()), + }), + ]) } } - - this.setModuleTsData() - } + }) } diff --git a/packages/lib/src/newlib/formatters/default.ts b/packages/lib/src/newlib/formatters/default.ts index fe08c4415..77c756fc8 100644 --- a/packages/lib/src/newlib/formatters/default.ts +++ b/packages/lib/src/newlib/formatters/default.ts @@ -1,7 +1,7 @@ import { Formatter } from "./formatter.js"; export class DefaultFormatter extends Formatter { - format(source: string): string { - return source; + format(source: string): Promise { + return Promise.resolve(source); } } diff --git a/packages/lib/src/newlib/formatters/formatter.ts b/packages/lib/src/newlib/formatters/formatter.ts index ee7c36d4b..f889904e0 100644 --- a/packages/lib/src/newlib/formatters/formatter.ts +++ b/packages/lib/src/newlib/formatters/formatter.ts @@ -1,3 +1,3 @@ export abstract class Formatter { - abstract format(source: string): string; + abstract format(source: string): Promise; } diff --git a/packages/lib/src/newlib/formatters/json.ts b/packages/lib/src/newlib/formatters/json.ts index f38765413..41ddf6b90 100644 --- a/packages/lib/src/newlib/formatters/json.ts +++ b/packages/lib/src/newlib/formatters/json.ts @@ -1,7 +1,7 @@ import { Formatter } from "./formatter.js"; export class JSONFormatter extends Formatter { - format(source: string): string { - return JSON.stringify(JSON.parse(source), null, 4); + format(source: string): Promise { + return Promise.resolve(JSON.stringify(JSON.parse(source), null, 4)); } } diff --git a/packages/lib/src/newlib/generators/dts-inline.ts b/packages/lib/src/newlib/generators/dts-inline.ts index 54c44c80d..84c650662 100644 --- a/packages/lib/src/newlib/generators/dts-inline.ts +++ b/packages/lib/src/newlib/generators/dts-inline.ts @@ -1,12 +1,12 @@ import { IntrospectedNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; -import { GirBase } from "../gir.js"; import { GenerationOptions } from "../types.js"; import { override as overrideGLib } from "./dts/glib.js"; import { override as overrideGObject } from "./dts/gobject.js"; import { override as overrideGio } from "./dts/gio.js"; import { DtsGenerator } from "./dts.js"; +import { IntrospectedNamespaceMember } from "../gir/base.js"; export class DtsInlineGenerator extends DtsGenerator { constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { @@ -51,17 +51,18 @@ export class DtsInlineGenerator extends DtsGenerator { const content = Array.from(node.members.values()) .map(m => { return `${(Array.isArray(m) ? m : [m]) - .map(m => (m.emit ? (m as GirBase).asString(this) : "")) + .map(m => (m.emit ? (m as IntrospectedNamespaceMember).asString(this) : "")) .join("\n")}`; }) .join("\n"); + const versionedImports = true; // TODO: options.versionedImports // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. const imports = Array.from(node.getImports()) .map( ([i, version]) => - `import * as ${i} from "${options.importPrefix}${i.toLowerCase()}${ - options.versionedImports ? version.toLowerCase().split(".")[0] : "" + `import * as ${i} from "${options.npmScope}${i.toLowerCase()}${ + versionedImports ? version.toLowerCase().split(".")[0] : "" }";` ) .join(`${"\n"}`); diff --git a/packages/lib/src/newlib/generators/dts-modules.ts b/packages/lib/src/newlib/generators/dts-modules.ts index 9f41ba6e5..ac142bf8b 100644 --- a/packages/lib/src/newlib/generators/dts-modules.ts +++ b/packages/lib/src/newlib/generators/dts-modules.ts @@ -1,12 +1,12 @@ import { IntrospectedNamespace, promisifyNamespaceFunctions } from "../gir/namespace.js"; -import { GirBase } from "../gir.js"; import { GenerationOptions } from "../types.js"; import { override as overrideGLib } from "./dts/glib.js"; import { override as overrideGObject } from "./dts/gobject.js"; import { override as overrideGio } from "./dts/gio.js"; import { DtsGenerator, versionImportFormat } from "./dts.js"; +import { IntrospectedNamespaceMember } from "../gir/base.js"; export class DtsModuleGenerator extends DtsGenerator { constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { @@ -51,21 +51,28 @@ export class DtsModuleGenerator extends DtsGenerator { const content = Array.from(node.members.values()) .map(m => { return `${(Array.isArray(m) ? m : [m]) - .map(m => (m.emit ? (m as GirBase).asString(this) : "")) + .map(m => { + const content = (m as IntrospectedNamespaceMember).asString(this); + + return m.emit ? content : ""; + }) .join("\n")}`; }) .join("\n"); - const pathSuffix = options.outputFormat === "folder" ? "/index.d.ts" : ".d.ts"; - const referenceType = options.importPrefix.startsWith(".") ? "path" : "types"; + const versionedImports = true; // TODO options.versionedImports + const pathSuffix = options.buildType === "lib" ? "/index.d.ts" : ".d.ts"; + const referenceType = + /*options.importPrefix.startsWith(".")*/ options.buildType === "lib" ? "path" : "types"; const references = [ ...(node.__dts__references ?? []), ...Array.from(node.getImports()).map( ([i, version]) => - `/// - `import ${i} from 'gi://${i}${options.versionedImports ? `?version=${version}` : ""}';` - ) + .map(([i, version]) => `import ${i} from 'gi://${i}${versionedImports ? `?version=${version}` : ""}';`) .join("\n"); const metadata = ` diff --git a/packages/lib/src/newlib/generators/dts.ts b/packages/lib/src/newlib/generators/dts.ts index fc6de3947..37cb366d8 100644 --- a/packages/lib/src/newlib/generators/dts.ts +++ b/packages/lib/src/newlib/generators/dts.ts @@ -13,14 +13,15 @@ import { } from "../gir/class.js"; import { IntrospectedConstant } from "../gir/const.js"; import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; -import { GirProperty, Field } from "../gir/property.js"; +import { IntrospectedProperty, IntrospectedField } from "../gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; import { IntrospectedFunction, IntrospectedConstructor, IntrospectedFunctionParameter, IntrospectedCallback, - IntrospectedDirectAllocationConstructor + IntrospectedDirectAllocationConstructor, + IntrospectedClassCallback } from "../gir/function.js"; import { IntrospectedClassFunction, @@ -40,12 +41,12 @@ import { Generic, ConflictType, TypeConflict, - BinaryType, - GirBase + BinaryType } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedAlias } from "../gir/alias.js"; -import { GenerationOptions } from "../types.js"; +import { AnyIntrospectedType } from "../gir/base.js"; +import { GenerateConfig } from "../../types/generate-config.js"; export function versionImportFormat(versionFormat: string, namespace: string, version: string) { const versionSlug = version.toLowerCase().split(".")[0]; @@ -59,7 +60,7 @@ export function versionImportFormat(versionFormat: string, namespace: string, ve } export abstract class DtsGenerator extends FormatGenerator { - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerateConfig) { super(namespace, options); } @@ -101,7 +102,7 @@ export abstract class DtsGenerator extends FormatGenerator { return ""; } - generateCallbackType(node: IntrospectedCallback): [string, string] { + generateCallbackType(node: IntrospectedCallback | IntrospectedClassCallback): [string, string] { const { namespace, options } = this; const Parameters = this.generateParameters(node.parameters); @@ -117,10 +118,14 @@ export abstract class DtsGenerator extends FormatGenerator { return ["", `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`]; } - generateCallback(node: IntrospectedCallback): string { + generateCallback(node: IntrospectedCallback | IntrospectedClassCallback): string { return `${this.docString(node)}export type ${node.name}${this.generateCallbackType(node).join(" = ")};`; } + generateClassCallback(node: IntrospectedClassCallback): string { + return this.generateCallback(node); + } + generateReturn(return_type: TypeExpression, output_parameters: IntrospectedFunctionParameter[]) { const { namespace, options } = this; @@ -189,11 +194,12 @@ ${this.docString(node)}export enum ${node.name} { const GLib = namespace.assertInstalledImport("GLib"); const GLibError = GLib.assertClass("Error"); - clazz.parent = GLibError.getType(); + clazz.superType = GLibError.getType(); // Manually construct a GLib.Error constructor. clazz.mainConstructor = new IntrospectedConstructor({ name: "new", + parent: clazz, parameters: [ new IntrospectedFunctionParameter({ name: "options", @@ -244,8 +250,8 @@ ${this.docString(node)}export enum ${node.name} { protected extends(node: IntrospectedBaseClass) { const { namespace: ns, options } = this; - if (node.parent) { - const ResolvedType = node.parent.resolveIdentifier(ns, options); + if (node.superType) { + const ResolvedType = node.superType.resolveIdentifier(ns, options); const Type = ResolvedType?.print(ns, options); if (Type) { @@ -253,7 +259,7 @@ ${this.docString(node)}export enum ${node.name} { } throw new Error( - `Unable to resolve type: ${node.parent.name} from ${node.parent.namespace} in ${node.namespace.name} ${node.namespace.version}` + `Unable to resolve type: ${node.superType.name} from ${node.superType.namespace} in ${node.namespace.name} ${node.namespace.version}` ); } @@ -438,11 +444,12 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${ } else { MainConstructor = `\nconstructor(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]);\n`; - if (!options.noInitTypes) { - MainConstructor += `_init(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]): void;\n`; - } else { - MainConstructor += "_init(...args: any[]): void;\n"; - } + // TODO: options migration + //if (!options.noInitTypes) { + // MainConstructor += `_init(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]): void;\n`; + //} else { + MainConstructor += "_init(...args: any[]): void;\n"; + //} } const ConstructorProps = filterConflicts( @@ -642,7 +649,7 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${ }`; } - generateField(node: Field): string { + generateField(node: IntrospectedField): string { const { namespace, options } = this; const { name, computed } = node; const invalid = isInvalid(name); @@ -670,7 +677,7 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${ .rootPrint(namespace, options)};`; } - generateProperty(node: GirProperty, construct: boolean = false): string { + generateProperty(node: IntrospectedProperty, construct: boolean = false): string { const { namespace, options } = this; const invalid = isInvalid(node.name); @@ -781,9 +788,9 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${ } } - docString(node: GirBase) { + docString(node: AnyIntrospectedType) { // TODO: Support node.doc not being a string? - return typeof node.doc === "string" && this.options.withDocs + return typeof node.doc === "string" && !this.options.noComments ? `/** ${node.doc .split("\n") @@ -832,7 +839,7 @@ ${node.doc } generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string { - const ConstructorFields = node.fields.map(field => field.asString(this)).join("\n"); + const ConstructorFields = node.parameters.map(param => param.asField().asString(this)).join("\n"); return ` constructor(properties?: Partial<{ diff --git a/packages/lib/src/newlib/generators/generator.ts b/packages/lib/src/newlib/generators/generator.ts index 1098be7c7..485b5763f 100644 --- a/packages/lib/src/newlib/generators/generator.ts +++ b/packages/lib/src/newlib/generators/generator.ts @@ -2,21 +2,22 @@ import { IntrospectedNamespace } from "../gir/namespace.js"; import { IntrospectedClass, IntrospectedRecord, IntrospectedInterface } from "../gir/class.js"; import { IntrospectedConstant } from "../gir/const.js"; import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; -import { GirProperty, Field } from "../gir/property.js"; +import { IntrospectedProperty, IntrospectedField } from "../gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; import { IntrospectedFunction, IntrospectedFunctionParameter, IntrospectedConstructor, IntrospectedCallback, - IntrospectedDirectAllocationConstructor + IntrospectedDirectAllocationConstructor, + IntrospectedClassCallback } from "../gir/function.js"; import { IntrospectedClassFunction } from "../gir/function.js"; import { IntrospectedStaticClassFunction } from "../gir/function.js"; import { IntrospectedVirtualClassFunction } from "../gir/function.js"; import { IntrospectedAlias } from "../gir/alias.js"; import { TypeExpression } from "../gir.js"; -import { GenerationOptions } from "../types.js"; +import { GenerateConfig } from "../../types/generate-config.js"; export interface GenericDescriptor { type: TypeExpression; @@ -25,9 +26,9 @@ export interface GenericDescriptor { export abstract class FormatGenerator { protected namespace: IntrospectedNamespace; - protected options: GenerationOptions; + protected options: GenerateConfig; - constructor(namespace: IntrospectedNamespace, options: GenerationOptions) { + constructor(namespace: IntrospectedNamespace, options: GenerateConfig) { this.namespace = namespace; this.options = options; } @@ -36,6 +37,7 @@ export abstract class FormatGenerator { abstract stringifyNamespace(node: IntrospectedNamespace): Promise; abstract generateCallback(node: IntrospectedCallback): T; + abstract generateClassCallback(node: IntrospectedClassCallback): T; abstract generateAlias(node: IntrospectedAlias): T; abstract generateConstructor(node: IntrospectedConstructor): T; abstract generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): T; @@ -48,8 +50,8 @@ export abstract class FormatGenerator { abstract generateConst(node: IntrospectedConstant): T; abstract generateClass(node: IntrospectedClass): T; abstract generateParameter(node: IntrospectedFunctionParameter): T; - abstract generateProperty(node: GirProperty, construct?: boolean): T; - abstract generateField(node: Field): T; + abstract generateProperty(node: IntrospectedProperty, construct?: boolean): T; + abstract generateField(node: IntrospectedField): T; abstract generateSignal(node: IntrospectedSignal, type?: IntrospectedSignalType): T; abstract generateFunction(node: IntrospectedFunction): T; abstract generateClassFunction(node: IntrospectedClassFunction): T; diff --git a/packages/lib/src/newlib/generators/json.ts b/packages/lib/src/newlib/generators/json.ts index c4637b6a6..c4b70949b 100644 --- a/packages/lib/src/newlib/generators/json.ts +++ b/packages/lib/src/newlib/generators/json.ts @@ -4,14 +4,15 @@ import { IntrospectedNamespace } from "../gir/namespace.js"; import { IntrospectedBaseClass, IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from "../gir/class.js"; import { IntrospectedConstant } from "../gir/const.js"; import { IntrospectedEnum, IntrospectedError, GirEnumMember } from "../gir/enum.js"; -import { GirProperty, Field } from "../gir/property.js"; +import { IntrospectedProperty, IntrospectedField } from "../gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "../gir/signal.js"; import { IntrospectedFunction, IntrospectedConstructor, IntrospectedFunctionParameter, IntrospectedCallback, - IntrospectedDirectAllocationConstructor + IntrospectedDirectAllocationConstructor, + IntrospectedClassCallback } from "../gir/function.js"; import { IntrospectedClassFunction, @@ -32,14 +33,14 @@ import { TupleType, NullableType, ClosureType, - GirBase, AnyFunctionType, TypeConflict, - GirMetadata + IntrospectedMetadata } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedAlias } from "../gir/alias.js"; import { GenerationOptions } from "../types.js"; +import { AnyIntrospectedType, IntrospectedNamespaceMember } from "../gir/base.js"; export const enum NodeKind { class = "class", @@ -336,7 +337,10 @@ export class JsonGenerator extends FormatGenerator { private generateDoc(doc: string): string { const { namespace } = this; - function resolveClass(ns: IntrospectedNamespace, className: string): readonly [GirBase | null, boolean] { + function resolveClass( + ns: IntrospectedNamespace, + className: string + ): readonly [IntrospectedNamespaceMember | null, boolean] { let classes = ns.getMembers(className); let plural = false; @@ -592,7 +596,7 @@ export class JsonGenerator extends FormatGenerator { }); } - private generateMetadata(metadata: GirMetadata): MetadataJson { + private generateMetadata(metadata: IntrospectedMetadata): MetadataJson { return { ...metadata } as MetadataJson; } @@ -612,7 +616,7 @@ export class JsonGenerator extends FormatGenerator { } // eslint-disable-next-line @typescript-eslint/no-unused-vars - generateCallbackType(node: IntrospectedCallback): [Json, Json] { + generateCallbackType(node: IntrospectedCallback | IntrospectedClassCallback): [Json, Json] { return [{}, {}]; } @@ -631,6 +635,21 @@ export class JsonGenerator extends FormatGenerator { }; } + generateClassCallback(node: IntrospectedClassCallback): CallbackJson { + const { namespace, options } = this; + + const parameters = this.generateParameters(node.parameters); + + return { + kind: NodeKind.callback, + name: node.name, + type: this.generateCallbackType(node), + parameters, + returnType: generateType(node.return().resolve(namespace, options)), + ...this._generateDocAndMetadata(node) + }; + } + generateReturn( return_type: TypeExpression, output_parameters: IntrospectedFunctionParameter[] @@ -670,11 +689,12 @@ export class JsonGenerator extends FormatGenerator { const GLib = namespace.assertInstalledImport("GLib"); const GLibError = GLib.assertClass("Error"); - clazz.parent = GLibError.getType(); + clazz.superType = GLibError.getType(); // Manually construct a GLib.Error constructor. clazz.mainConstructor = new IntrospectedConstructor({ name: "new", + parent: clazz, parameters: [ new IntrospectedFunctionParameter({ name: "options", @@ -691,10 +711,10 @@ export class JsonGenerator extends FormatGenerator { }; } - _generateDocAndMetadata(node: GirBase) { + _generateDocAndMetadata(node: AnyIntrospectedType) { const { options } = this; - if (options.withDocs) { + if (!options.noComments) { return { private: node.isPrivate, doc: this.generateDoc(node.doc ?? "") ?? null, @@ -735,8 +755,8 @@ export class JsonGenerator extends FormatGenerator { private extends(node: IntrospectedBaseClass): TypeIdentifier | null { const { namespace: ns, options } = this; - if (node.parent) { - return node.parent.resolveIdentifier(ns, options); + if (node.superType) { + return node.superType.resolveIdentifier(ns, options); } return null; @@ -745,7 +765,7 @@ export class JsonGenerator extends FormatGenerator { generateInterface(node: IntrospectedInterface): InterfaceJson { const { namespace } = this; // If an interface does not list a prerequisite type, we fill it with GObject.Object - if (node.parent == null) { + if (node.superType == null) { const gobject = namespace.assertInstalledImport("GObject"); // TODO Optimize GObject.Object @@ -761,7 +781,7 @@ export class JsonGenerator extends FormatGenerator { ); } - node.parent = GObject.getType(); + node.superType = GObject.getType(); } const { name } = node; @@ -1002,7 +1022,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateField(node: Field): FieldJson { + generateField(node: IntrospectedField): FieldJson { const { namespace, options } = this; const { name, computed } = node; const invalid = isInvalid(name); @@ -1021,7 +1041,7 @@ export class JsonGenerator extends FormatGenerator { }; } - generateProperty(node: GirProperty, construct: boolean = false): PropertyJson { + generateProperty(node: IntrospectedProperty, construct: boolean = false): PropertyJson { const { namespace, options } = this; const invalid = isInvalid(node.name); @@ -1148,17 +1168,7 @@ export class JsonGenerator extends FormatGenerator { return { name: node.name, kind: NodeKind.constructor, - parameters: this.generateParameters( - node.fields.map( - field => - new IntrospectedFunctionParameter({ - name: field.name, - direction: GirDirection.In, - type: field.type, - isOptional: true - }) - ) - ), + parameters: this.generateParameters(node.parameters), ...this._generateDocAndMetadata(node) }; } @@ -1217,7 +1227,7 @@ export class JsonGenerator extends FormatGenerator { } generateNamespace(node: IntrospectedNamespace): Promise { - function shouldGenerate(node: GirBase) { + function shouldGenerate(node: AnyIntrospectedType) { return node.emit; } diff --git a/packages/lib/src/newlib/generics/meta.ts b/packages/lib/src/newlib/generics/meta.ts index 2007381cf..5cbb63c8f 100644 --- a/packages/lib/src/newlib/generics/meta.ts +++ b/packages/lib/src/newlib/generics/meta.ts @@ -15,10 +15,10 @@ export default { const BackgroundContent = namespace.assertClass("BackgroundContent"); const BackgroundActor = namespace.assertClass("BackgroundActor"); - const parent = BackgroundActor.parent; + const parent = BackgroundActor.superType; if (parent) { - BackgroundActor.parent = new GenerifiedTypeIdentifier(parent.name, parent.namespace, [ + BackgroundActor.superType = new GenerifiedTypeIdentifier(parent.name, parent.namespace, [ LayoutManager.getType(), BackgroundContent.getType() ]); diff --git a/packages/lib/src/newlib/generics/st.ts b/packages/lib/src/newlib/generics/st.ts index 4ab9ae7cb..ec150e07c 100644 --- a/packages/lib/src/newlib/generics/st.ts +++ b/packages/lib/src/newlib/generics/st.ts @@ -61,10 +61,12 @@ export default { constraint: Actor.getType() }); - if (StBoxLayout.parent) { - StBoxLayout.parent = new GenerifiedTypeIdentifier(StBoxLayout.parent.name, StBoxLayout.parent.namespace, [ - ClutterBoxLayout.getType() - ]); + if (StBoxLayout.superType) { + StBoxLayout.superType = new GenerifiedTypeIdentifier( + StBoxLayout.superType.name, + StBoxLayout.superType.namespace, + [ClutterBoxLayout.getType()] + ); } Bin.addGeneric({ diff --git a/packages/lib/src/newlib/generics/visitor.ts b/packages/lib/src/newlib/generics/visitor.ts index 1ab844e03..9b59b4a2f 100644 --- a/packages/lib/src/newlib/generics/visitor.ts +++ b/packages/lib/src/newlib/generics/visitor.ts @@ -80,7 +80,7 @@ export class GenericVisitor extends GirVisitor { const { namespace } = _node; - const resolvedParent = node.parent ? resolveTypeIdentifier(namespace, node.parent) : null; + const resolvedParent = node.superType ? resolveTypeIdentifier(namespace, node.superType) : null; const derivatives = node.generics.filter(generic => generic.parent != null); if (node instanceof IntrospectedClass) { @@ -142,15 +142,15 @@ export class GenericVisitor extends GirVisitor { }); } - if (node.parent) { - const parentType = node.parent; + if (node.superType) { + const parentType = node.superType; const generic = derivatives.filter(d => d.parent?.is(parentType.namespace, parentType.name)); - if (node.parent instanceof GenerifiedTypeIdentifier) { + if (node.superType instanceof GenerifiedTypeIdentifier) { // Do nothing } else if (generic.length > 0) { - node.parent = new GenerifiedTypeIdentifier( + node.superType = new GenerifiedTypeIdentifier( parentType.name, parentType.namespace, generic.map(g => g.type) @@ -167,7 +167,7 @@ export class GenericVisitor extends GirVisitor { ); if (constrainedGeneric) { - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.superType = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ constrainedGeneric.type ]); } else { @@ -183,7 +183,7 @@ export class GenericVisitor extends GirVisitor { const firstGeneric = node.generics[node.generics.length - 1]; - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.superType = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ firstGeneric.type ]); } else if ( @@ -191,7 +191,7 @@ export class GenericVisitor extends GirVisitor { c => generic.defaultType && c.identifier.equals(generic.defaultType) ) ) { - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.superType = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ node.getType() ]); } @@ -201,7 +201,7 @@ export class GenericVisitor extends GirVisitor { c => generic.defaultType && c.identifier.equals(generic.defaultType) ) ) { - node.parent = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ + node.superType = new GenerifiedTypeIdentifier(resolved.name, resolved.namespace.name, [ node.getType() ]); } diff --git a/packages/lib/src/newlib/gir.ts b/packages/lib/src/newlib/gir.ts index 86fb9867e..9f66fceb5 100644 --- a/packages/lib/src/newlib/gir.ts +++ b/packages/lib/src/newlib/gir.ts @@ -1,9 +1,10 @@ import { IntrospectedNamespace } from "./gir/namespace.js"; -import { GirProperty, Field } from "./gir/property.js"; +import { IntrospectedProperty, IntrospectedField } from "./gir/property.js"; import { GenerationOptions } from "./types.js"; import { sanitizeIdentifierName } from "./gir/util.js"; -export { IntrospectedBase as GirBase, Options as GirOptions, Metadata as GirMetadata } from "./gir/base.js"; +export { IntrospectedBase, Options as IntrospectedOptions, Metadata as IntrospectedMetadata } from "./gir/base.js"; +export * from "./gir/nodes.js"; export abstract class TypeExpression { isPointer = false; @@ -750,4 +751,4 @@ export const VoidType = new NativeType("void"); export const UnknownType = new NativeType("unknown"); export const AnyFunctionType = new NativeType("(...args: any[]) => any"); -export type GirClassField = GirProperty | Field; +export type GirClassField = IntrospectedProperty | IntrospectedField; diff --git a/packages/lib/src/newlib/gir/alias.ts b/packages/lib/src/newlib/gir/alias.ts index b1ebd03b5..340855833 100644 --- a/packages/lib/src/newlib/gir/alias.ts +++ b/packages/lib/src/newlib/gir/alias.ts @@ -1,5 +1,5 @@ import { TypeExpression } from "../gir.js"; -import { IntrospectedBase as IntrospectedBase, Options } from "./base.js"; +import { IntrospectedNamespaceMember, Options } from "./base.js"; import { GirAliasElement } from "../../index.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; @@ -8,21 +8,23 @@ import { FormatGenerator, GenericDescriptor } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export class IntrospectedAlias extends IntrospectedBase { +export class IntrospectedAlias extends IntrospectedNamespaceMember { readonly type: TypeExpression; readonly generics: GenericDescriptor[]; constructor({ + namespace, name, type, generics = [], ...args }: Options<{ + namespace: IntrospectedNamespace; name: string; type: TypeExpression; generics?: GenericDescriptor[]; }>) { - super(name, { ...args }); + super(name, namespace, { ...args }); this.type = type; this.generics = generics; @@ -37,9 +39,9 @@ export class IntrospectedAlias extends IntrospectedBase { } copy(options?: { parent?: undefined; type?: TypeExpression }): IntrospectedAlias { - const { name, type } = this; + const { name, namespace, type } = this; - return new IntrospectedAlias({ name, type: options?.type ?? type })._copyBaseProperties(this); + return new IntrospectedAlias({ name, namespace, type: options?.type ?? type })._copyBaseProperties(this); } asString>(generator: T): ReturnType { @@ -47,26 +49,25 @@ export class IntrospectedAlias extends IntrospectedBase { } static fromXML( - modName: string, + element: GirAliasElement, ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - m: GirAliasElement + options: LoadOptions ): IntrospectedAlias | null { - if (!m.$.name) { - console.error(`Alias in ${modName} lacks name.`); + if (!element.$.name) { + console.error(`Alias in ${ns.name} lacks name.`); return null; } const alias = new IntrospectedAlias({ - name: sanitizeIdentifierName(ns.name, m.$.name), - type: getAliasType(modName, ns, m), - isIntrospectable: isIntrospectable(m) + namespace: ns, + name: sanitizeIdentifierName(ns.name, element.$.name), + type: getAliasType(ns.name, ns, element), + isIntrospectable: isIntrospectable(element) }); if (options.loadDocs) { - alias.doc = parseDoc(m); - alias.metadata = parseMetadata(m); + alias.doc = parseDoc(element); + alias.metadata = parseMetadata(element); } return alias; diff --git a/packages/lib/src/newlib/gir/base.ts b/packages/lib/src/newlib/gir/base.ts index e7e548de7..b68037219 100644 --- a/packages/lib/src/newlib/gir/base.ts +++ b/packages/lib/src/newlib/gir/base.ts @@ -2,6 +2,7 @@ import { FormatGenerator } from "../generators/index.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; import { IntrospectedNamespace } from "./namespace.js"; +import type { IntrospectedBaseClass } from "./nodes.js"; export interface Metadata { deprecated?: boolean; @@ -13,11 +14,15 @@ export interface Metadata { export interface BaseOptions { isPrivate?: boolean; isIntrospectable?: boolean; + doc?: string | null; } export type Options = BaseOptions & T; -export abstract class IntrospectedBase { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type AnyIntrospectedType = IntrospectedBase; + +export abstract class IntrospectedBase { name: string; doc?: string | null; metadata?: Metadata; @@ -27,12 +32,19 @@ export abstract class IntrospectedBase { private _commentWarning?: string; private _isPrivate: boolean; private _isIntrospectable: boolean; + private _parent: Parent; - constructor(name: string, options: BaseOptions = {}) { + constructor(name: string, parent: Parent, options: BaseOptions = {}) { this.name = name; + this._parent = parent; this._isPrivate = options.isPrivate ?? false; this._isIntrospectable = options.isIntrospectable ?? true; + this.doc = options.doc ?? null; + } + + get parent(): Parent { + return this._parent; } /** @@ -49,6 +61,8 @@ export abstract class IntrospectedBase { return this._commentWarning; } + abstract get namespace(): IntrospectedNamespace; + get isIntrospectable() { return this._isIntrospectable; } @@ -83,24 +97,56 @@ export abstract class IntrospectedBase { return this; } - abstract copy(options?: { parent?: IntrospectedBase }): IntrospectedBase; + abstract copy(options?: { parent?: Parent }): IntrospectedBase; - abstract accept(visitor: GirVisitor): IntrospectedBase; + abstract accept(visitor: GirVisitor): IntrospectedBase; static fromXML( + // eslint-disable-next-line + element: Record, // eslint-disable-next-line @typescript-eslint/no-unused-vars - modName: string, + parent: IntrospectedNamespace | AnyIntrospectedType, // eslint-disable-next-line @typescript-eslint/no-unused-vars - ns: IntrospectedNamespace, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - options: LoadOptions, + options: LoadOptions + ): AnyIntrospectedType | null { + throw new Error("GirBase cannot be instantiated"); + } + + abstract asString>( + generator: T + ): (T extends FormatGenerator ? R : never) | null; + abstract asString>(generator: T): unknown; +} + +export abstract class IntrospectedNamespaceMember extends IntrospectedBase { + constructor(name: string, namespace: IntrospectedNamespace, options: BaseOptions = {}) { + super(name, namespace, options); + } + + get namespace() { + return this.parent; + } + + static fromXML( + // eslint-disable-next-line + element: Record, // eslint-disable-next-line @typescript-eslint/no-unused-vars - parent: IntrospectedBase | null, + parent: IntrospectedNamespace, // eslint-disable-next-line @typescript-eslint/no-unused-vars - gir: object - ): IntrospectedBase | null { + options: LoadOptions + ): IntrospectedNamespaceMember | null { throw new Error("GirBase cannot be instantiated"); } +} - abstract asString, K>(generator: T): K | null; +export abstract class IntrospectedClassMember< + Parent extends IntrospectedBaseClass | null = IntrospectedBaseClass | null +> extends IntrospectedBase { + get namespace() { + if (!this.parent) { + throw new Error(`Failed to get namespace for ${this.name}`); + } + + return this.parent.namespace; + } } diff --git a/packages/lib/src/newlib/gir/class.ts b/packages/lib/src/newlib/gir/class.ts index e1ba01b15..75a547425 100644 --- a/packages/lib/src/newlib/gir/class.ts +++ b/packages/lib/src/newlib/gir/class.ts @@ -17,20 +17,20 @@ import { TypeConflict } from "../gir.js"; import { TypeExpression } from "../gir.js"; -import { IntrospectedBase } from "./base.js"; +import { IntrospectedBase, IntrospectedClassMember, IntrospectedNamespaceMember, Options } from "./base.js"; import { GirInterfaceElement, GirClassElement, GirRecordElement, GirDirection, GirUnionElement } from "../../index.js"; import { IntrospectedClassFunction, IntrospectedVirtualClassFunction, IntrospectedStaticClassFunction, - IntrospectedCallback, IntrospectedFunction, IntrospectedConstructor, IntrospectedFunctionParameter, - IntrospectedDirectAllocationConstructor + IntrospectedDirectAllocationConstructor, + IntrospectedClassCallback } from "./function.js"; -import { GirProperty, Field } from "./property.js"; +import { IntrospectedProperty, IntrospectedField } from "./property.js"; import { IntrospectedNamespace } from "./namespace.js"; import { sanitizeIdentifierName, @@ -52,7 +52,7 @@ export enum FilterBehavior { PRESERVE } -export function filterConflicts( +export function filterConflicts( ns: IntrospectedNamespace, c: IntrospectedBaseClass, elements: T[], @@ -65,12 +65,12 @@ export function filterConflicts( const field_conflicts = c.findParentMap(resolved_parent => { return findMap([...resolved_parent.fields], p => { if (p.name && p.name == next.name) { - if (next instanceof GirProperty) { + if (next instanceof IntrospectedProperty) { return ConflictType.ACCESSOR_PROPERTY_CONFLICT; } if ( - next instanceof Field && + next instanceof IntrospectedField && !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) ) { return ConflictType.FIELD_NAME_CONFLICT; @@ -85,12 +85,12 @@ export function filterConflicts( ? c.findParentMap(resolved_parent => { return findMap([...resolved_parent.props], p => { if (p.name && p.name == next.name) { - if (next instanceof Field) { + if (next instanceof IntrospectedField) { return ConflictType.PROPERTY_ACCESSOR_CONFLICT; } if ( - next instanceof GirProperty && + next instanceof IntrospectedProperty && !isSubtypeOf(ns, thisType, resolved_parent.getType(), next.type, p.type) ) { console.log( @@ -125,7 +125,7 @@ export function filterConflicts( const conflict = field_conflicts || prop_conflicts || function_conflicts; if (conflict) { if (behavior === FilterBehavior.PRESERVE) { - if (next instanceof Field || next instanceof GirProperty) { + if (next instanceof IntrospectedField || next instanceof IntrospectedProperty) { prev.push( next.copy({ type: new TypeConflict(next.type, conflict) @@ -238,6 +238,7 @@ export function filterFunctionConflict< const neverOptions = { name: next.name, + parent: base, parameters: [never_param], return_type: AnyType }; @@ -313,7 +314,9 @@ export function promisifyFunctions(functions: IntrospectedClassFunction[]) { ); if (async_res) { - const async_parameters = node.parameters.slice(0, -1).map(p => p.copy()); + const async_parameters = node.parameters + .slice(0, -1) + .map(p => p.copy({ parent: null })); const sync_parameters = node.parameters.map(p => p.copy({ isOptional: false })); const output_parameters = async_res instanceof IntrospectedConstructor ? [] : async_res.output_parameters; @@ -364,14 +367,14 @@ export const enum ClassInjectionMember { } export interface ClassDefinition { - parent: TypeIdentifier; + superType: TypeIdentifier; interfaces: TypeIdentifier[]; mainConstructor: IntrospectedConstructor; constructors: IntrospectedConstructor[]; members: IntrospectedClassFunction[]; - props: GirProperty[]; - fields: Field[]; - callbacks: IntrospectedCallback[]; + props: IntrospectedProperty[]; + fields: IntrospectedField[]; + callbacks: IntrospectedClassCallback[]; } export interface ResolutionNode { @@ -395,32 +398,31 @@ export interface RecordResolution extends ResolutionNode, Iterable + }> & + Partial ) { const { name, namespace, - parent = null, + superType = null, mainConstructor = null, constructors = [], members = [], @@ -430,17 +432,16 @@ export abstract class IntrospectedBaseClass extends IntrospectedBase { ...args } = options; - super(name, { ...args }); + super(name, namespace, { ...args }); - this.namespace = namespace; - this.parent = parent; + this.superType = superType; - this.mainConstructor = mainConstructor?.copy() ?? null; - this.constructors = [...constructors.map(c => c.copy())]; + this.mainConstructor = mainConstructor?.copy({ parent: this }) ?? null; + this.constructors = [...constructors.map(c => c.copy({ parent: this }))]; this.members = [...members.map(m => m.copy({ parent: this }))]; this.props = [...props.map(p => p.copy({ parent: this }))]; this.fields = [...fields.map(f => f.copy({ parent: this }))]; - this.callbacks = [...callbacks.map(c => c.copy())]; + this.callbacks = [...callbacks.map(c => c.copy({ parent: this }))]; } abstract accept(visitor: GirVisitor): IntrospectedBaseClass; @@ -449,9 +450,9 @@ export abstract class IntrospectedBaseClass extends IntrospectedBase { parent?: undefined; constructors?: IntrospectedConstructor[]; members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; + props?: IntrospectedProperty[]; + fields?: IntrospectedField[]; + callbacks?: IntrospectedClassCallback[]; }): IntrospectedBaseClass; getGenericName = GenericNameGenerator.new(); @@ -484,15 +485,11 @@ export abstract class IntrospectedBaseClass extends IntrospectedBase { static fromXML( // eslint-disable-next-line @typescript-eslint/no-unused-vars - modName: string, + element: GirClassElement | GirInterfaceElement | GirRecordElement, // eslint-disable-next-line @typescript-eslint/no-unused-vars ns: IntrospectedNamespace, // eslint-disable-next-line @typescript-eslint/no-unused-vars - options: LoadOptions, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - parent, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - klass: GirClassElement | GirInterfaceElement | GirRecordElement + options: LoadOptions ): IntrospectedBaseClass { throw new Error("fromXML is not implemented on GirBaseClass"); } @@ -500,6 +497,8 @@ export abstract class IntrospectedBaseClass extends IntrospectedBase { abstract asString(generator: FormatGenerator): T; } +type ClassMember = IntrospectedClassMember | IntrospectedClassFunction | IntrospectedProperty; + export class IntrospectedClass extends IntrospectedBaseClass { signals: IntrospectedSignal[] = []; interfaces: TypeIdentifier[] = []; @@ -523,7 +522,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { return visitor.visitClass?.(node) ?? node; } - hasInstanceSymbol(s: IntrospectedBase): boolean { + hasInstanceSymbol(s: S): boolean { return ( this.members.some(p => s.name === p.name && !(p instanceof IntrospectedStaticClassFunction)) || this.props.some(p => s.name === p.name) || @@ -593,15 +592,15 @@ export class IntrospectedClass extends IntrospectedBaseClass { return findMap(interfaces, i => i.findParentMap(predicate)); } - implementedProperties(potentialConflicts: IntrospectedBase[] = []) { + implementedProperties(potentialConflicts: IntrospectedBase[] = []) { const resolution = this.resolveParents(); const implemented_on_parent = [...(resolution.extends() ?? [])] .map(r => r.implements()) .flat() .map(i => i.identifier); - const properties = new Map(); + const properties = new Map(); - const validateProp = (prop: GirProperty) => + const validateProp = (prop: IntrospectedProperty) => !this.hasInstanceSymbol(prop) && !properties.has(prop.name) && potentialConflicts.every(p => prop.name !== p.name); @@ -638,7 +637,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { return [...properties.values()]; } - implementedMethods(potentialConflicts: IntrospectedBase[] = []) { + implementedMethods(potentialConflicts: ClassMember[] = []) { const resolution = this.resolveParents(); const implemented_on_parent = [...(resolution.extends() ?? [])].map(r => r.implements()).flat(); const methods = new Map(); @@ -738,7 +737,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { } resolveParents(): ClassResolution { - const { namespace, parent, interfaces } = this; + const { namespace, superType, interfaces } = this; return { *[Symbol.iterator]() { @@ -758,7 +757,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { return z; }, extends() { - const parentType = parent; + const parentType = superType; const resolved_parent = parentType && resolveTypeIdentifier(namespace, parentType); if (resolved_parent instanceof IntrospectedClass) return resolved_parent.resolveParents(); return undefined; @@ -774,15 +773,15 @@ export class IntrospectedClass extends IntrospectedBaseClass { signals?: IntrospectedSignal[]; constructors?: IntrospectedConstructor[]; members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; + props?: IntrospectedProperty[]; + fields?: IntrospectedField[]; + callbacks?: IntrospectedClassCallback[]; } = {} ): IntrospectedClass { const { name, namespace, - parent, + superType, interfaces, members, constructors, @@ -800,19 +799,19 @@ export class IntrospectedClass extends IntrospectedBaseClass { clazz._copyBaseProperties(this); - if (parent) { - clazz.parent = parent; + if (superType) { + clazz.superType = superType; } clazz._staticDefinition = _staticDefinition; - clazz.signals = (options.signals ?? signals).map(s => s.copy()); + clazz.signals = (options.signals ?? signals).map(s => s.copy({ parent: clazz })); clazz.interfaces = [...interfaces]; - clazz.props = (options.props ?? props).map(p => p.copy()); - clazz.fields = (options.fields ?? fields).map(f => f.copy()); - clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); + clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); + clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy({ parent: clazz })); clazz.isAbstract = isAbstract; clazz.mainConstructor = mainConstructor; - clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy({ parent: clazz })); clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); clazz.generics = [...generics]; @@ -826,45 +825,39 @@ export class IntrospectedClass extends IntrospectedBaseClass { return this._staticDefinition; } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - klass: GirClassElement - ): IntrospectedClass { - const name = sanitizeIdentifierName(ns.name, klass.$.name); + static fromXML(element: GirClassElement, ns: IntrospectedNamespace, options: LoadOptions): IntrospectedClass { + const name = sanitizeIdentifierName(ns.name, element.$.name); if (options.verbose) { - console.debug(` >> GirClass: Parsing definition ${klass.$.name} (${name})...`); + console.debug(` >> GirClass: Parsing definition ${element.$.name} (${name})...`); } const clazz = new IntrospectedClass(name, ns); if (options.loadDocs) { - clazz.doc = parseDoc(klass); - clazz.metadata = parseMetadata(klass); + clazz.doc = parseDoc(element); + clazz.metadata = parseMetadata(element); } - if (klass.$["glib:type-name"]) { - clazz.resolve_names.push(klass.$["glib:type-name"]); + if (element.$["glib:type-name"]) { + clazz.resolve_names.push(element.$["glib:type-name"]); - ns.registerResolveName(klass.$["glib:type-name"], ns.name, name); + ns.registerResolveName(element.$["glib:type-name"], ns.name, name); } - if (klass.$["glib:type-struct"]) { + if (element.$["glib:type-struct"]) { clazz.resolve_names.push(); - ns.registerResolveName(klass.$["glib:type-struct"], ns.name, name); + ns.registerResolveName(element.$["glib:type-struct"], ns.name, name); } - if (klass.$["c:type"]) { - clazz.resolve_names.push(klass.$["c:type"]); + if (element.$["c:type"]) { + clazz.resolve_names.push(element.$["c:type"]); - ns.registerResolveName(klass.$["c:type"], ns.name, name); + ns.registerResolveName(element.$["c:type"], ns.name, name); } - const typeStruct = klass.$["glib:type-struct"]; + const typeStruct = element.$["glib:type-struct"]; if (typeStruct) { clazz.registerStaticDefinition(typeStruct); @@ -875,34 +868,32 @@ export class IntrospectedClass extends IntrospectedBaseClass { try { // Setup parent type if this is an interface or class. - if (klass.$.parent) { - clazz.parent = parseTypeIdentifier(modName, klass.$.parent); + if (element.$.parent) { + clazz.superType = parseTypeIdentifier(ns.name, element.$.parent); } - if (klass.$.abstract) { + if (element.$.abstract) { clazz.isAbstract = true; } - if (Array.isArray(klass.constructor)) { + if (Array.isArray(element.constructor)) { clazz.constructors.push( - ...klass.constructor.map(constructor => - IntrospectedConstructor.fromXML(modName, ns, options, clazz, constructor) + ...element.constructor.map(constructor => + IntrospectedConstructor.fromXML(constructor, clazz, options) ) ); } - if (klass["glib:signal"]) { + if (element["glib:signal"]) { clazz.signals.push( - ...klass["glib:signal"].map(signal => - IntrospectedSignal.fromXML(modName, ns, options, clazz, signal) - ) + ...element["glib:signal"].map(signal => IntrospectedSignal.fromXML(signal, clazz, options)) ); } // Properties - if (klass.property) { - klass.property.forEach(prop => { - const property = GirProperty.fromXML(modName, ns, options, clazz, prop); + if (element.property) { + element.property.forEach(prop => { + const property = IntrospectedProperty.fromXML(prop, clazz, options); switch (options.propertyCase) { case "both": clazz.props.push(property); @@ -926,33 +917,31 @@ export class IntrospectedClass extends IntrospectedBaseClass { } // Instance Methods - if (klass.method) { + if (element.method) { clazz.members.push( - ...klass.method.map(method => - IntrospectedClassFunction.fromXML(modName, ns, options, clazz, method) - ) + ...element.method.map(method => IntrospectedClassFunction.fromXML(method, clazz, options)) ); } // Fields - if (klass.field) { - klass.field + if (element.field) { + element.field .filter(field => !("callback" in field)) .forEach(field => { - const f = Field.fromXML(modName, ns, options, null, field); + const f = IntrospectedField.fromXML(field, clazz); clazz.fields.push(f); }); } - if (klass.implements) { - klass.implements.forEach(implementee => { + if (element.implements) { + element.implements.forEach(implementee => { const name = implementee.$.name; - const type = parseTypeIdentifier(modName, name); + const type = parseTypeIdentifier(ns.name, name); // Sometimes namespaces will implicitly import // other namespaces like Atk via interface implements. - if (type && type.namespace && type.namespace !== modName && !ns.hasImport(type.namespace)) { + if (type && type.namespace && type.namespace !== ns.name && !ns.hasImport(type.namespace)) { ns.addImport(type.namespace); } @@ -963,33 +952,31 @@ export class IntrospectedClass extends IntrospectedBaseClass { } // Callback Types - if (klass.callback) { + if (element.callback) { clazz.callbacks.push( - ...klass.callback.map(callback => { + ...element.callback.map(callback => { if (options.verbose) { - console.debug(`Adding callback ${callback.$.name} for ${modName}`); + console.debug(`Adding callback ${callback.$.name} for ${ns.name}`); } - return IntrospectedCallback.fromXML(modName, ns, options, clazz, callback); + return IntrospectedClassCallback.fromXML(callback, clazz, options); }) ); } // Virtual Methods - if (klass["virtual-method"]) { + if (element["virtual-method"]) { clazz.members.push( - ...klass["virtual-method"].map(method => - IntrospectedVirtualClassFunction.fromXML(modName, ns, options, clazz, method) + ...element["virtual-method"].map(method => + IntrospectedVirtualClassFunction.fromXML(method, clazz, options) ) ); } // Static methods (functions) - if (klass.function) { + if (element.function) { clazz.members.push( - ...klass.function.map(func => - IntrospectedStaticClassFunction.fromXML(modName, ns, options, clazz, func) - ) + ...element.function.map(func => IntrospectedStaticClassFunction.fromXML(func, clazz, options)) ); } } catch (e) { @@ -1078,7 +1065,7 @@ export class IntrospectedRecord extends IntrospectedBaseClass { } resolveParents(): RecordResolution { - const { namespace, parent } = this; + const { namespace, superType } = this; return { *[Symbol.iterator]() { @@ -1090,8 +1077,7 @@ export class IntrospectedRecord extends IntrospectedBaseClass { } }, extends() { - const parentType = parent; - const resolved_parent = parentType ? resolveTypeIdentifier(namespace, parentType) : undefined; + const resolved_parent = superType ? resolveTypeIdentifier(namespace, superType) : undefined; if (resolved_parent instanceof IntrospectedRecord) return resolved_parent.resolveParents(); return undefined; @@ -1106,15 +1092,15 @@ export class IntrospectedRecord extends IntrospectedBaseClass { parent?: undefined; constructors?: IntrospectedConstructor[]; members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; + props?: IntrospectedProperty[]; + fields?: IntrospectedField[]; + callbacks?: IntrospectedClassCallback[]; } = {} ): IntrospectedRecord { const { name, namespace, - parent, + superType, members, constructors, _isForeign, @@ -1130,17 +1116,17 @@ export class IntrospectedRecord extends IntrospectedBaseClass { clazz._copyBaseProperties(this); - if (parent) { - clazz.parent = parent; + if (superType) { + clazz.superType; } clazz._structFor = _structFor; clazz._isForeign = _isForeign; clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); - clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); - clazz.mainConstructor = mainConstructor?.copy() ?? null; - clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy({ parent: clazz })); + clazz.mainConstructor = mainConstructor?.copy({ parent: clazz }) ?? null; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy({ parent: clazz })); clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); clazz.generics = [...generics]; @@ -1154,92 +1140,87 @@ export class IntrospectedRecord extends IntrospectedBaseClass { } static fromXML( - modName: string, + element: GirRecordElement | GirUnionElement, namespace: IntrospectedNamespace, - options: LoadOptions, - klass: GirRecordElement | GirUnionElement + options: LoadOptions ): IntrospectedRecord { - if (!klass.$.name) { + if (!element.$.name) { throw new Error("Invalid GIR File: No name provided for union."); } - const name = sanitizeIdentifierName(namespace.name, klass.$.name); + const name = sanitizeIdentifierName(namespace.name, element.$.name); if (options.verbose) { - console.debug(` >> GirRecord: Parsing definition ${klass.$.name} (${name})...`); + console.debug(` >> GirRecord: Parsing definition ${element.$.name} (${name})...`); } const clazz = new IntrospectedRecord({ name, namespace }); clazz.setPrivate( - klass.$.name.startsWith("_") || - ("disguised" in klass.$ && klass.$.disguised === "1") || + element.$.name.startsWith("_") || + ("disguised" in element.$ && element.$.disguised === "1") || // Don't generate records for structs - (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) + (typeof element.$["glib:is-gtype-struct-for"] === "string" && !!element.$["glib:is-gtype-struct-for"]) ); - if (typeof klass.$["glib:is-gtype-struct-for"] === "string" && !!klass.$["glib:is-gtype-struct-for"]) { + if (typeof element.$["glib:is-gtype-struct-for"] === "string" && !!element.$["glib:is-gtype-struct-for"]) { clazz.noEmit(); // This let's us replace these references when generating. - clazz._structFor = parseTypeIdentifier(modName, klass.$["glib:is-gtype-struct-for"]); + clazz._structFor = parseTypeIdentifier(namespace.name, element.$["glib:is-gtype-struct-for"]); } else { - if (klass.$["glib:type-name"]) { - clazz.resolve_names.push(klass.$["glib:type-name"]); + if (element.$["glib:type-name"]) { + clazz.resolve_names.push(element.$["glib:type-name"]); - namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); + namespace.registerResolveName(element.$["glib:type-name"], namespace.name, name); } - if (klass.$["c:type"]) { - clazz.resolve_names.push(klass.$["c:type"]); + if (element.$["c:type"]) { + clazz.resolve_names.push(element.$["c:type"]); - namespace.registerResolveName(klass.$["c:type"], namespace.name, name); + namespace.registerResolveName(element.$["c:type"], namespace.name, name); } } if (options.loadDocs) { - clazz.doc = parseDoc(klass); - clazz.metadata = parseMetadata(klass); + clazz.doc = parseDoc(element); + clazz.metadata = parseMetadata(element); } try { // Instance Methods - if (klass.method) { + if (element.method) { clazz.members.push( - ...klass.method.map(method => - IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method) - ) + ...element.method.map(method => IntrospectedClassFunction.fromXML(method, clazz, options)) ); } // Constructors - if (Array.isArray(klass.constructor)) { - klass.constructor.forEach(constructor => { - const c = IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor); + if (Array.isArray(element.constructor)) { + element.constructor.forEach(constructor => { + const c = IntrospectedConstructor.fromXML(constructor, clazz, options); clazz.constructors.push(c); }); } // Static methods (functions) - if (klass.function) { + if (element.function) { clazz.members.push( - ...klass.function.map(func => - IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func) - ) + ...element.function.map(func => IntrospectedStaticClassFunction.fromXML(func, clazz, options)) ); } // Is this a foreign type? (don't allow construction if foreign) - clazz._isForeign = "foreign" in klass.$ && klass.$.foreign === "1"; + clazz._isForeign = "foreign" in element.$ && element.$.foreign === "1"; // Fields (for "non-class" records) - if (klass.field) { + if (element.field) { clazz.fields.push( - ...klass.field + ...element.field .filter(field => !("callback" in field)) - .map(field => Field.fromXML(modName, namespace, options, null, field)) + .map(field => IntrospectedField.fromXML(field, clazz)) ); } } catch (e) { @@ -1408,15 +1389,15 @@ export class IntrospectedInterface extends IntrospectedBaseClass { noParent?: boolean; constructors?: IntrospectedConstructor[]; members?: IntrospectedClassFunction[]; - props?: GirProperty[]; - fields?: Field[]; - callbacks?: IntrospectedCallback[]; + props?: IntrospectedProperty[]; + fields?: IntrospectedField[]; + callbacks?: IntrospectedClassCallback[]; } = {} ): IntrospectedInterface { const { name, namespace, - parent, + superType, noParent, members, constructors, @@ -1433,15 +1414,15 @@ export class IntrospectedInterface extends IntrospectedBaseClass { clazz.noParent = noParent; - if (parent) { - clazz.parent = parent; + if (superType) { + clazz.superType = superType; } clazz.props = (options.props ?? props).map(p => p.copy({ parent: clazz })); clazz.fields = (options.fields ?? fields).map(f => f.copy({ parent: clazz })); - clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy()); - clazz.mainConstructor = mainConstructor?.copy() ?? null; - clazz.constructors = (options.constructors ?? constructors).map(c => c.copy()); + clazz.callbacks = (options.callbacks ?? callbacks).map(c => c.copy({ parent: clazz })); + clazz.mainConstructor = mainConstructor?.copy({ parent: clazz }) ?? null; + clazz.constructors = (options.constructors ?? constructors).map(c => c.copy({ parent: clazz })); clazz.members = (options.members ?? members).map(m => m.copy({ parent: clazz })); clazz.generics = [...generics]; @@ -1490,7 +1471,7 @@ export class IntrospectedInterface extends IntrospectedBaseClass { } resolveParents(): InterfaceResolution { - const { namespace, parent } = this; + const { namespace, superType } = this; return { *[Symbol.iterator]() { let current = this.extends(); @@ -1501,8 +1482,8 @@ export class IntrospectedInterface extends IntrospectedBaseClass { } }, extends() { - if (!parent) return undefined; - const resolved = resolveTypeIdentifier(namespace, parent); + if (!superType) return undefined; + const resolved = resolveTypeIdentifier(namespace, superType); if (resolved && (resolved instanceof IntrospectedClass || resolved instanceof IntrospectedInterface)) return resolved.resolveParents(); return undefined; @@ -1525,66 +1506,63 @@ export class IntrospectedInterface extends IntrospectedBaseClass { } static fromXML( - modName: string, + element: GirInterfaceElement, namespace: IntrospectedNamespace, - options: LoadOptions, - klass: GirInterfaceElement + options: LoadOptions ): IntrospectedInterface { - const name = sanitizeIdentifierName(namespace.name, klass.$.name); + const name = sanitizeIdentifierName(namespace.name, element.$.name); if (options.verbose) { - console.debug(` >> GirInterface: Parsing definition ${klass.$.name} (${name})...`); + console.debug(` >> GirInterface: Parsing definition ${element.$.name} (${name})...`); } const clazz = new IntrospectedInterface({ name, namespace }); if (options.loadDocs) { - clazz.doc = parseDoc(klass); - clazz.metadata = parseMetadata(klass); + clazz.doc = parseDoc(element); + clazz.metadata = parseMetadata(element); } - if (klass.$["glib:type-name"]) { - clazz.resolve_names.push(klass.$["glib:type-name"]); + if (element.$["glib:type-name"]) { + clazz.resolve_names.push(element.$["glib:type-name"]); - namespace.registerResolveName(klass.$["glib:type-name"], namespace.name, name); + namespace.registerResolveName(element.$["glib:type-name"], namespace.name, name); } - if (klass.$["glib:type-struct"]) { + if (element.$["glib:type-struct"]) { clazz.resolve_names.push(); - namespace.registerResolveName(klass.$["glib:type-struct"], namespace.name, name); + namespace.registerResolveName(element.$["glib:type-struct"], namespace.name, name); } - if (klass.$["c:type"]) { - clazz.resolve_names.push(klass.$["c:type"]); + if (element.$["c:type"]) { + clazz.resolve_names.push(element.$["c:type"]); - namespace.registerResolveName(klass.$["c:type"], namespace.name, name); + namespace.registerResolveName(element.$["c:type"], namespace.name, name); } try { // Setup the "parent" (prerequisite) for this interface. - if (klass.prerequisite && klass.prerequisite[0]) { - const [prerequisite] = klass.prerequisite; + if (element.prerequisite && element.prerequisite[0]) { + const [prerequisite] = element.prerequisite; if (prerequisite.$.name) { - clazz.parent = parseTypeIdentifier(modName, prerequisite.$.name); + clazz.superType = parseTypeIdentifier(namespace.name, prerequisite.$.name); } } - if (Array.isArray(klass.constructor)) { - for (const constructor of klass.constructor) { - clazz.constructors.push( - IntrospectedConstructor.fromXML(modName, namespace, options, clazz, constructor) - ); + if (Array.isArray(element.constructor)) { + for (const constructor of element.constructor) { + clazz.constructors.push(IntrospectedConstructor.fromXML(constructor, clazz, options)); } } // Properties - if (klass.property) { + if (element.property) { clazz.props.push( - ...klass.property + ...element.property - .map(prop => GirProperty.fromXML(modName, namespace, options, clazz, prop)) + .map(prop => IntrospectedProperty.fromXML(prop, clazz, options)) .map(prop => { switch (options.propertyCase) { case "both": @@ -1607,40 +1585,36 @@ export class IntrospectedInterface extends IntrospectedBaseClass { } // Instance Methods - if (klass.method) { - for (const method of klass.method) { - const m = IntrospectedClassFunction.fromXML(modName, namespace, options, clazz, method); + if (element.method) { + for (const method of element.method) { + const m = IntrospectedClassFunction.fromXML(method, clazz, options); clazz.members.push(m); } } // Virtual Methods - if (klass["virtual-method"]) { - for (const method of klass["virtual-method"]) { - clazz.members.push( - IntrospectedVirtualClassFunction.fromXML(modName, namespace, options, clazz, method) - ); + if (element["virtual-method"]) { + for (const method of element["virtual-method"]) { + clazz.members.push(IntrospectedVirtualClassFunction.fromXML(method, clazz, options)); } } // Callback Types - if (klass.callback) { - for (const callback of klass.callback) { + if (element.callback) { + for (const callback of element.callback) { if (options.verbose) { - console.debug(`Adding callback ${callback.$.name} for ${modName}`); + console.debug(`Adding callback ${callback.$.name} for ${namespace.name}`); } - clazz.callbacks.push(IntrospectedCallback.fromXML(modName, namespace, options, clazz, callback)); + clazz.callbacks.push(IntrospectedClassCallback.fromXML(callback, clazz, options)); } } // Static methods (functions) - if (klass.function) { - for (const func of klass.function) { - clazz.members.push( - IntrospectedStaticClassFunction.fromXML(modName, namespace, options, clazz, func) - ); + if (element.function) { + for (const func of element.function) { + clazz.members.push(IntrospectedStaticClassFunction.fromXML(func, clazz, options)); } } } catch (e) { diff --git a/packages/lib/src/newlib/gir/const.ts b/packages/lib/src/newlib/gir/const.ts index 8f2211a7e..7b9e71040 100644 --- a/packages/lib/src/newlib/gir/const.ts +++ b/packages/lib/src/newlib/gir/const.ts @@ -1,5 +1,5 @@ import { TypeExpression } from "../gir.js"; -import { IntrospectedBase } from "./base.js"; +import { IntrospectedNamespaceMember, Options } from "./base.js"; import { GirConstantElement } from "../../index.js"; import { IntrospectedNamespace } from "./namespace.js"; @@ -8,21 +8,24 @@ import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export class IntrospectedConstant extends IntrospectedBase { +export class IntrospectedConstant extends IntrospectedNamespaceMember { type: TypeExpression; value: string | null; constructor({ name, type, - value - }: { + namespace, + value, + ...options + }: Options<{ name: string; type: TypeExpression; + namespace: IntrospectedNamespace; value: string | null; isIntrospectable?: boolean; - }) { - super(name); + }>) { + super(name, namespace, options); this.type = type; this.value = value; @@ -38,7 +41,7 @@ export class IntrospectedConstant extends IntrospectedBase { copy( options: { - parent?: undefined; + parent?: IntrospectedNamespace; type?: TypeExpression; } = {} ): IntrospectedConstant { @@ -46,27 +49,23 @@ export class IntrospectedConstant extends IntrospectedBase { return new IntrospectedConstant({ name, + namespace: options.parent ?? this.namespace, type: options.type ?? type, value })._copyBaseProperties(this); } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - constant: GirConstantElement - ): IntrospectedConstant { + static fromXML(element: GirConstantElement, ns: IntrospectedNamespace, options: LoadOptions): IntrospectedConstant { const c = new IntrospectedConstant({ - name: sanitizeIdentifierName(ns.name, constant.$.name), - type: getType(modName, ns, constant), - value: constant.$.value ?? null + name: sanitizeIdentifierName(ns.name, element.$.name), + namespace: ns, + type: getType(ns, element), + value: element.$.value ?? null }); if (options.loadDocs) { - c.doc = parseDoc(constant); - c.metadata = parseMetadata(constant); + c.doc = parseDoc(element); + c.metadata = parseMetadata(element); } return c; diff --git a/packages/lib/src/newlib/gir/enum.ts b/packages/lib/src/newlib/gir/enum.ts index e1a7f34c7..aaecdd4c7 100644 --- a/packages/lib/src/newlib/gir/enum.ts +++ b/packages/lib/src/newlib/gir/enum.ts @@ -1,10 +1,10 @@ import { NumberType, TypeIdentifier } from "../gir.js"; -import { IntrospectedBase } from "./base.js"; +import { IntrospectedBase, IntrospectedNamespaceMember } from "./base.js"; import { GirMemberElement, GirEnumElement, GirBitfieldElement } from "../../index.js"; import { GirComplexRecord, IntrospectedRecord } from "./class.js"; -import { Field } from "./property.js"; +import { IntrospectedField } from "./property.js"; import { IntrospectedStaticClassFunction } from "./function.js"; import { IntrospectedNamespace } from "./namespace.js"; import { parseDoc, parseMetadata, sanitizeIdentifierName, sanitizeMemberName } from "./util.js"; @@ -12,15 +12,14 @@ import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -export class IntrospectedEnum extends IntrospectedBase { +export class IntrospectedEnum extends IntrospectedNamespaceMember { members = new Map(); flags: boolean = false; - namespace: IntrospectedNamespace; ns: string; constructor(name: string, namespace: IntrospectedNamespace, options: { isIntrospectable?: boolean } = {}) { - super(sanitizeIdentifierName(namespace.name, name), options); - this.namespace = namespace; + super(sanitizeIdentifierName(namespace.name, name), namespace, options); + this.ns = namespace.name; } @@ -66,14 +65,15 @@ export class IntrospectedEnum extends IntrospectedBase { } asClass(): IntrospectedRecord { - const { name, namespace } = this; + const { name, namespace, doc } = this; - const clazz = new GirComplexRecord({ name, namespace }); + const clazz = new GirComplexRecord({ name, namespace, doc }); clazz.fields.push( ...Array.from(this.members.values()).map(m => { - const field = new Field({ + const field = new IntrospectedField({ name: m.name, + parent: clazz, type: NumberType, writable: true, isStatic: true @@ -90,38 +90,36 @@ export class IntrospectedEnum extends IntrospectedBase { } static fromXML( - modName: string, + element: GirEnumElement | GirBitfieldElement, ns: IntrospectedNamespace, options: LoadOptions, - _parent, - m: GirEnumElement | GirBitfieldElement, flags = false ): IntrospectedEnum { - const em = new IntrospectedEnum(sanitizeMemberName(m.$.name), ns); + const em = new IntrospectedEnum(sanitizeMemberName(element.$.name), ns); - if (m.$["glib:type-name"]) { - em.resolve_names.push(m.$["glib:type-name"]); + if (element.$["glib:type-name"]) { + em.resolve_names.push(element.$["glib:type-name"]); - ns.registerResolveName(m.$["glib:type-name"], ns.name, em.name); + ns.registerResolveName(element.$["glib:type-name"], ns.name, em.name); } - if (m.$["c:type"]) { - em.resolve_names.push(m.$["c:type"]); + if (element.$["c:type"]) { + em.resolve_names.push(element.$["c:type"]); - ns.registerResolveName(m.$["c:type"], ns.name, em.name); + ns.registerResolveName(element.$["c:type"], ns.name, em.name); } if (options.loadDocs) { - em.doc = parseDoc(m); - em.metadata = parseMetadata(m); + em.doc = parseDoc(element); + em.metadata = parseMetadata(element); } - if (!m.member) { + if (!element.member) { return em; } - m.member.forEach(m => { - const member = GirEnumMember.fromXML(modName, ns, options, em, m); + element.member.forEach(m => { + const member = GirEnumMember.fromXML(m, em, options); em.members.set(member.name, member); }); @@ -132,42 +130,40 @@ export class IntrospectedEnum extends IntrospectedBase { } } -export class GirEnumMember extends IntrospectedBase { +export class GirEnumMember extends IntrospectedBase { value: string; c_identifier: string; - constructor(name: string, value: string, c_identifier: string) { - super(name); + constructor(name: string, value: string, parent: IntrospectedEnum, c_identifier: string) { + super(name, parent); this.value = value; this.c_identifier = c_identifier; } + get namespace() { + return this.parent.namespace; + } + accept(visitor: GirVisitor): GirEnumMember { const node = this.copy(); return visitor.visitEnumMember?.(node) ?? node; } copy(): GirEnumMember { - const { value, name, c_identifier } = this; + const { value, name, parent, c_identifier } = this; - return new GirEnumMember(name, value, c_identifier)._copyBaseProperties(this); + return new GirEnumMember(name, value, parent, c_identifier)._copyBaseProperties(this); } - static fromXML( - _: string, - _ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - m: GirMemberElement - ): GirEnumMember { - const upper = m.$.name.toUpperCase(); - const c_identifier = m.$["c:identifier"]; + static fromXML(element: GirMemberElement, parent: IntrospectedEnum, options: LoadOptions): GirEnumMember { + const upper = element.$.name.toUpperCase(); + const c_identifier = element.$["c:identifier"]; - const enumMember = new GirEnumMember(upper, m.$.value, c_identifier); + const enumMember = new GirEnumMember(upper, element.$.value, parent, c_identifier); if (options.loadDocs) { - enumMember.doc = parseDoc(m); - enumMember.metadata = parseMetadata(m); + enumMember.doc = parseDoc(element); + enumMember.metadata = parseMetadata(element); } return enumMember; @@ -213,41 +209,39 @@ export class IntrospectedError extends IntrospectedEnum { } static fromXML( - modName: string, + element: GirEnumElement | GirBitfieldElement, ns: IntrospectedNamespace, - options: LoadOptions, - parent, - m: GirEnumElement | GirBitfieldElement + options: LoadOptions ): IntrospectedEnum { - const err = new IntrospectedError(sanitizeMemberName(m.$.name), ns); + const err = new IntrospectedError(sanitizeMemberName(element.$.name), ns); - if (m.$["glib:type-name"]) { - err.resolve_names.push(m.$["glib:type-name"]); + if (element.$["glib:type-name"]) { + err.resolve_names.push(element.$["glib:type-name"]); - ns.registerResolveName(m.$["glib:type-name"], ns.name, err.name); + ns.registerResolveName(element.$["glib:type-name"], ns.name, err.name); } - if (m.$["c:type"]) { - err.resolve_names.push(m.$["c:type"]); + if (element.$["c:type"]) { + err.resolve_names.push(element.$["c:type"]); - ns.registerResolveName(m.$["c:type"], ns.name, err.name); + ns.registerResolveName(element.$["c:type"], ns.name, err.name); } if (options.loadDocs) { - err.doc = parseDoc(m); - err.metadata = parseMetadata(m); + err.doc = parseDoc(element); + err.metadata = parseMetadata(element); } - if (m.member) { - m.member.forEach(m => { - const member = GirEnumMember.fromXML(modName, ns, options, parent, m); + if (element.member) { + element.member.forEach(m => { + const member = GirEnumMember.fromXML(m, err, options); err.members.set(member.name, member); }); } - if (isEnumElement(m) && m.function) { - m.function.forEach(f => { - const func = IntrospectedStaticClassFunction.fromXML(modName, ns, options, err, f); + if (isEnumElement(element) && element.function) { + element.function.forEach(f => { + const func = IntrospectedStaticClassFunction.fromXML(f, err, options); err.functions.set(func.name, func); }); } diff --git a/packages/lib/src/newlib/gir/function.ts b/packages/lib/src/newlib/gir/function.ts index 2852f0c41..76fd4fea2 100644 --- a/packages/lib/src/newlib/gir/function.ts +++ b/packages/lib/src/newlib/gir/function.ts @@ -10,7 +10,7 @@ import { FunctionType } from "../gir.js"; -import { IntrospectedBase, Options } from "./base.js"; +import { IntrospectedBase, IntrospectedClassMember, IntrospectedNamespaceMember, Options } from "./base.js"; import { GirFunctionElement, GirMethodElement, @@ -18,30 +18,33 @@ import { GirCallableParamElement, GirCallbackElement, GirVirtualMethodElement, - GirConstructorElement + GirConstructorElement, + GirModule } from "../../index.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { getType, isInvalid, sanitizeMemberName, sanitizeIdentifierName, parseDoc, parseMetadata } from "./util.js"; -import { IntrospectedBaseClass, IntrospectedClass } from "./class.js"; +import { IntrospectedClass } from "./class.js"; import { IntrospectedEnum } from "./enum.js"; import { IntrospectedSignal } from "./signal.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; -import { Field } from "./property.js"; +import { IntrospectedField } from "./property.js"; +import { IntrospectedBaseClass } from "./nodes.js"; function hasShadow(obj: GirFunctionElement | GirMethodElement): obj is GirFunctionElement & { $: { shadows: string } } { return obj.$["shadows"] != null; } -export class IntrospectedFunction extends IntrospectedBase { +export class IntrospectedFunction extends IntrospectedNamespaceMember { readonly parameters: IntrospectedFunctionParameter[]; readonly output_parameters: IntrospectedFunctionParameter[]; readonly return_type: TypeExpression; readonly raw_name: string; generics: Generic[] = []; + returnTypeDoc: string | null; constructor({ name, @@ -49,6 +52,7 @@ export class IntrospectedFunction extends IntrospectedBase { return_type = UnknownType, parameters = [], output_parameters = [], + namespace, ...args }: Options<{ name: string; @@ -56,26 +60,32 @@ export class IntrospectedFunction extends IntrospectedBase { return_type?: TypeExpression; parameters?: IntrospectedFunctionParameter[]; output_parameters?: IntrospectedFunctionParameter[]; + namespace: GirModule; }>) { - super(name, { ...args }); + super(name, namespace, { ...args }); this.raw_name = raw_name; this.parameters = parameters.map(p => p.copy({ parent: this })); this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); this.return_type = return_type; + this.returnTypeDoc = null; } - copy({ - outputParameters, - parameters, - return_type - }: { - parent?: undefined; - parameters?: IntrospectedFunctionParameter[]; - outputParameters?: IntrospectedFunctionParameter[]; - return_type?: TypeExpression; - } = {}): IntrospectedFunction { + copy( + { + parent = this.parent, + outputParameters, + parameters, + return_type + }: { + parent?: GirModule; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; + return_type?: TypeExpression; + } = { parent: this.parent } + ): IntrospectedFunction { const fn = new IntrospectedFunction({ + namespace: parent ?? this.namespace, raw_name: this.raw_name, name: this.name, return_type: return_type ?? this.return_type, @@ -83,6 +93,7 @@ export class IntrospectedFunction extends IntrospectedBase { parameters: parameters ?? this.parameters }); + fn.returnTypeDoc = this.returnTypeDoc; fn.generics = [...this.generics]; return fn._copyBaseProperties(this); @@ -90,6 +101,7 @@ export class IntrospectedFunction extends IntrospectedBase { accept(visitor: GirVisitor): IntrospectedFunction { const node = this.copy({ + parent: this.parent, parameters: this.parameters.map(p => { return p.accept(visitor); }), @@ -103,43 +115,49 @@ export class IntrospectedFunction extends IntrospectedBase { } static fromXML( - modName: string, + element: GirFunctionElement | GirMethodElement, ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - func: GirFunctionElement | GirMethodElement + options: LoadOptions ): IntrospectedFunction { - let raw_name = func.$.name; + let raw_name = element.$.name; let name = sanitizeIdentifierName(null, raw_name); - if (hasShadow(func)) { - raw_name = func.$["shadows"]; - name = sanitizeIdentifierName(null, func.$["shadows"]); + if (hasShadow(element)) { + raw_name = element.$["shadows"]; + name = sanitizeIdentifierName(null, element.$["shadows"]); } + // TODO: Don't create a useless function object here + let fn = new IntrospectedFunction({ + name, + raw_name, + namespace: ns, + isIntrospectable: isIntrospectable(element) + }); + let return_type: TypeExpression; - if ("return-value" in func && func["return-value"] && func["return-value"].length > 0) { - const value = func["return-value"][0]; + if ("return-value" in element && element["return-value"] && element["return-value"].length > 0) { + const value = element["return-value"][0]; + + return_type = getType(ns, value); - return_type = getType(modName, ns, value); + fn.returnTypeDoc = parseDoc(value); } else { return_type = VoidType; } let parameters: IntrospectedFunctionParameter[] = []; - if (func.parameters) { - const param = func.parameters[0].parameter; + if (element.parameters) { + const param = element.parameters[0].parameter; if (param) { const inputs = param.filter((p): p is typeof p & { $: { name: string } } => { return !!p.$.name; }); - parameters.push( - ...inputs.map(i => IntrospectedFunctionParameter.fromXML(modName, ns, options, null, i)) - ); + parameters.push(...inputs.map(i => IntrospectedFunctionParameter.fromXML(i, fn, options))); const unwrapped = return_type.unwrap(); @@ -214,18 +232,16 @@ export class IntrospectedFunction extends IntrospectedBase { ) .map(parameter => parameter.copy({ isOptional: false })); - const fn = new IntrospectedFunction({ + fn = fn.copy({ + parent: ns, parameters: input_parameters, - output_parameters, - return_type, - name, - raw_name, - isIntrospectable: isIntrospectable(func) + outputParameters: output_parameters, + return_type }); if (options.loadDocs) { - fn.doc = parseDoc(func); - fn.metadata = parseMetadata(func); + fn.doc = parseDoc(element); + fn.metadata = parseMetadata(element); } return fn; @@ -236,9 +252,10 @@ export class IntrospectedFunction extends IntrospectedBase { } asCallback(): IntrospectedCallback { - const { raw_name, name, output_parameters, parameters, return_type } = this; + const { name, raw_name, namespace, output_parameters, parameters, return_type } = this; return new IntrospectedCallback({ + namespace, raw_name, name, output_parameters, @@ -250,7 +267,7 @@ export class IntrospectedFunction extends IntrospectedBase { asClassFunction(parent: IntrospectedBaseClass | IntrospectedEnum): IntrospectedClassFunction { const { raw_name: name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; - return new IntrospectedClassFunction({ + const fn = new IntrospectedClassFunction({ parent, name, output_parameters, @@ -259,6 +276,10 @@ export class IntrospectedFunction extends IntrospectedBase { doc, isIntrospectable }); + + fn.returnTypeDoc = this.returnTypeDoc; + + return fn; } asVirtualClassFunction(parent: IntrospectedBaseClass): IntrospectedVirtualClassFunction { @@ -294,17 +315,33 @@ export class IntrospectedFunction extends IntrospectedBase { } } -export class IntrospectedDirectAllocationConstructor extends IntrospectedBase { - fields: Field[]; +export class IntrospectedDirectAllocationConstructor extends IntrospectedClassMember { + parameters: IntrospectedFunctionParameter[]; - constructor(fields: Field[]) { - super("new", { isPrivate: false, isIntrospectable: true }); + constructor(parameters: IntrospectedFunctionParameter[], parent: IntrospectedBaseClass | null) { + super("new", parent, { isPrivate: false, isIntrospectable: true }); - this.fields = fields + this.parameters = parameters.map(parameter => parameter.copy({ parent: this })); + } + + static fromFields(fields: IntrospectedField[], parent: IntrospectedBaseClass) { + const building = new IntrospectedDirectAllocationConstructor([], parent); + + building.parameters = fields .filter(field => { return !field.isStatic && !field.isPrivate && !field.type.isPointer; }) - .map(field => field.copy({ parent: this })); + .map( + field => + new IntrospectedFunctionParameter({ + parent: building, + type: field.type, + name: field.name, + direction: GirDirection.In + }) + ); + + return building; } asString>(generator: T): ReturnType { @@ -314,9 +351,14 @@ export class IntrospectedDirectAllocationConstructor extends IntrospectedBase { } copy( - options?: { parent?: IntrospectedBase | undefined; fields: Field[] } | undefined + options?: + | { parent?: IntrospectedBaseClass | undefined; parameters?: IntrospectedFunctionParameter[] } + | undefined ): IntrospectedDirectAllocationConstructor { - const copy = new IntrospectedDirectAllocationConstructor(options?.fields ?? this.fields); + const copy = new IntrospectedDirectAllocationConstructor( + options?.parameters ?? this.parameters, + options?.parent ?? this.parent + ); copy._copyBaseProperties(this); @@ -325,8 +367,8 @@ export class IntrospectedDirectAllocationConstructor extends IntrospectedBase { accept(visitor: GirVisitor): IntrospectedDirectAllocationConstructor { const node = this.copy({ - fields: this.fields.map(field => { - return field.accept(visitor); + parameters: this.parameters.map(parameters => { + return parameters.accept(visitor); }) }); @@ -334,7 +376,7 @@ export class IntrospectedDirectAllocationConstructor extends IntrospectedBase { } } -export class IntrospectedConstructor extends IntrospectedBase { +export class IntrospectedConstructor extends IntrospectedClassMember { readonly parameters: IntrospectedFunctionParameter[] = []; readonly return_type: TypeExpression = UnknownType; @@ -342,40 +384,42 @@ export class IntrospectedConstructor extends IntrospectedBase { name, parameters = [], return_type, + parent, ...args }: Options<{ name: string; + parent: IntrospectedBaseClass | null; parameters?: IntrospectedFunctionParameter[]; return_type: TypeExpression; }>) { - super(name, { ...args }); + super(name, parent, { ...args }); this.return_type = return_type; this.parameters = parameters.map(p => p.copy({ parent: this })); } copy({ + parent, parameters, return_type }: { - parent?: undefined; + parent?: IntrospectedBaseClass; parameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; } = {}): IntrospectedConstructor { return new IntrospectedConstructor({ name: this.name, + parent: parent ?? this.parent ?? null, return_type: return_type ?? this.return_type, parameters: parameters ?? this.parameters })._copyBaseProperties(this); } static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, + m: GirConstructorElement, parent: IntrospectedBaseClass, - m: GirConstructorElement + options: LoadOptions ): IntrospectedConstructor { - return IntrospectedClassFunction.fromXML(modName, ns, options, parent, m as GirFunctionElement).asConstructor(); + return IntrospectedClassFunction.fromXML(m as GirFunctionElement, parent, options).asConstructor(); } accept(visitor: GirVisitor): IntrospectedConstructor { @@ -398,13 +442,19 @@ export class IntrospectedConstructor extends IntrospectedBase { } } -export class IntrospectedFunctionParameter extends IntrospectedBase { +export class IntrospectedFunctionParameter extends IntrospectedBase< + | IntrospectedClassFunction + | IntrospectedFunction + | IntrospectedSignal + | IntrospectedConstructor + | IntrospectedDirectAllocationConstructor + | null +> { readonly type: TypeExpression; readonly direction: GirDirection; readonly isVarArgs: boolean = false; readonly isOptional: boolean = false; readonly isNullable: boolean = false; - readonly parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; constructor({ name, @@ -418,7 +468,13 @@ export class IntrospectedFunctionParameter extends IntrospectedBase { ...args }: Options<{ name: string; - parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; + parent?: + | IntrospectedClassFunction + | IntrospectedFunction + | IntrospectedSignal + | IntrospectedConstructor + | IntrospectedDirectAllocationConstructor + | null; type: TypeExpression; direction: GirDirection; doc?: string | null; @@ -426,9 +482,8 @@ export class IntrospectedFunctionParameter extends IntrospectedBase { isOptional?: boolean; isNullable?: boolean; }>) { - super(name, { ...args }); + super(name, parent ?? null, { ...args }); - this.parent = parent; this.type = type; this.direction = direction; this.doc = doc; @@ -437,9 +492,31 @@ export class IntrospectedFunctionParameter extends IntrospectedBase { this.isNullable = isNullable; } + get namespace() { + if (!this.parent) throw new Error(`Failed to get namespace for ${this.name}`); + + return this.parent.namespace; + } + + asField() { + const { name, parent, isOptional: optional, type } = this; + + if (!(parent?.parent instanceof IntrospectedBaseClass)) { + throw new Error("Can't convert parameter of non-class function to field"); + } + + return new IntrospectedField({ name, parent: parent.parent, optional, type }); + } + copy( options: { - parent?: IntrospectedClassFunction | IntrospectedFunction | IntrospectedSignal | IntrospectedConstructor; + parent?: + | IntrospectedClassFunction + | IntrospectedFunction + | IntrospectedSignal + | IntrospectedConstructor + | IntrospectedDirectAllocationConstructor + | null; type?: TypeExpression; isOptional?: boolean; isNullable?: boolean; @@ -473,13 +550,14 @@ export class IntrospectedFunctionParameter extends IntrospectedBase { return generator.generateParameter(this); } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedSignal | IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor | null, - parameter: GirCallableParamElement & { $: { name: string } } + static fromXML< + Parent extends IntrospectedSignal | IntrospectedClassFunction | IntrospectedFunction | IntrospectedConstructor + >( + parameter: GirCallableParamElement & { $: { name: string } }, + parent: Parent, + options: LoadOptions ): IntrospectedFunctionParameter { + const ns = parent.namespace; let name = sanitizeMemberName(parameter.$.name); if (isInvalid(name)) { @@ -518,10 +596,10 @@ export class IntrospectedFunctionParameter extends IntrospectedBase { isNullable = true; } - type = getType(modName, ns, parameter); + type = getType(ns, parameter); } else if (parameter.$.direction === GirDirection.Out) { direction = parameter.$.direction; - type = getType(modName, ns, parameter); + type = getType(ns, parameter); } else { throw new Error(`Unknown parameter direction: ${parameter.$.direction as string}`); } @@ -546,14 +624,14 @@ export class IntrospectedFunctionParameter extends IntrospectedBase { } } -export class IntrospectedClassFunction extends IntrospectedBase { +export class IntrospectedClassFunction extends IntrospectedBase { readonly parameters: IntrospectedFunctionParameter[]; protected readonly return_type: TypeExpression; readonly output_parameters: IntrospectedFunctionParameter[]; protected _anyify: boolean = false; protected _generify: boolean = false; - parent: IntrospectedBaseClass | IntrospectedEnum; interfaceParent: IntrospectedBaseClass | IntrospectedEnum | null = null; + returnTypeDoc?: string | null; generics: Generic[] = []; @@ -573,22 +651,38 @@ export class IntrospectedClassFunction extends IntrospectedBase { parent: IntrospectedBaseClass | IntrospectedEnum; doc?: string | null; }>) { - super(name, { ...args }); + super(name, parent, { ...args }); this.parameters = parameters.map(p => p.copy({ parent: this })); this.output_parameters = output_parameters.map(p => p.copy({ parent: this })); this.return_type = return_type; - this.parent = parent; this.doc = doc; } + get namespace() { + return this.parent.namespace; + } + + asCallback(): IntrospectedClassCallback { + const { name, parent, output_parameters, parameters, return_type } = this; + + return new IntrospectedClassCallback({ + parent, + name, + output_parameters, + parameters, + return_type + }); + } + asConstructor(): IntrospectedConstructor { - const { name, parameters } = this; + const { name, parent, parameters } = this; - if (this.parent instanceof IntrospectedBaseClass) { + if (parent instanceof IntrospectedBaseClass) { // Always force constructors to have the correct return type. return new IntrospectedConstructor({ name, + parent, parameters, return_type: this.parent.getType(), isIntrospectable: this.isIntrospectable @@ -596,7 +690,7 @@ export class IntrospectedClassFunction extends IntrospectedBase { } throw new Error( - `Attempted to convert GirClassFunction into GirConstructor from invalid parent: ${this.parent.name}` + `Attempted to convert GirClassFunction into GirConstructor from invalid enum parent: ${this.parent.name}` ); } @@ -643,6 +737,7 @@ export class IntrospectedClassFunction extends IntrospectedBase { }); fn.generics = [...this.generics]; + fn.returnTypeDoc = this.returnTypeDoc; if (interfaceParent) { fn.interfaceParent = interfaceParent; @@ -678,13 +773,11 @@ export class IntrospectedClassFunction extends IntrospectedBase { } static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, + element: GirFunctionElement | GirMethodElement, parent: IntrospectedBaseClass | IntrospectedEnum, - m: GirFunctionElement | GirMethodElement + options: LoadOptions ): IntrospectedClassFunction { - const fn = IntrospectedFunction.fromXML(modName, ns, options, null, m); + const fn = IntrospectedFunction.fromXML(element, parent.namespace, options); return fn.asClassFunction(parent); } @@ -744,13 +837,11 @@ export class IntrospectedVirtualClassFunction extends IntrospectedClassFunction } static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, + m: GirVirtualMethodElement, parent: IntrospectedBaseClass, - m: GirVirtualMethodElement + options: LoadOptions ): IntrospectedVirtualClassFunction { - const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); + const fn = IntrospectedFunction.fromXML(m, parent.namespace, options); return fn.asVirtualClassFunction(parent); } @@ -780,13 +871,11 @@ export class IntrospectedStaticClassFunction extends IntrospectedClassFunction { } static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, + m: GirFunctionElement, parent: IntrospectedBaseClass | IntrospectedEnum, - m: GirFunctionElement + options: LoadOptions ): IntrospectedStaticClassFunction { - const fn = IntrospectedFunction.fromXML(modName, ns, options, parent, m); + const fn = IntrospectedFunction.fromXML(m, parent.namespace, options); return fn.asStaticClassFunction(parent); } @@ -803,9 +892,10 @@ export class IntrospectedCallback extends IntrospectedFunction { copy({ parameters, returnType, - outputParameters + outputParameters, + parent }: { - parent?: undefined; + parent?: GirModule; parameters?: IntrospectedFunctionParameter[]; outputParameters?: IntrospectedFunctionParameter[]; returnType?: TypeExpression; @@ -815,7 +905,8 @@ export class IntrospectedCallback extends IntrospectedFunction { raw_name: this.raw_name, return_type: returnType ?? this.return_type, parameters: parameters ?? this.parameters, - output_parameters: outputParameters ?? this.output_parameters + output_parameters: outputParameters ?? this.output_parameters, + namespace: parent ?? this.parent })._copyBaseProperties(this); cb.generics = [...this.generics]; @@ -837,26 +928,21 @@ export class IntrospectedCallback extends IntrospectedFunction { return visitor.visitCallback?.(node) ?? node; } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - _parent, - func: GirCallbackElement - ): IntrospectedCallback { - const cb = IntrospectedFunction.fromXML(modName, ns, options, null, func).asCallback(); - - const glibTypeName = func.$["glib:type-name"]; - if (typeof glibTypeName === "string" && func.$["glib:type-name"]) { + static fromXML(element: GirCallbackElement, namespace: GirModule, options: LoadOptions): IntrospectedCallback { + const ns = namespace; + const cb = IntrospectedFunction.fromXML(element, ns, options).asCallback(); + + const glibTypeName = element.$["glib:type-name"]; + if (typeof glibTypeName === "string" && element.$["glib:type-name"]) { cb.resolve_names.push(glibTypeName); ns.registerResolveName(glibTypeName, ns.name, cb.name); } - if (func.$["c:type"]) { - cb.resolve_names.push(func.$["c:type"]); + if (element.$["c:type"]) { + cb.resolve_names.push(element.$["c:type"]); - ns.registerResolveName(func.$["c:type"], ns.name, cb.name); + ns.registerResolveName(element.$["c:type"], ns.name, cb.name); } return cb; @@ -866,3 +952,78 @@ export class IntrospectedCallback extends IntrospectedFunction { return generator.generateCallback(this) as ReturnType; } } + +export class IntrospectedClassCallback extends IntrospectedClassFunction { + asFunctionType(): FunctionType { + return new FunctionType( + Object.fromEntries(this.parameters.map(p => [p.name, p.type] as const)), + this.return_type + ); + } + + copy({ + parameters, + returnType, + outputParameters, + parent + }: { + parent?: IntrospectedBaseClass; + parameters?: IntrospectedFunctionParameter[]; + outputParameters?: IntrospectedFunctionParameter[]; + returnType?: TypeExpression; + } = {}): IntrospectedClassCallback { + const cb = new IntrospectedClassCallback({ + name: this.name, + return_type: returnType ?? this.return_type, + parameters: parameters ?? this.parameters, + output_parameters: outputParameters ?? this.output_parameters, + parent: parent ?? this.parent + })._copyBaseProperties(this); + + cb.generics = [...this.generics]; + + return cb; + } + + accept(visitor: GirVisitor): IntrospectedClassCallback { + const node = this.copy({ + parameters: this.parameters.map(p => { + return p.accept(visitor); + }), + outputParameters: this.output_parameters.map(p => { + return p.accept(visitor); + }), + returnType: visitor.visitType?.(this.return_type) + }); + + return visitor.visitClassCallback?.(node) ?? node; + } + + static fromXML( + element: GirCallbackElement, + parent: IntrospectedBaseClass, + options: LoadOptions + ): IntrospectedClassCallback { + const ns = parent.namespace; + const cb = IntrospectedClassFunction.fromXML(element, parent, options).asCallback(); + + const glibTypeName = element.$["glib:type-name"]; + if (typeof glibTypeName === "string" && element.$["glib:type-name"]) { + cb.resolve_names.push(glibTypeName); + + ns.registerResolveName(glibTypeName, ns.name, cb.name); + } + + if (element.$["c:type"]) { + cb.resolve_names.push(element.$["c:type"]); + + ns.registerResolveName(element.$["c:type"], ns.name, cb.name); + } + + return cb; + } + + asString>(generator: T): ReturnType { + return generator.generateClassCallback(this) as ReturnType; + } +} diff --git a/packages/lib/src/newlib/gir/namespace.ts b/packages/lib/src/newlib/gir/namespace.ts index b2c1e7f35..2c57825ee 100644 --- a/packages/lib/src/newlib/gir/namespace.ts +++ b/packages/lib/src/newlib/gir/namespace.ts @@ -1,29 +1,13 @@ -import { - NullableType, - ObjectType, - BinaryType, - VoidType, - PromiseType, - BooleanType, - TupleType, - TypeIdentifier, - ClosureType -} from "../gir.js"; +import { BinaryType, VoidType, PromiseType, BooleanType, TupleType, TypeIdentifier, ClosureType } from "../gir.js"; -import { IntrospectedBase } from "./base.js"; -import { ParsedGir, GirInfoAttrs, GirType } from "../../index.js"; -import { isPrimitiveType } from "./util.js"; +import { GirInfoAttrs, GirModule } from "../../index.js"; -import { IntrospectedClass, IntrospectedInterface, IntrospectedRecord, IntrospectedBaseClass } from "./class.js"; -import { IntrospectedFunction, IntrospectedCallback } from "./function.js"; -import { IntrospectedEnum, IntrospectedError } from "./enum.js"; +import { IntrospectedBaseClass } from "./class.js"; +import { IntrospectedFunction } from "./function.js"; +import { IntrospectedEnum } from "./enum.js"; import { IntrospectedConstant } from "./const.js"; import { IntrospectedAlias } from "./alias.js"; -import { LoadOptions } from "../types.js"; -import { NSRegistry } from "./registry.js"; -import { GirVisitor } from "../visitor.js"; - export type GirNSMember = | IntrospectedBaseClass | IntrospectedFunction @@ -37,7 +21,7 @@ export const isDeprecated = (e: { $: GirInfoAttrs }) => e && e.$ && e.$.deprecat export const deprecatedVersion = (e: { $: GirInfoAttrs }) => e?.$?.["deprecated-version"]; export const introducedVersion = (e: { $: GirInfoAttrs }) => e?.$?.version; -export function promisifyNamespaceFunctions(namespace: IntrospectedNamespace) { +export function promisifyNamespaceFunctions(namespace: GirModule) { return namespace.members.forEach(node => { if (!(node instanceof IntrospectedFunction)) return; @@ -95,487 +79,4 @@ export function promisifyNamespaceFunctions(namespace: IntrospectedNamespace) { }); } -export class IntrospectedNamespace { - readonly name: string; - readonly version: string; - readonly c_prefixes: string[]; - - private imports: Map = new Map(); - default_imports: Map = new Map(); - - private _members?: Map; - private _enum_constants?: Map; - private _resolve_names: Map = new Map(); - __dts__references?: string[]; - - package_version!: readonly [string, string] | readonly [string, string, string]; - parent!: NSRegistry; - - constructor(name: string, version: string, prefixes: string[]) { - this.name = name; - this.version = version; - this.c_prefixes = [...prefixes]; - this.package_version = ["0", "0"]; - } - - registerResolveName(resolveName: string, namespace: string, name: string) { - this._resolve_names.set(resolveName, new TypeIdentifier(name, namespace)); - } - - get members(): Map { - if (!this._members) { - this._members = new Map(); - } - - return this._members; - } - - get enum_constants(): Map { - if (!this._enum_constants) { - this._enum_constants = new Map(); - } - - return this._enum_constants; - } - - accept(visitor: GirVisitor) { - for (const key of [...this.members.keys()]) { - const member = this.members.get(key); - - if (!member) continue; - - if (Array.isArray(member)) { - this.members.set( - key, - member.map(m => { - return m.accept(visitor); - }) - ); - } else { - this.members.set(key, member.accept(visitor)); - } - } - } - - getImportsForCPrefix(c_prefix: string): IntrospectedNamespace[] { - return this.parent.namespacesForPrefix(c_prefix); - } - - hasImport(name: string): boolean { - return this.default_imports.has(name) || this.imports.has(name); - } - - private _getImport(name: string): IntrospectedNamespace | null { - let version = this.default_imports.get(name) ?? this.imports.get(name); - - if (name === this.name) { - return this; - } - - // TODO: Clean this up, but essentially try to resolve import versions - // using transitive imports (e.g. use GtkSource to find the version of Gtk) - if (!version) { - const entries = [...this.default_imports.entries()].flatMap(([_name]) => { - const namespace = this._getImport(_name); - - return [...(namespace?.default_imports.entries() ?? [])]; - }); - - version = Object.fromEntries(entries)[name]; - } - - if (!version) { - version = this.parent.assertDefaultVersionOf(name); - } - - const namespace = this.parent.namespace(name, version); - - if (namespace) { - if (!this.imports.has(namespace.name)) { - this.imports.set(namespace.name, namespace.version); - } - } - - return namespace; - } - - getInstalledImport(name: string): IntrospectedNamespace | null { - let version = this.default_imports.get(name) ?? this.imports.get(name); - - if (name === this.name) { - return this; - } - - if (!version) { - version = this.parent.defaultVersionOf(name) ?? undefined; - } - - if (!version) { - return null; - } - - const namespace = this.parent.namespace(name, version); - - if (namespace) { - if (!this.imports.has(namespace.name)) { - this.imports.set(namespace.name, namespace.version); - } - } - - return namespace; - } - - assertInstalledImport(name: string): IntrospectedNamespace { - const namespace = this._getImport(name); - - if (!namespace) { - throw new Error(`Failed to import ${name} in ${this.name}, not installed or accessible.`); - } - - return namespace; - } - - getImports(): [string, string][] { - return [...this.imports.entries()].sort(([[a], [b]]) => a.localeCompare(b)); - } - - addImport(ns_name: string) { - this._getImport(ns_name); - } - - getMembers(name: string): IntrospectedBase[] { - const members = this.members.get(name); - - if (Array.isArray(members)) { - return [...members]; - } - return members ? [members] : []; - } - - getMemberWithoutOverrides(name: string) { - if (this.members.has(name)) { - const member = this.members.get(name); - - if (!Array.isArray(member)) { - return member; - } - - return null; - } - - const resolvedName = this._resolve_names.get(name); - if (resolvedName) { - const member = this.members.get(resolvedName.name); - - if (!Array.isArray(member)) { - return member; - } - } - - return null; - } - - assertClass(name: string): IntrospectedBaseClass { - const clazz = this.getClass(name); - - if (!clazz) { - throw new Error(`Class ${name} does not exist in namespace ${this.name}.`); - } - - return clazz; - } - - getClass(name: string): IntrospectedBaseClass | null { - const member = this.getMemberWithoutOverrides(name); - - if (member instanceof IntrospectedBaseClass) { - return member; - } - return null; - } - - getEnum(name: string): IntrospectedEnum | null { - const member = this.getMemberWithoutOverrides(name); - - if (member instanceof IntrospectedEnum) { - return member; - } - return null; - } - - getAlias(name: string): IntrospectedAlias | null { - const member = this.getMemberWithoutOverrides(name); - - if (member instanceof IntrospectedAlias) { - return member; - } - return null; - } - - hasSymbol(name: string) { - return this.members.has(name); - } - - resolveSymbolFromTypeName(name: string): string | null { - const resolvedName = this._resolve_names.get(name); - - if (!resolvedName) { - return null; - } - - const member = this.members.get(resolvedName.name); - if (member instanceof IntrospectedBase) { - return member.name; - } - - return null; - } - - findClassCallback(name: string): [string | null, string] { - const clazzes = Array.from(this.members.values()).filter( - (m): m is IntrospectedBaseClass => m instanceof IntrospectedBaseClass - ); - const res = clazzes - .map<[IntrospectedBaseClass, IntrospectedCallback | undefined]>(m => [ - m, - m.callbacks.find(c => c.name === name || c.resolve_names.includes(name)) - ]) - .find((r): r is [IntrospectedBaseClass, IntrospectedCallback] => r[1] != null); - - if (res) { - return [res[0].name, res[1].name]; - } else { - return [null, name]; - } - } - - /** - * This is an internal method to add TypeScript - * comments when overrides use parts of the TypeScript standard - * libraries that are newer than default. - */ - ___dts___addReference(reference: string) { - this.__dts__references ??= []; - this.__dts__references.push(reference); - } - - static fromXML(repo: ParsedGir, options: LoadOptions, registry: NSRegistry): IntrospectedNamespace { - const ns = repo.repository[0]?.namespace?.[0]; - - if (!ns) throw new Error(`Missing namespace in ${repo.repository[0].package[0].$.name}`); - - const modName = ns.$["name"]; - let version = ns.$["version"]; - - // Hardcode harfbuzz version for now... - if (modName === "HarfBuzz" && version === "0.0") { - version = "2.0"; - } - - if (!modName) { - throw new Error("Invalid GIR file: no namespace name specified."); - } - - if (!version) { - throw new Error("Invalid GIR file: no version name specified."); - } - - const c_prefix = ns.$?.["c:symbol-prefixes"]?.split(",") ?? []; - - if (options.verbose) { - console.debug(`Parsing ${modName}...`); - } - - const building = new IntrospectedNamespace(modName, version, c_prefix); - building.parent = registry; - // Set the namespace object here to prevent re-parsing the namespace if - // another namespace imports it. - registry.mapping.set(modName, version, building); - - const includes = repo.repository[0].include || []; - - includes - .map(i => [i.$.name, i.$.version] as const) - .forEach(([name, version]) => { - if (version) { - if (options.verbose) { - console.debug(`Adding dependency ${name} ${version}...`); - } - - building.default_imports.set(name, version); - } - }); - - const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { - return !building.hasImport(el.name); - }; - - if (ns.enumeration) { - // Get the requested enums - ns.enumeration - ?.map(enumeration => { - if (enumeration.$["glib:error-domain"]) { - return IntrospectedError.fromXML(modName, building, options, null, enumeration); - } else { - return IntrospectedEnum.fromXML(modName, building, options, null, enumeration); - } - }) - .forEach(c => building.members.set(c.name, c)); - } - - // Constants - if (ns.constant) { - ns.constant - ?.filter(isIntrospectable) - .map(constant => IntrospectedConstant.fromXML(modName, building, options, null, constant)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - // Get the requested functions - if (ns.function) { - ns.function - ?.filter(isIntrospectable) - .map(func => IntrospectedFunction.fromXML(modName, building, options, null, func)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - if (ns.callback) { - ns.callback - ?.filter(isIntrospectable) - .map(callback => IntrospectedCallback.fromXML(modName, building, options, null, callback)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - if (ns["glib:boxed"]) { - ns["glib:boxed"] - ?.filter(isIntrospectable) - .map(boxed => new IntrospectedAlias({ name: boxed.$["glib:name"], type: new NullableType(ObjectType) })) - .forEach(c => building.members.set(c.name, c)); - } - - // Bitfield is a type of enum - if (ns.bitfield) { - ns.bitfield - ?.filter(isIntrospectable) - .map(field => IntrospectedEnum.fromXML(modName, building, options, building, field, true)) - .forEach(c => building.members.set(c.name, c)); - } - - // The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y) - // to the name of the enum (Button) to resolve references (Gtk.Button.Y) - Array.from(building.members.values()) - .filter((m): m is IntrospectedEnum => m instanceof IntrospectedEnum) - .forEach(m => { - m.members.forEach(member => { - building.enum_constants.set(member.c_identifier, [m.name, member.name] as const); - }); - }); - - // Get the requested classes - if (ns.class) { - ns.class - ?.filter(isIntrospectable) - .map(klass => IntrospectedClass.fromXML(modName, building, options, building, klass)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - if (ns.record) { - ns.record - ?.filter(isIntrospectable) - .map(record => IntrospectedRecord.fromXML(modName, building, options, record)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - if (ns.union) { - ns.union - ?.filter(isIntrospectable) - .map(union => IntrospectedRecord.fromXML(modName, building, options, union)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - if (ns.interface) { - ns.interface - ?.map(inter => IntrospectedInterface.fromXML(modName, building, options, inter)) - .filter(importConflicts) - .forEach(c => building.members.set(c.name, c)); - } - - if (ns.alias) { - type NamedType = GirType & { $: { name: string } }; - - ns.alias - ?.filter(isIntrospectable) - // Avoid attempting to alias non-introspectable symbols. - .map(b => { - b.type = b.type - ?.filter((t): t is NamedType => !!(t && t.$.name)) - .map(t => { - if ( - t.$.name && - !building.hasSymbol(t.$.name) && - !isPrimitiveType(t.$.name) && - !t.$.name.includes(".") - ) { - return { $: { name: "unknown", "c:type": "unknown" } } as GirType; - } - - return t; - }); - - return b; - }) - .map(alias => IntrospectedAlias.fromXML(modName, building, options, null, alias)) - .filter((alias): alias is IntrospectedAlias => alias != null) - .forEach(c => building.members.set(c.name, c)); - } - - try { - let [major = null] = building.getMembers("MAJOR_VERSION"); - let [minor = null] = building.getMembers("MINOR_VERSION"); - let [micro = null] = building.getMembers("MICRO_VERSION"); - - if (!major) { - major = building.getMembers("VERSION_MAJOR")[0] ?? null; - } - - if (!minor) { - minor = building.getMembers("VERSION_MINOR")[0] ?? null; - } - - if (!micro) { - micro = building.getMembers("VERSION_MICRO")[0] ?? null; - } - - if ( - major instanceof IntrospectedConstant && - minor instanceof IntrospectedConstant && - major.value && - minor.value - ) { - if (micro instanceof IntrospectedConstant && micro.value) { - building.package_version = [major.value, minor.value, micro.value] as const; - } else { - building.package_version = [major.value, minor.value] as const; - } - } else { - const [major = "", minor = "0", micro] = building.version.split(".").filter(v => v != ""); - - if (micro) { - building.package_version = [major, minor, micro]; - } else { - building.package_version = [major, minor]; - } - } - } catch (error) { - console.error(`Failed to parse package version for ${building.name} with version ${building.version}`); - } - - return building; - } -} +export { GirModule as IntrospectedNamespace } from "../../gir-module.js"; diff --git a/packages/lib/src/newlib/gir/nodes.ts b/packages/lib/src/newlib/gir/nodes.ts index aeebaa06d..f215db9c2 100644 --- a/packages/lib/src/newlib/gir/nodes.ts +++ b/packages/lib/src/newlib/gir/nodes.ts @@ -1,25 +1,47 @@ -export { IntrospectedAlias as GirAlias } from "./alias.js"; +export { IntrospectedAlias } from "./alias.js"; export { - IntrospectedClass as GirClass, - IntrospectedInterface as GirInterface, - IntrospectedRecord as GirRecord, + IntrospectedClass, + IntrospectedInterface, + IntrospectedRecord, GirComplexRecord, - IntrospectedBaseClass as GirBaseClass + IntrospectedBaseClass } from "./class.js"; -export { IntrospectedConstant as GirConst } from "./const.js"; -export { IntrospectedEnum as GirEnum, IntrospectedError as GirError, GirEnumMember } from "./enum.js"; +export { IntrospectedConstant } from "./const.js"; +export { IntrospectedEnum, GirEnumMember } from "./enum.js"; export { - IntrospectedFunction as GirFunction, - IntrospectedClassFunction as GirClassFunction, - IntrospectedCallback as GirCallback, - IntrospectedConstructor as GirConstructor, - IntrospectedStaticClassFunction as GirStaticClassFunction, - IntrospectedVirtualClassFunction as GirVirtualClassFunction, - IntrospectedFunctionParameter as GirFunctionParameter, - IntrospectedDirectAllocationConstructor as GirDirectAllocationConstructor + IntrospectedFunction, + IntrospectedClassFunction, + IntrospectedCallback, + IntrospectedConstructor, + IntrospectedStaticClassFunction, + IntrospectedVirtualClassFunction, + IntrospectedFunctionParameter, + IntrospectedDirectAllocationConstructor as IntrospectedDirectAllocationConstructor } from "./function.js"; -export { IntrospectedNamespace as GirNamespace, GirNSMember } from "./namespace.js"; -export { NSRegistry as GirNSRegistry, NSLoader as GirNSLoader } from "./registry.js"; -export { Field as GirField, GirProperty } from "./property.js"; -export { IntrospectedSignal as GirSignal, IntrospectedSignalType as GirSignalType } from "./signal.js"; +export { IntrospectedNamespace, GirNSMember } from "./namespace.js"; +export { NSRegistry, NSLoader } from "./registry.js"; +export { IntrospectedField, IntrospectedProperty } from "./property.js"; +export { IntrospectedSignal, IntrospectedSignalType } from "./signal.js"; +export { + GenericType, + TypeExpression, + TypeIdentifier, + OrType, + NativeType, + TypeConflict, + AnyType, + ThisType, + TupleType, + GTypeType, + NeverType, + BinaryType, + NumberType, + ObjectType, + StringType, + ClosureType, + PromiseType, + UnknownType, + ConflictType +} from "../gir.js"; + export * as nodeUtils from "./util.js"; diff --git a/packages/lib/src/newlib/gir/property.ts b/packages/lib/src/newlib/gir/property.ts index be9909c9a..2d2738ef2 100644 --- a/packages/lib/src/newlib/gir/property.ts +++ b/packages/lib/src/newlib/gir/property.ts @@ -1,16 +1,16 @@ import { TypeExpression } from "../gir.js"; -import { IntrospectedBase, Options } from "./base.js"; +import { IntrospectedBase, IntrospectedClassMember, Options } from "./base.js"; import { GirFieldElement, GirPropertyElement } from "../../index.js"; import { getType, parseDoc, parseMetadata } from "./util.js"; -import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; +import { isIntrospectable } from "./namespace.js"; import { FormatGenerator } from "../generators/generator.js"; import { LoadOptions } from "../types.js"; import { GirVisitor } from "../visitor.js"; import { IntrospectedBaseClass } from "./class.js"; import { IntrospectedEnum } from "./enum.js"; -export class Field extends IntrospectedBase { +export class IntrospectedField extends IntrospectedClassMember { type: TypeExpression; // TODO: Make these properties readonly @@ -20,11 +20,12 @@ export class Field extends IntrospectedBase { writable: boolean; isNative: boolean = false; - copy(options?: { parent?: IntrospectedBase; type?: TypeExpression; isStatic?: boolean }): Field { - const { type, name, optional, computed, isStatic, writable } = this; + copy(options?: { parent?: IntrospectedBaseClass; type?: TypeExpression; isStatic?: boolean }): IntrospectedField { + const { type, name, parent, optional, computed, isStatic, writable } = this; - return new Field({ + return new IntrospectedField({ name, + parent, type: options?.type ?? type, optional, computed, @@ -35,6 +36,7 @@ export class Field extends IntrospectedBase { constructor({ name, + parent, type, computed = false, optional = false, @@ -43,13 +45,14 @@ export class Field extends IntrospectedBase { ...args }: Options<{ name: string; + parent?: IntrospectedBaseClass | null; type: TypeExpression; computed?: boolean; optional?: boolean; isStatic?: boolean; writable?: boolean; }>) { - super(name, { ...args }); + super(name, parent ?? null, { ...args }); this.type = type; this.computed = computed; @@ -62,7 +65,7 @@ export class Field extends IntrospectedBase { return generator.generateField(this) as ReturnType; } - accept(visitor: GirVisitor): Field { + accept(visitor: GirVisitor): IntrospectedField { const node = this.copy({ type: visitor.visitType?.(this.type) ?? this.type }); @@ -70,18 +73,14 @@ export class Field extends IntrospectedBase { return visitor.visitField?.(node) ?? node; } - static fromXML( - namespace: string, - ns: IntrospectedNamespace, - _options: LoadOptions, - _parent, - field: GirFieldElement - ): Field { + static fromXML(field: GirFieldElement, parent: IntrospectedBaseClass): IntrospectedField { + const namespace = parent.namespace; const name = field.$["name"]; const _name = name.replace(/[-]/g, "_"); - const f = new Field({ + const f = new IntrospectedField({ name: _name, - type: getType(namespace, ns, field), + parent, + type: getType(namespace, field), isPrivate: field.$.private === "1", isIntrospectable: isIntrospectable(field) }); @@ -90,27 +89,29 @@ export class Field extends IntrospectedBase { } } -export class JSField extends Field { +export class JSField extends IntrospectedField { isNative = true; } -export class GirProperty extends IntrospectedBase { +export class IntrospectedProperty extends IntrospectedBase { type: TypeExpression; readonly writable: boolean = false; readonly readable: boolean = true; readonly constructOnly: boolean; - parent: IntrospectedBaseClass | IntrospectedEnum; + get namespace() { + return this.parent.namespace; + } copy(options?: { name?: string; parent?: IntrospectedBaseClass | IntrospectedEnum; type?: TypeExpression; - }): GirProperty { + }): IntrospectedProperty { const { name, writable, readable, type, constructOnly, parent } = this; - return new GirProperty({ + return new IntrospectedProperty({ name: options?.name ?? name, writable, readable, @@ -120,7 +121,7 @@ export class GirProperty extends IntrospectedBase { })._copyBaseProperties(this); } - accept(visitor: GirVisitor): GirProperty { + accept(visitor: GirVisitor): IntrospectedProperty { const node = this.copy({ parent: this.parent, type: visitor.visitType?.(this.type) ?? this.type @@ -145,13 +146,12 @@ export class GirProperty extends IntrospectedBase { constructOnly: boolean; parent: IntrospectedBaseClass | IntrospectedEnum; }>) { - super(name, { ...args }); + super(name, parent, { ...args }); this.type = type; this.writable = writable; this.readable = readable; this.constructOnly = constructOnly; - this.parent = parent; } asString>(generator: T, construct?: boolean): ReturnType { @@ -177,27 +177,26 @@ export class GirProperty extends IntrospectedBase { } static fromXML( - namespace: string, - ns: IntrospectedNamespace, - options: LoadOptions, + element: GirPropertyElement, parent: IntrospectedBaseClass | IntrospectedEnum, - prop: GirPropertyElement - ): GirProperty { - const name = prop.$["name"]; + options: LoadOptions + ): IntrospectedProperty { + const ns = parent.namespace; + const name = element.$["name"]; const _name = name.replace(/[-]/g, "_"); - const property = new GirProperty({ + const property = new IntrospectedProperty({ name: _name, - writable: prop.$?.writable === "1", - readable: prop.$?.readable !== "0", - constructOnly: prop.$?.["construct-only"] === "1", - type: getType(namespace, ns, prop), + writable: element.$?.writable === "1", + readable: element.$?.readable !== "0", + constructOnly: element.$?.["construct-only"] === "1", + type: getType(ns, element), parent, - isIntrospectable: isIntrospectable(prop) + isIntrospectable: isIntrospectable(element) }); if (options.loadDocs) { - property.doc = parseDoc(prop); - property.metadata = parseMetadata(prop); + property.doc = parseDoc(element); + property.metadata = parseMetadata(element); } return property; diff --git a/packages/lib/src/newlib/gir/registry.ts b/packages/lib/src/newlib/gir/registry.ts index dec54b606..5bec9e897 100644 --- a/packages/lib/src/newlib/gir/registry.ts +++ b/packages/lib/src/newlib/gir/registry.ts @@ -15,6 +15,7 @@ import { IntrospectedNamespace } from "./namespace.js"; import { DtsModuleGenerator } from "../generators/dts-modules.js"; import { DtsInlineGenerator } from "../generators/dts-inline.js"; import { ParsedGir } from "../../types/parsed-gir.js"; +import { GenerateConfig } from "../../types/generate-config.js"; export interface NSLoader { load(namespace: string, version: string): ParsedGir | null; @@ -210,7 +211,7 @@ export class NSRegistry { } load(gir: ParsedGir, options: LoadOptions): IntrospectedNamespace { - const namespace = IntrospectedNamespace.fromXML(gir, options, this); + const namespace = IntrospectedNamespace.load(gir, options as LoadOptions & GenerateConfig, this); this.mapping.set(namespace.name, namespace.version, namespace); diff --git a/packages/lib/src/newlib/gir/signal.ts b/packages/lib/src/newlib/gir/signal.ts index 089e4708e..7210f89d2 100644 --- a/packages/lib/src/newlib/gir/signal.ts +++ b/packages/lib/src/newlib/gir/signal.ts @@ -8,10 +8,10 @@ import { NullableType, ArrayType } from "../gir.js"; -import { IntrospectedBase, Options } from "./base.js"; -import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; +import { IntrospectedClassMember, Options } from "./base.js"; +import { isIntrospectable } from "./namespace.js"; import { IntrospectedClass } from "./class.js"; -import { IntrospectedClassFunction, IntrospectedFunctionParameter, IntrospectedCallback } from "./function.js"; +import { IntrospectedClassFunction, IntrospectedFunctionParameter, IntrospectedClassCallback } from "./function.js"; import { GirSignalElement, GirDirection, GirCallableParamElement } from "@gi.ts/parser"; import { getType, parseDoc, parseMetadata } from "./util.js"; import { FormatGenerator } from "../generators/generator.js"; @@ -24,10 +24,9 @@ export enum IntrospectedSignalType { EMIT } -export class IntrospectedSignal extends IntrospectedBase { +export class IntrospectedSignal extends IntrospectedClassMember { parameters: IntrospectedFunctionParameter[]; return_type: TypeExpression; - parent: IntrospectedClass; constructor({ name, @@ -41,11 +40,10 @@ export class IntrospectedSignal extends IntrospectedBase { return_type?: TypeExpression; parent: IntrospectedClass; }>) { - super(name, { ...args }); + super(name, parent, { ...args }); this.parameters = parameters.map(p => p.copy({ parent: this })); this.return_type = return_type; - this.parent = parent; } accept(visitor: GirVisitor): IntrospectedSignal { @@ -76,24 +74,19 @@ export class IntrospectedSignal extends IntrospectedBase { })._copyBaseProperties(this); } - static fromXML( - modName: string, - ns: IntrospectedNamespace, - options: LoadOptions, - parent: IntrospectedClass, - sig: GirSignalElement - ): IntrospectedSignal { + static fromXML(element: GirSignalElement, parent: IntrospectedClass, options: LoadOptions): IntrospectedSignal { + const ns = parent.namespace; const signal = new IntrospectedSignal({ - name: sig.$.name, + name: element.$.name, parent, - isIntrospectable: isIntrospectable(sig) + isIntrospectable: isIntrospectable(element) }); - if (sig.parameters && sig.parameters[0].parameter) { + if (element.parameters && element.parameters[0].parameter) { signal.parameters.push( - ...sig.parameters[0].parameter + ...element.parameters[0].parameter .filter((p): p is GirCallableParamElement & { $: { name: string } } => !!p.$.name) - .map(p => IntrospectedFunctionParameter.fromXML(modName, ns, options, signal, p)) + .map(p => IntrospectedFunctionParameter.fromXML(p, signal, options)) ); } @@ -148,11 +141,11 @@ export class IntrospectedSignal extends IntrospectedBase { .params.reverse() .filter((p): p is IntrospectedFunctionParameter => p != null); - signal.return_type = getType(modName, ns, sig["return-value"]?.[0]); + signal.return_type = getType(ns, element["return-value"]?.[0]); if (options.loadDocs) { - signal.doc = parseDoc(sig); - signal.metadata = parseMetadata(sig); + signal.doc = parseDoc(element); + signal.metadata = parseMetadata(element); } return signal; @@ -192,12 +185,16 @@ export class IntrospectedSignal extends IntrospectedBase { const name = after ? "connect_after" : "connect"; const parent = this.parent; - const cb = new IntrospectedCallback({ - raw_name: "callback", + const cb = new IntrospectedClassCallback({ + parent, name: "callback", output_parameters: [], parameters: [ - new IntrospectedFunctionParameter({ name: "_source", type: ThisType, direction: GirDirection.In }), + new IntrospectedFunctionParameter({ + name: "_source", + type: ThisType, + direction: GirDirection.In + }), ...connect.parameters.map(p => p.copy()) ], return_type: connect.return_type @@ -222,7 +219,7 @@ export class IntrospectedSignal extends IntrospectedBase { return_type, parameters, name, - parent + parent: this.parent }); } diff --git a/packages/lib/src/newlib/gir/util.ts b/packages/lib/src/newlib/gir/util.ts index 996ed5851..04bcb0dee 100644 --- a/packages/lib/src/newlib/gir/util.ts +++ b/packages/lib/src/newlib/gir/util.ts @@ -141,10 +141,11 @@ function isPointerType(types: GirType[] | undefined) { /* Decode the type */ export function getType( - modName: string, - _ns: IntrospectedNamespace, + ns: IntrospectedNamespace, param?: GirConstantElement | GirCallableReturn | GirFieldElement ): TypeExpression { + const modName = ns.name; + if (!param) return VoidType; let name = ""; @@ -354,7 +355,9 @@ export function isInvalid(name: string): boolean { } export function parseDoc(element: GirDocElement): string | null { - return element.doc?.[0]?._ ?? null; + const el = element.doc?.[0]?._; + + return el ? `${el}` : null; } export function parseDeprecatedDoc(element: GirDocElement): string | null { diff --git a/packages/lib/src/newlib/injections/gio.ts b/packages/lib/src/newlib/injections/gio.ts index 72363c0fb..1530d8bc8 100644 --- a/packages/lib/src/newlib/injections/gio.ts +++ b/packages/lib/src/newlib/injections/gio.ts @@ -20,7 +20,7 @@ import { Generic } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; -import { Field, JSField } from "../gir/property.js"; +import { IntrospectedField, JSField } from "../gir/property.js"; import { IntrospectedClass, IntrospectedInterface } from "../gir/class.js"; export default { @@ -36,6 +36,7 @@ export default { DBusNodeInfo.constructors.push( new IntrospectedConstructor({ name: "new_for_xml", + parent: DBusNodeInfo, parameters: [ new IntrospectedFunctionParameter({ name: "info", @@ -54,6 +55,7 @@ export default { DBusInterfaceInfo.constructors.push( new IntrospectedConstructor({ name: "new_for_xml", + parent: DBusInterfaceInfo, parameters: [ new IntrospectedFunctionParameter({ name: "info", @@ -70,8 +72,9 @@ export default { const ListStore = namespace.assertClass("ListStore"); ListStore.fields.push( - new Field({ + new IntrospectedField({ name: "Symbol.iterator", + parent: ListStore, computed: true, type: new FunctionType( {}, @@ -87,6 +90,7 @@ export default { SettingsSchema.fields.push( new JSField({ name: "_realGetKey", + parent: SettingsSchema, type: new NativeType("typeof SettingsSchema.prototype.get_key") }) ); @@ -98,18 +102,22 @@ export default { Settings.fields.push( new JSField({ name: "_realInit", + parent: Settings, type: AnyFunctionType }), new JSField({ name: "_realMethods", + parent: Settings, type: new NativeType("typeof Settings.prototype") }), new JSField({ name: "_keys", + parent: Settings, type: new ArrayType(StringType) }), new JSField({ name: "_children", + parent: Settings, type: new ArrayType(StringType) }) ); @@ -286,12 +294,14 @@ export default { new JSField({ isStatic: true, name: "session", + parent: DBus, type: DBusConnection.getType(), writable: false }), new JSField({ isStatic: true, name: "system", + parent: DBus, type: DBusConnection.getType(), writable: false }) diff --git a/packages/lib/src/newlib/injections/glib.ts b/packages/lib/src/newlib/injections/glib.ts index 71da10eed..4d0c2bc1d 100644 --- a/packages/lib/src/newlib/injections/glib.ts +++ b/packages/lib/src/newlib/injections/glib.ts @@ -31,6 +31,7 @@ export default { new IntrospectedFunction({ name: "log_structured", raw_name: "log_structured", + namespace: namespace, parameters: [ new IntrospectedFunctionParameter({ name: "logDomain", @@ -59,6 +60,7 @@ export default { new IntrospectedFunction({ name: "strstrip", raw_name: "strstrip", + namespace: namespace, parameters: [ new IntrospectedFunctionParameter({ name: "str", @@ -132,6 +134,7 @@ export default { ]; const VariantConstructor = new IntrospectedConstructor({ name: "new", + parent: Variant, parameters: VariantParams.map(vp => vp.copy()), return_type: Variant.getType() }); @@ -144,6 +147,7 @@ export default { // static _new_internal: (sig: any, value: any) => any;, new IntrospectedConstructor({ name: "_new_internal", + parent: Variant, parameters: VariantParams.map(vp => vp.copy()), return_type: AnyType }) diff --git a/packages/lib/src/newlib/injections/gobject.ts b/packages/lib/src/newlib/injections/gobject.ts index a318af7f6..0e29e0b1e 100644 --- a/packages/lib/src/newlib/injections/gobject.ts +++ b/packages/lib/src/newlib/injections/gobject.ts @@ -25,7 +25,7 @@ import { GenerifiedTypeIdentifier } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; -import { Field } from "../gir/property.js"; +import { IntrospectedField } from "../gir/property.js"; import { IntrospectedAlias } from "../gir/alias.js"; import { IntrospectedInterface } from "../gir/class.js"; @@ -50,19 +50,19 @@ export default { name: "SignalMatch", namespace, fields: [ - new Field({ + new IntrospectedField({ name: "signalId", type: StringType, isStatic: false, writable: true }), - new Field({ + new IntrospectedField({ name: "detail", type: StringType, isStatic: false, writable: true }), - new Field({ + new IntrospectedField({ name: "func", type: AnyFunctionType, isStatic: false, @@ -78,6 +78,7 @@ export default { const GType = new IntrospectedAlias({ name: "GType", + namespace, type: new NativeType("any") }); namespace.members.set("GType", GType); @@ -132,7 +133,7 @@ export default { } ParamSpec.fields.push( - new Field({ + new IntrospectedField({ name: "override", isStatic: true, type: AnyType, @@ -254,6 +255,7 @@ export default { "Closure", new IntrospectedAlias({ name: "Closure", + namespace, type: NativeType.of("(...args: P[]) => R"), generics: [ { @@ -394,6 +396,7 @@ export default { "signal_handlers_block_by_func", new IntrospectedFunction({ name: "signal_handlers_block_by_func", + namespace, raw_name: "signal_handlers_block_by_func", parameters: [ new IntrospectedFunctionParameter({ @@ -417,6 +420,7 @@ export default { "signal_handlers_unblock_by_func", new IntrospectedFunction({ name: "signal_handlers_unblock_by_func", + namespace, raw_name: "signal_handlers_unblock_by_func", parameters: [ new IntrospectedFunctionParameter({ @@ -440,6 +444,7 @@ export default { "signal_handlers_disconnect_by_func", new IntrospectedFunction({ name: "signal_handlers_disconnect_by_func", + namespace, raw_name: "signal_handlers_disconnect_by_func", parameters: [ new IntrospectedFunctionParameter({ @@ -533,6 +538,7 @@ export default { function originalFunc(name: string) { return new IntrospectedFunction({ name, + namespace, raw_name: name, return_type: NumberType, parameters: originalArgs.map(a => a.copy()) @@ -545,6 +551,7 @@ export default { // [name](...args: [Object, SignalMatch] | [Object, SignalMatchType, number, GLib.Quark, Closure | null, object | null, object | null]): number; new IntrospectedFunction({ name, + namespace, raw_name: name, return_type: NumberType, parameters: [args] @@ -552,6 +559,7 @@ export default { // export function [name](instance: Object, match: SignalMatch): number; new IntrospectedFunction({ name, + namespace, raw_name: name, return_type: NumberType, parameters: modifiedArgs.map(a => a.copy()) diff --git a/packages/lib/src/newlib/lib.ts b/packages/lib/src/newlib/lib.ts index 54969e80e..d51d9b94b 100644 --- a/packages/lib/src/newlib/lib.ts +++ b/packages/lib/src/newlib/lib.ts @@ -38,11 +38,13 @@ export async function generateModule( ): Promise { const ns = registry.namespace(name, version); + const format = "dts"; // TODO: options.format; + if (ns) { - const Generator = await registry.getGenerator(options.format); + const Generator = await registry.getGenerator(format); if (!Generator) { - throw new Error(`Invalid output format selected: ${options.format}.`); + throw new Error(`Invalid output format selected: ${format}.`); } const generator = new Generator(ns, options); @@ -70,8 +72,8 @@ export async function generateModule( imports: Object.fromEntries(ns.getImports()) }; - const formatter = registry.getFormatter(options.format); - const formatted = !options.noPrettyPrint ? formatter.format(generated) : generated; + const formatter = registry.getFormatter(format); + const formatted = !options.noPrettyPrint ? await formatter.format(generated) : generated; return { formattedOutput: formatted, diff --git a/packages/lib/src/newlib/types.ts b/packages/lib/src/newlib/types.ts index 31b683593..f9d9dbf4c 100644 --- a/packages/lib/src/newlib/types.ts +++ b/packages/lib/src/newlib/types.ts @@ -1,7 +1,10 @@ +import { GenerateConfig } from "../types"; + export type PropertyCase = "both" | "camel" | "underscore"; export type Format = "dts" | "json"; export interface Options { + environment: "gjs"; verbose: boolean; } @@ -16,28 +19,28 @@ export interface TransformOptions extends Options { export type OutputFormat = "file" | "folder"; -export interface GenerationOptions extends Options { - [key: string]: boolean | string | number | undefined; - outputFormat?: string; - outputPath?: string; - promisify: boolean; - withDocs: boolean; - format: string; - versionedOutput: boolean; - versionedImports: boolean; - /** - * A format for versioned imports - * - * @example - * "{namespace}{version}{version-slug}" - */ - versionFormat?: string; - importPrefix: string; - emitMetadata: boolean; - noAdvancedVariants: boolean; - noPrettyPrint: boolean; - noInitTypes: boolean; -} +export type GenerationOptions = GenerateConfig; +// [key: string]: boolean | string | number | undefined; +// outputFormat?: string; +// outputPath?: string; +// promisify: boolean; +// withDocs: boolean; +// format: string; +// versionedOutput: boolean; +// versionedImports: boolean; +// /** +// * A format for versioned imports +// * +// * @example +// * "{namespace}{version}{version-slug}" +// */ +// versionFormat?: string; +// importPrefix: string; +// emitMetadata: boolean; +// noAdvancedVariants: boolean; +// noPrettyPrint: boolean; +// noInitTypes: boolean; +// } export interface Metadata { name: string; diff --git a/packages/lib/src/newlib/validators/class.ts b/packages/lib/src/newlib/validators/class.ts index d5ccae0d4..9c735c318 100644 --- a/packages/lib/src/newlib/validators/class.ts +++ b/packages/lib/src/newlib/validators/class.ts @@ -60,10 +60,10 @@ const filterConflictingNamedClassMembers = (nod * @returns */ const fixParamSpecSubtypes = (node: T): T => { - if (node.parent?.namespace === "GObject" && node.parent.name.startsWith("ParamSpec")) { + if (node.superType?.namespace === "GObject" && node.superType.name.startsWith("ParamSpec")) { // We don't assert this import because we don't want to force libraries // to unnecessarily import GObject. - node.parent = new TypeIdentifier("ParamSpec", "GObject"); + node.superType = new TypeIdentifier("ParamSpec", "GObject"); node.noEmit(); } @@ -82,11 +82,11 @@ const fixParamSpecSubtypes = (node: T): T => { const fixMissingParent = (node: T): T => { const { namespace } = node; - if (node.parent == null) { + if (node.superType == null) { const isGObject = node.someParent(p => p.getType().is("GObject", "Object")); if (isGObject) { - node.parent = namespace.assertInstalledImport("GObject").assertClass("Object").getType(); + node.superType = namespace.assertInstalledImport("GObject").assertClass("Object").getType(); } } @@ -170,7 +170,7 @@ const resolveMainConstructor = (node: IntrospectedRecord): IntrospectedRecord => } if (zeroArgsConstructor || node.isSimpleWithoutPointers()) { - node.mainConstructor = new IntrospectedDirectAllocationConstructor(node.fields); + node.mainConstructor = IntrospectedDirectAllocationConstructor.fromFields(node.fields, node); return node; } @@ -181,7 +181,7 @@ const resolveMainConstructor = (node: IntrospectedRecord): IntrospectedRecord => } if (node.isSimple()) { - node.mainConstructor = new IntrospectedDirectAllocationConstructor(node.fields); + node.mainConstructor = IntrospectedDirectAllocationConstructor.fromFields(node.fields, node); return node; } diff --git a/packages/lib/src/newlib/validators/interface.ts b/packages/lib/src/newlib/validators/interface.ts index c4dddce76..d946773df 100644 --- a/packages/lib/src/newlib/validators/interface.ts +++ b/packages/lib/src/newlib/validators/interface.ts @@ -4,7 +4,7 @@ import { GirVisitor } from "../visitor.js"; export class InterfaceVisitor extends GirVisitor { visitInterface = (node: IntrospectedInterface): IntrospectedInterface => { // If an interface does not list a prerequisite type, we fill it with GObject.Object - if (!node.noParent && node.parent == null) { + if (!node.noParent && node.superType == null) { const gobject = node.namespace.assertInstalledImport("GObject"); const GObject = gobject.assertClass("Object"); @@ -14,7 +14,7 @@ export class InterfaceVisitor extends GirVisitor { ); } - node.parent = GObject.getType(); + node.superType = GObject.getType(); } return node; diff --git a/packages/lib/src/newlib/visitor.ts b/packages/lib/src/newlib/visitor.ts index 9a44ba2ad..f9c4b0987 100644 --- a/packages/lib/src/newlib/visitor.ts +++ b/packages/lib/src/newlib/visitor.ts @@ -11,15 +11,17 @@ import { IntrospectedClassFunction, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction, - IntrospectedDirectAllocationConstructor + IntrospectedDirectAllocationConstructor, + IntrospectedClassCallback } from "./gir/function.js"; import { IntrospectedNamespace } from "./gir/namespace.js"; -import { GirProperty, Field } from "./gir/property.js"; +import { IntrospectedProperty, IntrospectedField } from "./gir/property.js"; import { IntrospectedSignal, IntrospectedSignalType } from "./gir/signal.js"; export abstract class GirVisitor { visitType?: (node: TypeExpression) => TypeExpression; visitCallback?: (node: IntrospectedCallback) => IntrospectedCallback; + visitClassCallback?: (node: IntrospectedClassCallback) => IntrospectedClassCallback; visitAlias?: (node: IntrospectedAlias) => IntrospectedAlias; visitConstructor?: (node: IntrospectedConstructor) => IntrospectedConstructor; visitDirectAllocationConstructor?: ( @@ -34,8 +36,8 @@ export abstract class GirVisitor { visitConst?: (node: IntrospectedConstant) => IntrospectedConstant; visitClass?: (node: IntrospectedClass) => IntrospectedClass; visitParameter?: (node: IntrospectedFunctionParameter) => IntrospectedFunctionParameter; - visitProperty?: (node: GirProperty) => GirProperty; - visitField?: (node: Field) => Field; + visitProperty?: (node: IntrospectedProperty) => IntrospectedProperty; + visitField?: (node: IntrospectedField) => IntrospectedField; visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal; visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction; visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction; diff --git a/packages/lib/src/types/generate-config.ts b/packages/lib/src/types/generate-config.ts index b9809a99c..7227bd9e1 100644 --- a/packages/lib/src/types/generate-config.ts +++ b/packages/lib/src/types/generate-config.ts @@ -39,4 +39,8 @@ export interface GenerateConfig { package: boolean /** Adds Yarn workspace support to the NPM packages */ packageYarn: boolean + /** Disable pretty printing the output */ + noPrettyPrint: boolean + /** Disable GLib.Variant class with string parsing */ + noAdvancedVariants: boolean } diff --git a/packages/lib/src/types/index.ts b/packages/lib/src/types/index.ts index 907c7393a..4757266dd 100644 --- a/packages/lib/src/types/index.ts +++ b/packages/lib/src/types/index.ts @@ -125,3 +125,4 @@ export * from './type-ts-function.js' export * from './type-ts-property.js' export * from './user-config-load-result.js' export * from './user-config.js' +export * from '../newlib/gir.js' From df568caa953242754541b008b237eec01d1ecc34 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sat, 10 Feb 2024 15:51:25 -0800 Subject: [PATCH 12/53] Merge 'newlib' sources with lib This merges the sources from @gi.ts/lib (newlib) into the lib package. --- packages/cli/src/commands/generate.ts | 2 +- .../src/type-definition-generator.ts | 20 +- packages/lib/.eslintrc.cjs | 40 +- packages/lib/.prettierrc.json | 10 +- packages/lib/README.md | 1 - packages/lib/package.json | 130 ++--- packages/lib/src/dependency-manager.ts | 2 +- packages/lib/src/formatters/.eslintrc.cjs | 26 + .../{newlib => formatters}/.prettierrc.json | 3 +- .../src/{newlib => }/formatters/default.ts | 0 .../src/{newlib => }/formatters/formatter.ts | 0 .../lib/src/{newlib => }/formatters/json.ts | 0 packages/lib/src/generators/.eslintrc.cjs | 26 + packages/lib/src/generators/.prettierrc.json | 8 + .../src/{newlib => }/generators/dts-inline.ts | 0 .../{newlib => }/generators/dts-modules.ts | 0 .../lib/src/{newlib => }/generators/dts.ts | 2 +- .../src/{newlib => }/generators/dts/gio.ts | 0 .../src/{newlib => }/generators/dts/glib.ts | 0 .../{newlib => }/generators/dts/gobject.ts | 0 .../src/{newlib => }/generators/generator.ts | 2 +- .../lib/src/{newlib => }/generators/index.ts | 0 .../lib/src/{newlib => }/generators/json.ts | 0 packages/lib/src/generics/.eslintrc.cjs | 26 + packages/lib/src/generics/.prettierrc.json | 8 + .../lib/src/{newlib => }/generics/clutter.ts | 0 .../lib/src/{newlib => }/generics/generify.ts | 0 packages/lib/src/{newlib => }/generics/gio.ts | 0 .../lib/src/{newlib => }/generics/glib.ts | 0 .../lib/src/{newlib => }/generics/meta.ts | 0 packages/lib/src/{newlib => }/generics/st.ts | 0 .../lib/src/{newlib => }/generics/visitor.ts | 0 packages/lib/src/gir-module.ts | 31 +- packages/lib/src/{newlib => }/gir.ts | 506 +++++++++--------- packages/lib/src/gir/.eslintrc.cjs | 26 + packages/lib/src/gir/.prettierrc.json | 8 + packages/lib/src/{newlib => }/gir/alias.ts | 2 +- packages/lib/src/{newlib => }/gir/base.ts | 0 packages/lib/src/{newlib => }/gir/class.ts | 2 +- packages/lib/src/{newlib => }/gir/const.ts | 2 +- packages/lib/src/{newlib => }/gir/enum.ts | 2 +- packages/lib/src/{newlib => }/gir/function.ts | 2 +- packages/lib/src/{newlib => }/gir/generics.ts | 0 .../lib/src/{newlib => }/gir/namespace.ts | 4 +- packages/lib/src/{newlib => }/gir/nodes.ts | 3 +- packages/lib/src/{newlib => }/gir/property.ts | 2 +- packages/lib/src/{newlib => }/gir/registry.ts | 4 +- packages/lib/src/{newlib => }/gir/signal.ts | 0 packages/lib/src/{newlib => }/gir/util.ts | 0 packages/lib/src/index.ts | 2 + packages/lib/src/injections/.eslintrc.cjs | 26 + packages/lib/src/injections/.prettierrc.json | 8 + .../lib/src/{newlib => }/injections/gio.ts | 0 .../lib/src/{newlib => }/injections/glib.ts | 0 .../src/{newlib => }/injections/gobject.ts | 0 .../lib/src/{newlib => }/injections/inject.ts | 0 packages/lib/src/newlib/.eslintrc.cjs | 26 - packages/lib/src/newlib/lib.ts | 85 --- packages/lib/src/newlib/util.ts | 84 --- packages/lib/src/registry.ts | 85 +++ packages/lib/src/{newlib => }/types.ts | 28 +- packages/lib/src/types/index.ts | 1 - packages/lib/src/util.ts | 84 +++ packages/lib/src/validators/.eslintrc.cjs | 26 + packages/lib/src/validators/.prettierrc.json | 8 + .../lib/src/{newlib => }/validators/class.ts | 0 .../src/{newlib => }/validators/interface.ts | 0 packages/lib/src/{newlib => }/visitor.ts | 70 +-- packages/lib/tsconfig.json | 45 +- 69 files changed, 822 insertions(+), 656 deletions(-) create mode 100644 packages/lib/src/formatters/.eslintrc.cjs rename packages/lib/src/{newlib => formatters}/.prettierrc.json (96%) rename packages/lib/src/{newlib => }/formatters/default.ts (100%) rename packages/lib/src/{newlib => }/formatters/formatter.ts (100%) rename packages/lib/src/{newlib => }/formatters/json.ts (100%) create mode 100644 packages/lib/src/generators/.eslintrc.cjs create mode 100644 packages/lib/src/generators/.prettierrc.json rename packages/lib/src/{newlib => }/generators/dts-inline.ts (100%) rename packages/lib/src/{newlib => }/generators/dts-modules.ts (100%) rename packages/lib/src/{newlib => }/generators/dts.ts (99%) rename packages/lib/src/{newlib => }/generators/dts/gio.ts (100%) rename packages/lib/src/{newlib => }/generators/dts/glib.ts (100%) rename packages/lib/src/{newlib => }/generators/dts/gobject.ts (100%) rename packages/lib/src/{newlib => }/generators/generator.ts (97%) rename packages/lib/src/{newlib => }/generators/index.ts (100%) rename packages/lib/src/{newlib => }/generators/json.ts (100%) create mode 100644 packages/lib/src/generics/.eslintrc.cjs create mode 100644 packages/lib/src/generics/.prettierrc.json rename packages/lib/src/{newlib => }/generics/clutter.ts (100%) rename packages/lib/src/{newlib => }/generics/generify.ts (100%) rename packages/lib/src/{newlib => }/generics/gio.ts (100%) rename packages/lib/src/{newlib => }/generics/glib.ts (100%) rename packages/lib/src/{newlib => }/generics/meta.ts (100%) rename packages/lib/src/{newlib => }/generics/st.ts (100%) rename packages/lib/src/{newlib => }/generics/visitor.ts (100%) rename packages/lib/src/{newlib => }/gir.ts (59%) create mode 100644 packages/lib/src/gir/.eslintrc.cjs create mode 100644 packages/lib/src/gir/.prettierrc.json rename packages/lib/src/{newlib => }/gir/alias.ts (97%) rename packages/lib/src/{newlib => }/gir/base.ts (100%) rename packages/lib/src/{newlib => }/gir/class.ts (99%) rename packages/lib/src/{newlib => }/gir/const.ts (97%) rename packages/lib/src/{newlib => }/gir/enum.ts (99%) rename packages/lib/src/{newlib => }/gir/function.ts (99%) rename packages/lib/src/{newlib => }/gir/generics.ts (100%) rename packages/lib/src/{newlib => }/gir/namespace.ts (96%) rename packages/lib/src/{newlib => }/gir/nodes.ts (90%) rename packages/lib/src/{newlib => }/gir/property.ts (98%) rename packages/lib/src/{newlib => }/gir/registry.ts (98%) rename packages/lib/src/{newlib => }/gir/signal.ts (100%) rename packages/lib/src/{newlib => }/gir/util.ts (100%) create mode 100644 packages/lib/src/injections/.eslintrc.cjs create mode 100644 packages/lib/src/injections/.prettierrc.json rename packages/lib/src/{newlib => }/injections/gio.ts (100%) rename packages/lib/src/{newlib => }/injections/glib.ts (100%) rename packages/lib/src/{newlib => }/injections/gobject.ts (100%) rename packages/lib/src/{newlib => }/injections/inject.ts (100%) delete mode 100644 packages/lib/src/newlib/.eslintrc.cjs delete mode 100644 packages/lib/src/newlib/lib.ts delete mode 100644 packages/lib/src/newlib/util.ts create mode 100644 packages/lib/src/registry.ts rename packages/lib/src/{newlib => }/types.ts (61%) create mode 100644 packages/lib/src/util.ts create mode 100644 packages/lib/src/validators/.eslintrc.cjs create mode 100644 packages/lib/src/validators/.prettierrc.json rename packages/lib/src/{newlib => }/validators/class.ts (100%) rename packages/lib/src/{newlib => }/validators/interface.ts (100%) rename packages/lib/src/{newlib => }/visitor.ts (52%) diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index 10a8aa2de..0930e9627 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -11,7 +11,7 @@ import { ModuleLoader } from '../module-loader.js' import prettier from 'prettier' import type { ConfigFlags } from '@ts-for-gir/lib' -import { Formatter } from '@ts-for-gir/lib/lib/newlib/lib.js' +import { Formatter } from '@ts-for-gir/lib' const command = 'generate [modules..]' diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 764663e09..cf9893483 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -35,8 +35,6 @@ import { IntrospectedSignal, IntrospectedProperty, IntrospectedConstant, -} from '@ts-for-gir/lib' -import { IntrospectedClassCallback, IntrospectedClassFunction, IntrospectedConstructor, @@ -44,19 +42,17 @@ import { IntrospectedFunctionParameter, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction, -} from '@ts-for-gir/lib/lib/newlib/gir/function.js' -import { IntrospectedNamespaceMember } from '@ts-for-gir/lib/lib/newlib/gir/base.js' -import { - FormatGenerator, - Generic, - GirEnumMember, + IntrospectedNamespaceMember, IntrospectedAlias, IntrospectedEnum, IntrospectedSignalType, + IntrospectedEnumMember, + IntrospectedError, + FormatGenerator, + Generic, NativeType, -} from '@ts-for-gir/lib/lib/newlib/lib.js' -import { IntrospectedError } from '@ts-for-gir/lib/lib/newlib/gir/enum.js' -import { isInvalid } from '@ts-for-gir/lib/lib/newlib/gir/util.js' + isInvalid, +} from '@ts-for-gir/lib' function printGirDocComment(tsDoc: TsDoc, config: GenerateConfig) { const desc: string[] = [] @@ -800,7 +796,7 @@ class ModuleGenerator extends FormatGenerator { return desc } - generateEnumMember(tsMember: GirEnumMember, indentCount = 1) { + generateEnumMember(tsMember: IntrospectedEnumMember, indentCount = 1) { const desc: string[] = [] desc.push(...this.addGirDocComment(tsMember.doc, [], indentCount)) diff --git a/packages/lib/.eslintrc.cjs b/packages/lib/.eslintrc.cjs index 481d43eaa..5705ed112 100644 --- a/packages/lib/.eslintrc.cjs +++ b/packages/lib/.eslintrc.cjs @@ -1,25 +1,25 @@ module.exports = { - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"], - "extends": [ - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "prettier" + root: true, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: [ + 'plugin:prettier/recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'prettier', ], - "rules": { - "semi": ["error", "never"], - "no-debugger": "off", - "@typescript-eslint/triple-slash-reference": "off", - "camelcase": "off", - "@typescript-eslint/camelcase": "off" + rules: { + semi: ['error', 'never'], + 'no-debugger': 'off', + '@typescript-eslint/triple-slash-reference': 'off', + camelcase: 'off', + '@typescript-eslint/camelcase': 'off', }, - "parserOptions": { - "tsconfigRootDir": __dirname, - "project": ["./tsconfig.json"] + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + }, + globals: { + imports: true, }, - "globals": { - "imports": true - } } diff --git a/packages/lib/.prettierrc.json b/packages/lib/.prettierrc.json index 4effe30b4..ad45a741b 100644 --- a/packages/lib/.prettierrc.json +++ b/packages/lib/.prettierrc.json @@ -1,7 +1,7 @@ { - "semi": false, - "trailingComma": "all", - "singleQuote": true, - "printWidth": 120, - "tabWidth": 4 + "semi": false, + "trailingComma": "all", + "singleQuote": true, + "printWidth": 120, + "tabWidth": 4 } diff --git a/packages/lib/README.md b/packages/lib/README.md index d5dad39bf..ffdd45ae4 100644 --- a/packages/lib/README.md +++ b/packages/lib/README.md @@ -19,4 +19,3 @@ # Library Node.js library to generate Typescript Type Definition files for Gjs and node-gtk. - diff --git a/packages/lib/package.json b/packages/lib/package.json index 4d4cfb144..b8b5a6aa7 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,67 +1,67 @@ { - "name": "@ts-for-gir/lib", - "version": "3.2.3", - "description": "Typescript .d.ts generator from GIR for gjs", - "module": "lib/index.js", - "main": "lib/index.js", - "type": "module", - "engines": { - "node": ">=18" - }, - "scripts": { - "build": "yarn lint && yarn build:ts", - "build:ts": "tsc", - "clear": "yarn clear:build", - "clear:build": "rimraf ./lib", - "watch": "yarn build:ts --watch", - "lint": "eslint . --ext .ts,.tsx --fix", - "update-package-descriptions": "wget https://raw.githubusercontent.com/vala-lang/valadoc-org/master/documentation/packages.xml" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/gjsify/ts-for-gir.git" - }, - "author": "Pascal Garber ", - "files": [ - "lib" - ], - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/gjsify/ts-for-gir/issues" - }, - "homepage": "https://github.com/gjsify/ts-for-gir#readme", - "keywords": [ - "gjs", - "typescript", - "generate", - "gir", - "gobject-introspection", - "gnome", - "gtk", - "glib", - "gobject", - "dts", - "type definitions" - ], - "devDependencies": { - "@types/ejs": "^3.1.5", - "@types/eslint": "8.56.2", - "@types/lodash": "^4.14.202", - "@types/node": "^20.11.18", - "@types/xml2js": "^0.4.14", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.1.3", - "prettier": "^3.2.5", - "rimraf": "^5.0.5", - "typescript": "5.2.2" - }, - "dependencies": { - "colorette": "^2.0.20", - "ejs": "^3.1.9", - "lodash": "^4.17.21", - "xml2js": "0.6.2" - } + "name": "@ts-for-gir/lib", + "version": "3.2.3", + "description": "Typescript .d.ts generator from GIR for gjs", + "module": "lib/index.js", + "main": "lib/index.js", + "type": "module", + "engines": { + "node": ">=18" + }, + "scripts": { + "build": "yarn lint && yarn build:ts", + "build:ts": "tsc", + "clear": "yarn clear:build", + "clear:build": "rimraf ./lib", + "watch": "yarn build:ts --watch", + "lint": "eslint . --ext .ts,.tsx --fix", + "update-package-descriptions": "wget https://raw.githubusercontent.com/vala-lang/valadoc-org/master/documentation/packages.xml" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/gjsify/ts-for-gir.git" + }, + "author": "Pascal Garber ", + "files": [ + "lib" + ], + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/gjsify/ts-for-gir/issues" + }, + "homepage": "https://github.com/gjsify/ts-for-gir#readme", + "keywords": [ + "gjs", + "typescript", + "generate", + "gir", + "gobject-introspection", + "gnome", + "gtk", + "glib", + "gobject", + "dts", + "type definitions" + ], + "devDependencies": { + "@types/ejs": "^3.1.5", + "@types/eslint": "8.56.2", + "@types/lodash": "^4.14.202", + "@types/node": "^20.11.18", + "@types/xml2js": "^0.4.14", + "@typescript-eslint/eslint-plugin": "^7.0.1", + "@typescript-eslint/parser": "^7.0.1", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "prettier": "^3.2.5", + "rimraf": "^5.0.5", + "typescript": "5.2.2" + }, + "dependencies": { + "colorette": "^2.0.20", + "ejs": "^3.1.9", + "lodash": "^4.17.21", + "xml2js": "0.6.2" + } } diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index 9b4593c14..5168ae221 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -4,7 +4,7 @@ import { Transformation } from './transformation.js' import type { Dependency, GenerateConfig, GirInclude } from './types/index.js' import type { GirModule } from './gir-module.js' -import { GirNSRegistry } from './newlib/lib.js' +import { GirNSRegistry } from './registry.js' export class DependencyManager { protected log: Logger diff --git a/packages/lib/src/formatters/.eslintrc.cjs b/packages/lib/src/formatters/.eslintrc.cjs new file mode 100644 index 000000000..25ee0da0e --- /dev/null +++ b/packages/lib/src/formatters/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + rules: { + semi: ["error", "always"], + quotes: ["error", "double", { avoidEscape: true }], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + camelcase: "off", + "@typescript-eslint/camelcase": "off" + }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ["../../tsconfig.json"] + }, + globals: { + imports: true + } +}; diff --git a/packages/lib/src/newlib/.prettierrc.json b/packages/lib/src/formatters/.prettierrc.json similarity index 96% rename from packages/lib/src/newlib/.prettierrc.json rename to packages/lib/src/formatters/.prettierrc.json index cec7730e5..71bd46baf 100644 --- a/packages/lib/src/newlib/.prettierrc.json +++ b/packages/lib/src/formatters/.prettierrc.json @@ -5,5 +5,4 @@ "singleQuote": false, "printWidth": 120, "tabWidth": 4 - } - \ No newline at end of file +} diff --git a/packages/lib/src/newlib/formatters/default.ts b/packages/lib/src/formatters/default.ts similarity index 100% rename from packages/lib/src/newlib/formatters/default.ts rename to packages/lib/src/formatters/default.ts diff --git a/packages/lib/src/newlib/formatters/formatter.ts b/packages/lib/src/formatters/formatter.ts similarity index 100% rename from packages/lib/src/newlib/formatters/formatter.ts rename to packages/lib/src/formatters/formatter.ts diff --git a/packages/lib/src/newlib/formatters/json.ts b/packages/lib/src/formatters/json.ts similarity index 100% rename from packages/lib/src/newlib/formatters/json.ts rename to packages/lib/src/formatters/json.ts diff --git a/packages/lib/src/generators/.eslintrc.cjs b/packages/lib/src/generators/.eslintrc.cjs new file mode 100644 index 000000000..25ee0da0e --- /dev/null +++ b/packages/lib/src/generators/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + rules: { + semi: ["error", "always"], + quotes: ["error", "double", { avoidEscape: true }], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + camelcase: "off", + "@typescript-eslint/camelcase": "off" + }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ["../../tsconfig.json"] + }, + globals: { + imports: true + } +}; diff --git a/packages/lib/src/generators/.prettierrc.json b/packages/lib/src/generators/.prettierrc.json new file mode 100644 index 000000000..71bd46baf --- /dev/null +++ b/packages/lib/src/generators/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "none", + "arrowParens": "avoid", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 +} diff --git a/packages/lib/src/newlib/generators/dts-inline.ts b/packages/lib/src/generators/dts-inline.ts similarity index 100% rename from packages/lib/src/newlib/generators/dts-inline.ts rename to packages/lib/src/generators/dts-inline.ts diff --git a/packages/lib/src/newlib/generators/dts-modules.ts b/packages/lib/src/generators/dts-modules.ts similarity index 100% rename from packages/lib/src/newlib/generators/dts-modules.ts rename to packages/lib/src/generators/dts-modules.ts diff --git a/packages/lib/src/newlib/generators/dts.ts b/packages/lib/src/generators/dts.ts similarity index 99% rename from packages/lib/src/newlib/generators/dts.ts rename to packages/lib/src/generators/dts.ts index 37cb366d8..c6777c283 100644 --- a/packages/lib/src/newlib/generators/dts.ts +++ b/packages/lib/src/generators/dts.ts @@ -46,7 +46,7 @@ import { import { GirDirection } from "@gi.ts/parser"; import { IntrospectedAlias } from "../gir/alias.js"; import { AnyIntrospectedType } from "../gir/base.js"; -import { GenerateConfig } from "../../types/generate-config.js"; +import { GenerateConfig } from "../types/generate-config.js"; export function versionImportFormat(versionFormat: string, namespace: string, version: string) { const versionSlug = version.toLowerCase().split(".")[0]; diff --git a/packages/lib/src/newlib/generators/dts/gio.ts b/packages/lib/src/generators/dts/gio.ts similarity index 100% rename from packages/lib/src/newlib/generators/dts/gio.ts rename to packages/lib/src/generators/dts/gio.ts diff --git a/packages/lib/src/newlib/generators/dts/glib.ts b/packages/lib/src/generators/dts/glib.ts similarity index 100% rename from packages/lib/src/newlib/generators/dts/glib.ts rename to packages/lib/src/generators/dts/glib.ts diff --git a/packages/lib/src/newlib/generators/dts/gobject.ts b/packages/lib/src/generators/dts/gobject.ts similarity index 100% rename from packages/lib/src/newlib/generators/dts/gobject.ts rename to packages/lib/src/generators/dts/gobject.ts diff --git a/packages/lib/src/newlib/generators/generator.ts b/packages/lib/src/generators/generator.ts similarity index 97% rename from packages/lib/src/newlib/generators/generator.ts rename to packages/lib/src/generators/generator.ts index 485b5763f..22ec63c25 100644 --- a/packages/lib/src/newlib/generators/generator.ts +++ b/packages/lib/src/generators/generator.ts @@ -17,7 +17,7 @@ import { IntrospectedStaticClassFunction } from "../gir/function.js"; import { IntrospectedVirtualClassFunction } from "../gir/function.js"; import { IntrospectedAlias } from "../gir/alias.js"; import { TypeExpression } from "../gir.js"; -import { GenerateConfig } from "../../types/generate-config.js"; +import { GenerateConfig } from "../types/generate-config.js"; export interface GenericDescriptor { type: TypeExpression; diff --git a/packages/lib/src/newlib/generators/index.ts b/packages/lib/src/generators/index.ts similarity index 100% rename from packages/lib/src/newlib/generators/index.ts rename to packages/lib/src/generators/index.ts diff --git a/packages/lib/src/newlib/generators/json.ts b/packages/lib/src/generators/json.ts similarity index 100% rename from packages/lib/src/newlib/generators/json.ts rename to packages/lib/src/generators/json.ts diff --git a/packages/lib/src/generics/.eslintrc.cjs b/packages/lib/src/generics/.eslintrc.cjs new file mode 100644 index 000000000..25ee0da0e --- /dev/null +++ b/packages/lib/src/generics/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + rules: { + semi: ["error", "always"], + quotes: ["error", "double", { avoidEscape: true }], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + camelcase: "off", + "@typescript-eslint/camelcase": "off" + }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ["../../tsconfig.json"] + }, + globals: { + imports: true + } +}; diff --git a/packages/lib/src/generics/.prettierrc.json b/packages/lib/src/generics/.prettierrc.json new file mode 100644 index 000000000..71bd46baf --- /dev/null +++ b/packages/lib/src/generics/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "none", + "arrowParens": "avoid", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 +} diff --git a/packages/lib/src/newlib/generics/clutter.ts b/packages/lib/src/generics/clutter.ts similarity index 100% rename from packages/lib/src/newlib/generics/clutter.ts rename to packages/lib/src/generics/clutter.ts diff --git a/packages/lib/src/newlib/generics/generify.ts b/packages/lib/src/generics/generify.ts similarity index 100% rename from packages/lib/src/newlib/generics/generify.ts rename to packages/lib/src/generics/generify.ts diff --git a/packages/lib/src/newlib/generics/gio.ts b/packages/lib/src/generics/gio.ts similarity index 100% rename from packages/lib/src/newlib/generics/gio.ts rename to packages/lib/src/generics/gio.ts diff --git a/packages/lib/src/newlib/generics/glib.ts b/packages/lib/src/generics/glib.ts similarity index 100% rename from packages/lib/src/newlib/generics/glib.ts rename to packages/lib/src/generics/glib.ts diff --git a/packages/lib/src/newlib/generics/meta.ts b/packages/lib/src/generics/meta.ts similarity index 100% rename from packages/lib/src/newlib/generics/meta.ts rename to packages/lib/src/generics/meta.ts diff --git a/packages/lib/src/newlib/generics/st.ts b/packages/lib/src/generics/st.ts similarity index 100% rename from packages/lib/src/newlib/generics/st.ts rename to packages/lib/src/generics/st.ts diff --git a/packages/lib/src/newlib/generics/visitor.ts b/packages/lib/src/generics/visitor.ts similarity index 100% rename from packages/lib/src/newlib/generics/visitor.ts rename to packages/lib/src/generics/visitor.ts diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index 07111bd05..b17556b6f 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -27,7 +27,6 @@ import type { ParsedGir, GirInfoAttrs, GenerateConfig, - GirNSMember, IntrospectedFunctionParameter, IntrospectedClassFunction, PromisifyFunc, @@ -42,22 +41,22 @@ import { BinaryType, NullableType, ObjectType, -} from './newlib/gir.js' -import { IntrospectedAlias } from './newlib/gir/alias.js' -import { IntrospectedBase, IntrospectedNamespaceMember } from './newlib/gir/base.js' + GirNSMember, +} from './gir.js' +import { IntrospectedAlias } from './gir/alias.js' +import { IntrospectedBase, IntrospectedNamespaceMember } from './gir/base.js' +import { IntrospectedBaseClass, IntrospectedClass, IntrospectedRecord, IntrospectedInterface } from './gir/class.js' +import { IntrospectedConstant } from './gir/const.js' +import { IntrospectedEnum, IntrospectedError } from './gir/enum.js' import { - IntrospectedBaseClass, - IntrospectedClass, - IntrospectedRecord, - IntrospectedInterface, -} from './newlib/gir/class.js' -import { IntrospectedConstant } from './newlib/gir/const.js' -import { IntrospectedEnum, IntrospectedError } from './newlib/gir/enum.js' -import { IntrospectedFunction, IntrospectedCallback, IntrospectedClassCallback } from './newlib/gir/function.js' -import { NSRegistry } from './newlib/gir/registry.js' -import { isPrimitiveType } from './newlib/gir/util.js' -import { LoadOptions } from './newlib/types.js' -import { GirVisitor } from './newlib/visitor.js' + IntrospectedFunction, + IntrospectedCallback, + IntrospectedClassCallback, +} from './gir/function.js' +import { NSRegistry } from './gir/registry.js' +import { isPrimitiveType } from './gir/util.js' +import { LoadOptions } from './types.js' +import { GirVisitor } from './visitor.js' export class GirModule { /** diff --git a/packages/lib/src/newlib/gir.ts b/packages/lib/src/gir.ts similarity index 59% rename from packages/lib/src/newlib/gir.ts rename to packages/lib/src/gir.ts index 9f66fceb5..b1c0ef116 100644 --- a/packages/lib/src/newlib/gir.ts +++ b/packages/lib/src/gir.ts @@ -1,537 +1,543 @@ -import { IntrospectedNamespace } from "./gir/namespace.js"; -import { IntrospectedProperty, IntrospectedField } from "./gir/property.js"; -import { GenerationOptions } from "./types.js"; -import { sanitizeIdentifierName } from "./gir/util.js"; - -export { IntrospectedBase, Options as IntrospectedOptions, Metadata as IntrospectedMetadata } from "./gir/base.js"; -export * from "./gir/nodes.js"; +import { IntrospectedNamespace } from './gir/namespace.js' +import { IntrospectedProperty, IntrospectedField } from './gir/property.js' +import { GenerationOptions } from './types.js' +import { sanitizeIdentifierName } from './gir/util.js' + +export { + IntrospectedBase, + Options as IntrospectedOptions, + Metadata as IntrospectedMetadata, + IntrospectedNamespaceMember, + IntrospectedClassMember, +} from './gir/base.js' +export * from './gir/nodes.js' export abstract class TypeExpression { - isPointer = false; + isPointer = false - abstract equals(type: TypeExpression): boolean; - abstract unwrap(): TypeExpression; + abstract equals(type: TypeExpression): boolean + abstract unwrap(): TypeExpression deepUnwrap(): TypeExpression { - return this.unwrap(); + return this.unwrap() } - abstract rewrap(type: TypeExpression): TypeExpression; - abstract resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression; + abstract rewrap(type: TypeExpression): TypeExpression + abstract resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression - abstract print(namespace: IntrospectedNamespace, options: GenerationOptions): string; + abstract print(namespace: IntrospectedNamespace, options: GenerationOptions): string rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return this.print(namespace, options); + return this.print(namespace, options) } } export class TypeIdentifier extends TypeExpression { - readonly name: string; - readonly namespace: string; + readonly name: string + readonly namespace: string constructor(name: string, namespace: string) { - super(); - this.name = name; - this.namespace = namespace; + super() + this.name = name + this.namespace = namespace } equals(type: TypeExpression): boolean { - return type instanceof TypeIdentifier && type.name === this.name && type.namespace === this.namespace; + return type instanceof TypeIdentifier && type.name === this.name && type.namespace === this.namespace } is(namespace: string, name: string) { - return this.namespace === namespace && this.name === name; + return this.namespace === namespace && this.name === name } unwrap() { - return this; + return this } rewrap(type: TypeExpression): TypeExpression { - return type; + return type } protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { - const name: string = sanitizeIdentifierName(null, this.name); - const ns_name = this.namespace; + const name: string = sanitizeIdentifierName(null, this.name) + const ns_name = this.namespace - const ns = namespace.assertInstalledImport(ns_name); + const ns = namespace.assertInstalledImport(ns_name) if (ns.hasSymbol(name)) { - const c = ns.getClass(name); + const c = ns.getClass(name) // Some records are structs for other class types. // GirRecord.prototype.getType resolves this relationship. - if (c) return c.getType(); + if (c) return c.getType() - return new TypeIdentifier(name, ns_name); + return new TypeIdentifier(name, ns_name) } // Handle "class callback" types (they're in a definition-merged module) - let [cb, corrected_name] = ns.findClassCallback(name); - let resolved_name: string | null = null; + let [cb, corrected_name] = ns.findClassCallback(name) + let resolved_name: string | null = null if (!cb) { - resolved_name = ns.resolveSymbolFromTypeName(name); + resolved_name = ns.resolveSymbolFromTypeName(name) } - let c_resolved_name: string | null = null; + let c_resolved_name: string | null = null if (!c_resolved_name) { - c_resolved_name = ns.resolveSymbolFromTypeName(`${ns_name}${name}`); + c_resolved_name = ns.resolveSymbolFromTypeName(`${ns_name}${name}`) } if (!cb && !resolved_name && !c_resolved_name) { // Don't warn if a missing import is at fault, this will be dealt with later. if (namespace.name === ns_name) { - console.error(`Attempting to fall back on c:type inference for ${ns_name}.${name}.`); + console.error(`Attempting to fall back on c:type inference for ${ns_name}.${name}.`) } - [cb, corrected_name] = ns.findClassCallback(`${ns_name}${name}`); + ;[cb, corrected_name] = ns.findClassCallback(`${ns_name}${name}`) if (cb) { console.error( - `Falling back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` - ); + `Falling back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.`, + ) } } if (cb) { if (options.verbose) { - console.debug(`Callback found: ${cb}.${corrected_name}`); + console.debug(`Callback found: ${cb}.${corrected_name}`) } - return new TypeIdentifier(corrected_name, cb); + return new TypeIdentifier(corrected_name, cb) } else if (resolved_name) { - return new TypeIdentifier(resolved_name, ns_name); + return new TypeIdentifier(resolved_name, ns_name) } else if (c_resolved_name) { console.error( - `Fell back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.` - ); + `Fell back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.`, + ) - return new TypeIdentifier(c_resolved_name, ns_name); + return new TypeIdentifier(c_resolved_name, ns_name) } else if (namespace.name === ns_name) { - console.error(`Unable to resolve type ${this.name} in same namespace ${ns_name}!`); - return null; + console.error(`Unable to resolve type ${this.name} in same namespace ${ns_name}!`) + return null } - console.error(`Type ${this.namespace}.${this.name} could not be resolved in ${namespace.name}`); - return null; + console.error(`Type ${this.namespace}.${this.name} could not be resolved in ${namespace.name}`) + return null } resolveIdentifier(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { - return this._resolve(namespace, options); + return this._resolve(namespace, options) } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const resolved = this._resolve(namespace, options); + const resolved = this._resolve(namespace, options) // Generally if we can't resolve a type it is not introspectable, // thus we annotate it as "never". - return resolved ?? NeverType; + return resolved ?? NeverType } static new({ name, namespace }: { name: string; namespace: string }) { - return new TypeIdentifier(name, namespace); + return new TypeIdentifier(name, namespace) } // eslint-disable-next-line @typescript-eslint/no-unused-vars print(namespace: IntrospectedNamespace, options: GenerationOptions): string { if (namespace.name === this.namespace) { - return `${this.name}`; + return `${this.name}` } else { - return `${this.namespace}.${this.name}`; + return `${this.namespace}.${this.name}` } } } export class GenerifiedTypeIdentifier extends TypeIdentifier { - generics: TypeExpression[]; + generics: TypeExpression[] constructor(name: string, namespace: string, generics: TypeExpression[] = []) { - super(name, namespace); - this.generics = generics; + super(name, namespace) + this.generics = generics } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - const Generics = this.generics.map(generic => generic.print(namespace, options)).join(", "); + const Generics = this.generics.map((generic) => generic.print(namespace, options)).join(', ') if (namespace.name === this.namespace) { - return `${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + return `${this.name}${this.generics.length > 0 ? `<${Generics}>` : ''}` } else { - return `${this.namespace}.${this.name}${this.generics.length > 0 ? `<${Generics}>` : ""}`; + return `${this.namespace}.${this.name}${this.generics.length > 0 ? `<${Generics}>` : ''}` } } _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { - const iden = super._resolve(namespace, options); + const iden = super._resolve(namespace, options) if (iden) { - return new GenerifiedTypeIdentifier(iden.name, iden.namespace, [...this.generics]); + return new GenerifiedTypeIdentifier(iden.name, iden.namespace, [...this.generics]) } - return iden; + return iden } } export class NativeType extends TypeExpression { - readonly expression: (options?: GenerationOptions) => string; + readonly expression: (options?: GenerationOptions) => string constructor(expression: ((options?: GenerationOptions) => string) | string) { - super(); + super() - this.expression = typeof expression === "string" ? () => expression : expression; + this.expression = typeof expression === 'string' ? () => expression : expression } rewrap(type: TypeExpression): TypeExpression { - return type; + return type } resolve(): TypeExpression { - return this; + return this } print(_namespace: IntrospectedNamespace, options: GenerationOptions) { - return this.expression(options); + return this.expression(options) } equals(type: TypeExpression, options?: GenerationOptions): boolean { - return type instanceof NativeType && this.expression(options) === type.expression(options); + return type instanceof NativeType && this.expression(options) === type.expression(options) } unwrap(): TypeExpression { - return this; + return this } static withGenerator(generator: (options?: GenerationOptions) => string): TypeExpression { - return new NativeType(generator); + return new NativeType(generator) } static of(nativeType: string) { - return new NativeType(nativeType); + return new NativeType(nativeType) } } export class OrType extends TypeExpression { - readonly types: ReadonlyArray; + readonly types: ReadonlyArray constructor(type: TypeExpression, ...types: TypeExpression[]) { - super(); - this.types = [type, ...types]; + super() + this.types = [type, ...types] } rewrap(type: TypeExpression): TypeExpression { - return type; + return type } unwrap(): TypeExpression { - return this; + return this } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const [type, ...types] = this.types; + const [type, ...types] = this.types - return new OrType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); + return new OrType(type.resolve(namespace, options), ...types.map((t) => t.resolve(namespace, options))) } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `(${this.types.map(t => t.print(namespace, options)).join(" | ")})`; + return `(${this.types.map((t) => t.print(namespace, options)).join(' | ')})` } rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `${this.types.map(t => t.print(namespace, options)).join(" | ")}`; + return `${this.types.map((t) => t.print(namespace, options)).join(' | ')}` } equals(type: TypeExpression) { if (type instanceof OrType) { - return this.types.every(t => type.types.some(type => type.equals(t))); + return this.types.every((t) => type.types.some((type) => type.equals(t))) } else { - return false; + return false } } } export class TupleType extends OrType { print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `[${this.types.map(t => t.print(namespace, options)).join(", ")}]`; + return `[${this.types.map((t) => t.print(namespace, options)).join(', ')}]` } rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return this.print(namespace, options); + return this.print(namespace, options) } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const [type, ...types] = this.types; + const [type, ...types] = this.types - return new TupleType(type.resolve(namespace, options), ...types.map(t => t.resolve(namespace, options))); + return new TupleType(type.resolve(namespace, options), ...types.map((t) => t.resolve(namespace, options))) } equals(type: TypeExpression) { if (type instanceof TupleType) { - return this.types.length === type.types.length && this.types.every((t, i) => type.types[i].equals(t)); + return this.types.length === type.types.length && this.types.every((t, i) => type.types[i].equals(t)) } else { - return false; + return false } } } export class BinaryType extends OrType { constructor(primary: TypeExpression, secondary: TypeExpression) { - super(primary, secondary); + super(primary, secondary) } unwrap(): TypeExpression { - return this; + return this } resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { - return new BinaryType(this.a.resolve(namespace, options), this.b.resolve(namespace, options)); + return new BinaryType(this.a.resolve(namespace, options), this.b.resolve(namespace, options)) } is() { - return false; + return false } get a() { - return this.types[0]; + return this.types[0] } get b() { - return this.types[1]; + return this.types[1] } } export class FunctionType extends TypeExpression { - parameterTypes: { [name: string]: TypeExpression }; - returnType: TypeExpression; + parameterTypes: { [name: string]: TypeExpression } + returnType: TypeExpression constructor(parameters: { [name: string]: TypeExpression }, returnType: TypeExpression) { - super(); + super() - this.parameterTypes = parameters; - this.returnType = returnType; + this.parameterTypes = parameters + this.returnType = returnType } equals(type: TypeExpression): boolean { if (type instanceof FunctionType) { return ( - Object.values(this.parameterTypes).every(t => - Object.values(type.parameterTypes).some(tp => t.equals(tp)) + Object.values(this.parameterTypes).every((t) => + Object.values(type.parameterTypes).some((tp) => t.equals(tp)), ) && - Object.values(type.parameterTypes).every(t => - Object.values(this.parameterTypes).some(tp => t.equals(tp)) + Object.values(type.parameterTypes).every((t) => + Object.values(this.parameterTypes).some((tp) => t.equals(tp)), ) && this.returnType.equals(type.returnType) - ); + ) } - return false; + return false } rewrap(type: TypeExpression): TypeExpression { - return type; + return type } unwrap(): TypeExpression { - return this; + return this } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { return new FunctionType( Object.fromEntries( Object.entries(this.parameterTypes).map(([k, p]) => { - return [k, p.resolve(namespace, options)]; - }) + return [k, p.resolve(namespace, options)] + }), ), - this.returnType.resolve(namespace, options) - ); + this.returnType.resolve(namespace, options), + ) } rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions): string { const Parameters = Object.entries(this.parameterTypes) .map(([k, v]) => { - return `${k}: ${v.rootPrint(namespace, options)}`; + return `${k}: ${v.rootPrint(namespace, options)}` }) - .join(", "); + .join(', ') - return `(${Parameters}) => ${this.returnType.print(namespace, options)}`; + return `(${Parameters}) => ${this.returnType.print(namespace, options)}` } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return `(${this.rootPrint(namespace, options)})`; + return `(${this.rootPrint(namespace, options)})` } } export class Generic { - private _deriveFrom: TypeIdentifier | null; - private _genericType: GenericType; - private _defaultType: TypeExpression | null; - private _constraint: TypeExpression | null; - private _propagate: boolean; + private _deriveFrom: TypeIdentifier | null + private _genericType: GenericType + private _defaultType: TypeExpression | null + private _constraint: TypeExpression | null + private _propagate: boolean constructor( genericType: GenericType, defaultType?: TypeExpression, deriveFrom?: TypeIdentifier, constraint?: TypeExpression, - propagate = true + propagate = true, ) { - this._genericType = genericType; - this._defaultType = defaultType ?? null; - this._deriveFrom = deriveFrom ?? null; - this._constraint = constraint ?? null; - this._propagate = propagate; + this._genericType = genericType + this._defaultType = defaultType ?? null + this._deriveFrom = deriveFrom ?? null + this._constraint = constraint ?? null + this._propagate = propagate } unwrap() { - return this.type; + return this.type } get propagate() { - return this._propagate; + return this._propagate } get type() { - return this._genericType; + return this._genericType } get defaultType() { - return this._defaultType; + return this._defaultType } get constraint() { - return this._constraint; + return this._constraint } get parent() { - return this._deriveFrom; + return this._deriveFrom } } export class GenerifiedType extends TypeExpression { - type: TypeExpression; - generic: GenericType; + type: TypeExpression + generic: GenericType constructor(type: TypeExpression, generic: GenericType) { - super(); + super() - this.type = type; - this.generic = generic; + this.type = type + this.generic = generic } resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { - return new GenerifiedType(this.type.resolve(namespace, options), this.generic.resolve()); + return new GenerifiedType(this.type.resolve(namespace, options), this.generic.resolve()) } unwrap() { - return this.type; + return this.type } rootPrint(namespace: IntrospectedNamespace, options: GenerationOptions) { - return `${this.type.print(namespace, options)}<${this.generic.print()}>`; + return `${this.type.print(namespace, options)}<${this.generic.print()}>` } print(namespace: IntrospectedNamespace, options: GenerationOptions) { - return `${this.type.print(namespace, options)}<${this.generic.print()}>`; + return `${this.type.print(namespace, options)}<${this.generic.print()}>` } equals(type: TypeExpression): boolean { if (type instanceof GenerifiedType) { - return type.type.equals(this.type) && type.generic.equals(this.generic); + return type.type.equals(this.type) && type.generic.equals(this.generic) } - return false; + return false } rewrap(type: TypeExpression): TypeExpression { - return new GenerifiedType(this.type.rewrap(type), this.generic); + return new GenerifiedType(this.type.rewrap(type), this.generic) } } export class GenericType extends TypeExpression { - identifier: string; - replacedType?: TypeExpression; + identifier: string + replacedType?: TypeExpression constructor(identifier: string, replacedType?: TypeExpression) { - super(); - this.identifier = identifier; - this.replacedType = replacedType; + super() + this.identifier = identifier + this.replacedType = replacedType } equals(type: TypeExpression): boolean { if (type instanceof GenericType) { - return type.identifier === this.identifier; + return type.identifier === this.identifier } - return false; + return false } unwrap(): TypeExpression { - return this; + return this } rewrap(type: TypeExpression): TypeExpression { - return type; + return type } resolve(): GenericType { - return this; + return this } print(): string { - return `${this.identifier}`; + return `${this.identifier}` } } export class NullableType extends BinaryType { constructor(type: TypeExpression) { - super(type, NullType); + super(type, NullType) } unwrap() { - return this.type; + return this.type } rewrap(type: TypeExpression): TypeExpression { - return new NullableType(this.type.rewrap(type)); + return new NullableType(this.type.rewrap(type)) } get type() { - return this.a; + return this.a } } export class PromiseType extends TypeExpression { - type: TypeExpression; + type: TypeExpression constructor(type: TypeExpression) { - super(); - this.type = type; + super() + this.type = type } equals(type: TypeExpression): boolean { - return type instanceof PromiseType && type.type.equals(this.type); + return type instanceof PromiseType && type.type.equals(this.type) } unwrap() { - return this.type; + return this.type } rewrap(type: TypeExpression): TypeExpression { - return new PromiseType(this.type.rewrap(type)); + return new PromiseType(this.type.rewrap(type)) } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - return new PromiseType(this.type.resolve(namespace, options)); + return new PromiseType(this.type.resolve(namespace, options)) } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { // TODO: Optimize this check. - if (!namespace.hasSymbol("Promise")) { - return `Promise<${this.type.print(namespace, options)}>`; + if (!namespace.hasSymbol('Promise')) { + return `Promise<${this.type.print(namespace, options)}>` } - return `globalThis.Promise<${this.type.print(namespace, options)}>`; + return `globalThis.Promise<${this.type.print(namespace, options)}>` } } @@ -552,7 +558,7 @@ export enum ConflictType { FIELD_NAME_CONFLICT, FUNCTION_NAME_CONFLICT, ACCESSOR_PROPERTY_CONFLICT, - PROPERTY_ACCESSOR_CONFLICT + PROPERTY_ACCESSOR_CONFLICT, } /** @@ -567,188 +573,188 @@ export enum ConflictType { * resolve the conflicts so the typing stays sound. */ export class TypeConflict extends TypeExpression { - readonly conflictType: ConflictType; - readonly type: TypeExpression; + readonly conflictType: ConflictType + readonly type: TypeExpression constructor(type: TypeExpression, conflictType: ConflictType) { - super(); - this.type = type; - this.conflictType = conflictType; + super() + this.type = type + this.conflictType = conflictType } rewrap(type: TypeExpression) { - return new TypeConflict(this.type.rewrap(type), this.conflictType); + return new TypeConflict(this.type.rewrap(type), this.conflictType) } unwrap() { - return this.type; + return this.type } // TODO: This constant "true" is a remnant of the Anyified type. equals() { - return true; + return true } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { throw new Error( `Type conflict was not resolved for ${this.type.resolve(namespace, options).print(namespace, options)} in ${ namespace.name - }` - ); + }`, + ) } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { throw new Error( `Type conflict was not resolved for ${this.type.resolve(namespace, options).print(namespace, options)} in ${ namespace.name - }` - ); + }`, + ) } } export class ClosureType extends TypeExpression { - type: TypeExpression; - user_data: number | null = null; + type: TypeExpression + user_data: number | null = null constructor(type: TypeExpression) { - super(); - this.type = type; + super() + this.type = type } equals(type: TypeExpression): boolean { if (type instanceof ClosureType) { - const closureType = type; - return this.type.equals(closureType.type); + const closureType = type + return this.type.equals(closureType.type) } - return false; + return false } deepUnwrap(): TypeExpression { - return this.type; + return this.type } rewrap(type: TypeExpression): TypeExpression { - const closure = new ClosureType(this.type.rewrap(type)); + const closure = new ClosureType(this.type.rewrap(type)) - closure.user_data = this.user_data; + closure.user_data = this.user_data - return closure; + return closure } unwrap(): TypeExpression { - return this; + return this } resolve(namespace: IntrospectedNamespace, options: GenerationOptions) { - const { user_data, type } = this; + const { user_data, type } = this return ClosureType.new({ user_data, - type: type.resolve(namespace, options) - }); + type: type.resolve(namespace, options), + }) } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - return this.type.print(namespace, options); + return this.type.print(namespace, options) } static new({ type, user_data = null }: { type: TypeExpression; user_data?: number | null }) { - const vt = new ClosureType(type); - vt.user_data = user_data; - return vt; + const vt = new ClosureType(type) + vt.user_data = user_data + return vt } } export class ArrayType extends TypeExpression { - type: TypeExpression; - arrayDepth: number = 1; - length: number | null = null; + type: TypeExpression + arrayDepth: number = 1 + length: number | null = null constructor(type: TypeExpression) { - super(); - this.type = type; + super() + this.type = type } deepUnwrap(): TypeExpression { - return this.type; + return this.type } unwrap(): TypeExpression { - return this; + return this } rewrap(type: TypeExpression): TypeExpression { - const array = new ArrayType(this.type.rewrap(type)); + const array = new ArrayType(this.type.rewrap(type)) - array.arrayDepth = this.arrayDepth; - array.length = this.length; + array.arrayDepth = this.arrayDepth + array.length = this.length - return array; + return array } equals(type: TypeExpression) { if (type instanceof ArrayType) { - const arrayType: ArrayType = type; + const arrayType: ArrayType = type - return arrayType.type.equals(this.type) && type.arrayDepth === this.arrayDepth; + return arrayType.type.equals(this.type) && type.arrayDepth === this.arrayDepth } - return false; + return false } resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeExpression { - const { type, arrayDepth, length } = this; + const { type, arrayDepth, length } = this return ArrayType.new({ type: type.resolve(namespace, options), arrayDepth, - length - }); + length, + }) } print(namespace: IntrospectedNamespace, options: GenerationOptions): string { - const depth = this.arrayDepth; - let typeSuffix: string = ""; + const depth = this.arrayDepth + let typeSuffix: string = '' if (depth === 0) { - typeSuffix = ""; + typeSuffix = '' } else if (depth === 1) { - typeSuffix = "[]"; + typeSuffix = '[]' } else { - typeSuffix = "".padStart(2 * depth, "[]"); + typeSuffix = ''.padStart(2 * depth, '[]') } - return `${this.type.print(namespace, options)}${typeSuffix}`; + return `${this.type.print(namespace, options)}${typeSuffix}` } static new({ type, arrayDepth = 1, - length = null + length = null, }: { - type: TypeExpression; - length?: number | null; - arrayDepth?: number; + type: TypeExpression + length?: number | null + arrayDepth?: number }) { - const vt = new ArrayType(type); - vt.length = length; - vt.arrayDepth = arrayDepth; - return vt; + const vt = new ArrayType(type) + vt.length = length + vt.arrayDepth = arrayDepth + return vt } } -export const GTypeType = new TypeIdentifier("GType", "GObject"); -export const ThisType = new NativeType("this"); -export const ObjectType = new NativeType("object"); -export const AnyType = new NativeType("any"); -export const NeverType = new NativeType("never"); -export const Uint8ArrayType = new NativeType("Uint8Array"); -export const BooleanType = new NativeType("boolean"); -export const StringType = new NativeType("string"); -export const NumberType = new NativeType("number"); -export const NullType = new NativeType("null"); -export const VoidType = new NativeType("void"); -export const UnknownType = new NativeType("unknown"); -export const AnyFunctionType = new NativeType("(...args: any[]) => any"); - -export type GirClassField = IntrospectedProperty | IntrospectedField; +export const GTypeType = new TypeIdentifier('GType', 'GObject') +export const ThisType = new NativeType('this') +export const ObjectType = new NativeType('object') +export const AnyType = new NativeType('any') +export const NeverType = new NativeType('never') +export const Uint8ArrayType = new NativeType('Uint8Array') +export const BooleanType = new NativeType('boolean') +export const StringType = new NativeType('string') +export const NumberType = new NativeType('number') +export const NullType = new NativeType('null') +export const VoidType = new NativeType('void') +export const UnknownType = new NativeType('unknown') +export const AnyFunctionType = new NativeType('(...args: any[]) => any') + +export type GirClassField = IntrospectedProperty | IntrospectedField diff --git a/packages/lib/src/gir/.eslintrc.cjs b/packages/lib/src/gir/.eslintrc.cjs new file mode 100644 index 000000000..25ee0da0e --- /dev/null +++ b/packages/lib/src/gir/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + rules: { + semi: ["error", "always"], + quotes: ["error", "double", { avoidEscape: true }], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + camelcase: "off", + "@typescript-eslint/camelcase": "off" + }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ["../../tsconfig.json"] + }, + globals: { + imports: true + } +}; diff --git a/packages/lib/src/gir/.prettierrc.json b/packages/lib/src/gir/.prettierrc.json new file mode 100644 index 000000000..71bd46baf --- /dev/null +++ b/packages/lib/src/gir/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "none", + "arrowParens": "avoid", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 +} diff --git a/packages/lib/src/newlib/gir/alias.ts b/packages/lib/src/gir/alias.ts similarity index 97% rename from packages/lib/src/newlib/gir/alias.ts rename to packages/lib/src/gir/alias.ts index 340855833..61c4fc63a 100644 --- a/packages/lib/src/newlib/gir/alias.ts +++ b/packages/lib/src/gir/alias.ts @@ -1,7 +1,7 @@ import { TypeExpression } from "../gir.js"; import { IntrospectedNamespaceMember, Options } from "./base.js"; -import { GirAliasElement } from "../../index.js"; +import { GirAliasElement } from "../index.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { sanitizeIdentifierName, getAliasType, parseDoc, parseMetadata } from "./util.js"; import { FormatGenerator, GenericDescriptor } from "../generators/generator.js"; diff --git a/packages/lib/src/newlib/gir/base.ts b/packages/lib/src/gir/base.ts similarity index 100% rename from packages/lib/src/newlib/gir/base.ts rename to packages/lib/src/gir/base.ts diff --git a/packages/lib/src/newlib/gir/class.ts b/packages/lib/src/gir/class.ts similarity index 99% rename from packages/lib/src/newlib/gir/class.ts rename to packages/lib/src/gir/class.ts index 75a547425..1c4692f9e 100644 --- a/packages/lib/src/newlib/gir/class.ts +++ b/packages/lib/src/gir/class.ts @@ -19,7 +19,7 @@ import { import { TypeExpression } from "../gir.js"; import { IntrospectedBase, IntrospectedClassMember, IntrospectedNamespaceMember, Options } from "./base.js"; -import { GirInterfaceElement, GirClassElement, GirRecordElement, GirDirection, GirUnionElement } from "../../index.js"; +import { GirInterfaceElement, GirClassElement, GirRecordElement, GirDirection, GirUnionElement } from "../index.js"; import { IntrospectedClassFunction, IntrospectedVirtualClassFunction, diff --git a/packages/lib/src/newlib/gir/const.ts b/packages/lib/src/gir/const.ts similarity index 97% rename from packages/lib/src/newlib/gir/const.ts rename to packages/lib/src/gir/const.ts index 7b9e71040..30e5f3105 100644 --- a/packages/lib/src/newlib/gir/const.ts +++ b/packages/lib/src/gir/const.ts @@ -1,6 +1,6 @@ import { TypeExpression } from "../gir.js"; import { IntrospectedNamespaceMember, Options } from "./base.js"; -import { GirConstantElement } from "../../index.js"; +import { GirConstantElement } from "../index.js"; import { IntrospectedNamespace } from "./namespace.js"; import { getType, parseDoc, parseMetadata, sanitizeIdentifierName } from "./util.js"; diff --git a/packages/lib/src/newlib/gir/enum.ts b/packages/lib/src/gir/enum.ts similarity index 99% rename from packages/lib/src/newlib/gir/enum.ts rename to packages/lib/src/gir/enum.ts index aaecdd4c7..03448e2ea 100644 --- a/packages/lib/src/newlib/gir/enum.ts +++ b/packages/lib/src/gir/enum.ts @@ -1,7 +1,7 @@ import { NumberType, TypeIdentifier } from "../gir.js"; import { IntrospectedBase, IntrospectedNamespaceMember } from "./base.js"; -import { GirMemberElement, GirEnumElement, GirBitfieldElement } from "../../index.js"; +import { GirMemberElement, GirEnumElement, GirBitfieldElement } from "../index.js"; import { GirComplexRecord, IntrospectedRecord } from "./class.js"; import { IntrospectedField } from "./property.js"; diff --git a/packages/lib/src/newlib/gir/function.ts b/packages/lib/src/gir/function.ts similarity index 99% rename from packages/lib/src/newlib/gir/function.ts rename to packages/lib/src/gir/function.ts index 76fd4fea2..53a9e4d0f 100644 --- a/packages/lib/src/newlib/gir/function.ts +++ b/packages/lib/src/gir/function.ts @@ -20,7 +20,7 @@ import { GirVirtualMethodElement, GirConstructorElement, GirModule -} from "../../index.js"; +} from "../index.js"; import { IntrospectedNamespace, isIntrospectable } from "./namespace.js"; import { getType, isInvalid, sanitizeMemberName, sanitizeIdentifierName, parseDoc, parseMetadata } from "./util.js"; diff --git a/packages/lib/src/newlib/gir/generics.ts b/packages/lib/src/gir/generics.ts similarity index 100% rename from packages/lib/src/newlib/gir/generics.ts rename to packages/lib/src/gir/generics.ts diff --git a/packages/lib/src/newlib/gir/namespace.ts b/packages/lib/src/gir/namespace.ts similarity index 96% rename from packages/lib/src/newlib/gir/namespace.ts rename to packages/lib/src/gir/namespace.ts index 2c57825ee..26e8f73b1 100644 --- a/packages/lib/src/newlib/gir/namespace.ts +++ b/packages/lib/src/gir/namespace.ts @@ -1,6 +1,6 @@ import { BinaryType, VoidType, PromiseType, BooleanType, TupleType, TypeIdentifier, ClosureType } from "../gir.js"; -import { GirInfoAttrs, GirModule } from "../../index.js"; +import { GirInfoAttrs, GirModule } from "../index.js"; import { IntrospectedBaseClass } from "./class.js"; import { IntrospectedFunction } from "./function.js"; @@ -79,4 +79,4 @@ export function promisifyNamespaceFunctions(namespace: GirModule) { }); } -export { GirModule as IntrospectedNamespace } from "../../gir-module.js"; +export { GirModule as IntrospectedNamespace } from "../gir-module.js"; diff --git a/packages/lib/src/newlib/gir/nodes.ts b/packages/lib/src/gir/nodes.ts similarity index 90% rename from packages/lib/src/newlib/gir/nodes.ts rename to packages/lib/src/gir/nodes.ts index f215db9c2..6c01a6bae 100644 --- a/packages/lib/src/newlib/gir/nodes.ts +++ b/packages/lib/src/gir/nodes.ts @@ -7,9 +7,10 @@ export { IntrospectedBaseClass } from "./class.js"; export { IntrospectedConstant } from "./const.js"; -export { IntrospectedEnum, GirEnumMember } from "./enum.js"; +export { IntrospectedEnum, GirEnumMember as IntrospectedEnumMember, IntrospectedError } from "./enum.js"; export { IntrospectedFunction, + IntrospectedClassCallback, IntrospectedClassFunction, IntrospectedCallback, IntrospectedConstructor, diff --git a/packages/lib/src/newlib/gir/property.ts b/packages/lib/src/gir/property.ts similarity index 98% rename from packages/lib/src/newlib/gir/property.ts rename to packages/lib/src/gir/property.ts index 2d2738ef2..a18b7ae5f 100644 --- a/packages/lib/src/newlib/gir/property.ts +++ b/packages/lib/src/gir/property.ts @@ -1,6 +1,6 @@ import { TypeExpression } from "../gir.js"; import { IntrospectedBase, IntrospectedClassMember, Options } from "./base.js"; -import { GirFieldElement, GirPropertyElement } from "../../index.js"; +import { GirFieldElement, GirPropertyElement } from "../index.js"; import { getType, parseDoc, parseMetadata } from "./util.js"; import { isIntrospectable } from "./namespace.js"; diff --git a/packages/lib/src/newlib/gir/registry.ts b/packages/lib/src/gir/registry.ts similarity index 98% rename from packages/lib/src/newlib/gir/registry.ts rename to packages/lib/src/gir/registry.ts index 5bec9e897..dbfb1a877 100644 --- a/packages/lib/src/newlib/gir/registry.ts +++ b/packages/lib/src/gir/registry.ts @@ -14,8 +14,8 @@ import { GirVisitor } from "../visitor.js"; import { IntrospectedNamespace } from "./namespace.js"; import { DtsModuleGenerator } from "../generators/dts-modules.js"; import { DtsInlineGenerator } from "../generators/dts-inline.js"; -import { ParsedGir } from "../../types/parsed-gir.js"; -import { GenerateConfig } from "../../types/generate-config.js"; +import { ParsedGir } from "../types/parsed-gir.js"; +import { GenerateConfig } from "../types/generate-config.js"; export interface NSLoader { load(namespace: string, version: string): ParsedGir | null; diff --git a/packages/lib/src/newlib/gir/signal.ts b/packages/lib/src/gir/signal.ts similarity index 100% rename from packages/lib/src/newlib/gir/signal.ts rename to packages/lib/src/gir/signal.ts diff --git a/packages/lib/src/newlib/gir/util.ts b/packages/lib/src/gir/util.ts similarity index 100% rename from packages/lib/src/newlib/gir/util.ts rename to packages/lib/src/gir/util.ts diff --git a/packages/lib/src/index.ts b/packages/lib/src/index.ts index af716df46..5012cbfde 100644 --- a/packages/lib/src/index.ts +++ b/packages/lib/src/index.ts @@ -11,3 +11,5 @@ export * from './messages.js' export * from './symtable.js' export * from './transformation.js' export * from './utils.js' +export * from './gir.js' +export * from './registry.js' diff --git a/packages/lib/src/injections/.eslintrc.cjs b/packages/lib/src/injections/.eslintrc.cjs new file mode 100644 index 000000000..25ee0da0e --- /dev/null +++ b/packages/lib/src/injections/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + rules: { + semi: ["error", "always"], + quotes: ["error", "double", { avoidEscape: true }], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + camelcase: "off", + "@typescript-eslint/camelcase": "off" + }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ["../../tsconfig.json"] + }, + globals: { + imports: true + } +}; diff --git a/packages/lib/src/injections/.prettierrc.json b/packages/lib/src/injections/.prettierrc.json new file mode 100644 index 000000000..71bd46baf --- /dev/null +++ b/packages/lib/src/injections/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "none", + "arrowParens": "avoid", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 +} diff --git a/packages/lib/src/newlib/injections/gio.ts b/packages/lib/src/injections/gio.ts similarity index 100% rename from packages/lib/src/newlib/injections/gio.ts rename to packages/lib/src/injections/gio.ts diff --git a/packages/lib/src/newlib/injections/glib.ts b/packages/lib/src/injections/glib.ts similarity index 100% rename from packages/lib/src/newlib/injections/glib.ts rename to packages/lib/src/injections/glib.ts diff --git a/packages/lib/src/newlib/injections/gobject.ts b/packages/lib/src/injections/gobject.ts similarity index 100% rename from packages/lib/src/newlib/injections/gobject.ts rename to packages/lib/src/injections/gobject.ts diff --git a/packages/lib/src/newlib/injections/inject.ts b/packages/lib/src/injections/inject.ts similarity index 100% rename from packages/lib/src/newlib/injections/inject.ts rename to packages/lib/src/injections/inject.ts diff --git a/packages/lib/src/newlib/.eslintrc.cjs b/packages/lib/src/newlib/.eslintrc.cjs deleted file mode 100644 index 5f4fa1024..000000000 --- a/packages/lib/src/newlib/.eslintrc.cjs +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"], - "extends": [ - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "prettier" - ], - "rules": { - "semi": ["error", "always"], - "quotes": ["error", "double", {avoidEscape: true}], - "no-debugger": "off", - "@typescript-eslint/triple-slash-reference": "off", - "camelcase": "off", - "@typescript-eslint/camelcase": "off" - }, - "parserOptions": { - "tsconfigRootDir": __dirname, - "project": ["../../tsconfig.json"] - }, - "globals": { - "imports": true - } -} diff --git a/packages/lib/src/newlib/lib.ts b/packages/lib/src/newlib/lib.ts deleted file mode 100644 index d51d9b94b..000000000 --- a/packages/lib/src/newlib/lib.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { NSRegistry } from "./gir/registry.js"; -import { SanitizedIdentifiers } from "./gir/util.js"; - -import { GenerationOptions, Metadata } from "./types.js"; - -export * as dts from "./generators/dts-modules.js"; - -export * as json from "./generators/json.js"; - -export * from "./generators/index.js"; - -export * from "./types.js"; - -export * from "./gir.js"; -export * from "./gir/nodes.js"; - -export { NSRegistry as GirNSRegistry } from "./gir/registry.js"; -export { Formatter } from "./formatters/formatter.js"; - -export function getSanitizedIdentifiers(): ReadonlyMap { - return SanitizedIdentifiers; -} - -export function createRegistry(): NSRegistry { - return new NSRegistry(); -} - -export interface GeneratedModule { - meta: Metadata; - formattedOutput: string; -} - -export async function generateModule( - options: GenerationOptions, - registry: NSRegistry, - name: string, - version: string -): Promise { - const ns = registry.namespace(name, version); - - const format = "dts"; // TODO: options.format; - - if (ns) { - const Generator = await registry.getGenerator(format); - - if (!Generator) { - throw new Error(`Invalid output format selected: ${format}.`); - } - - const generator = new Generator(ns, options); - - let generated: string | null = null; - - try { - generated = await generator.stringifyNamespace(ns); - } catch (error) { - console.error(`Failed to generate ${ns.name} ${ns.version}...`); - - if (options.verbose) { - console.error(error); - } - } - - if (!generated) { - return null; - } - - const meta: Metadata = { - name: ns.name, - api_version: ns.version, - package_version: ns.package_version.join("."), - imports: Object.fromEntries(ns.getImports()) - }; - - const formatter = registry.getFormatter(format); - const formatted = !options.noPrettyPrint ? await formatter.format(generated) : generated; - - return { - formattedOutput: formatted, - meta - }; - } - - return null; -} diff --git a/packages/lib/src/newlib/util.ts b/packages/lib/src/newlib/util.ts deleted file mode 100644 index 773946ffc..000000000 --- a/packages/lib/src/newlib/util.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * A simple two-key map. - */ -export class TwoKeyMap { - private baseMap = new Map>(); - - forEach(op: (v: V) => void) { - this.baseMap.forEach(map => { - map.forEach(v => { - op(v); - }); - }); - } - - has(key1: K1, key2: K2): boolean { - const obj = this.baseMap.get(key1); - - if (!obj) { - return false; - } - - return obj.has(key2); - } - - getIfOnly(key1: K1): readonly [K2, V] | undefined { - const obj = this.baseMap.get(key1); - - if (!obj) { - return undefined; - } - - if (obj.size === 1) { - const [k2] = obj.keys(); - const v = obj.get(k2); - - if (!v) { - return undefined; - } - - return [k2, v] as const; - } - - return undefined; - } - - get(key1: K1, key2: K2): V | undefined { - const obj = this.baseMap.get(key1); - - if (!obj) { - return undefined; - } - - return obj.get(key2); - } - - set(key1: K1, key2: K2, value: V): void { - let obj = this.baseMap.get(key1); - - if (!obj) { - obj = new Map(); - - this.baseMap.set(key1, obj); - } - - obj.set(key2, value); - } -} - -/** - * If the predicate returns a value other than undefined, - * that value is returned. It combines the .find() and - * .map() APIs for convenience. - * - * @param arr - * @param predicate - */ -export function findMap(arr: T[], predicate: (p: T) => K | undefined): K | undefined { - for (const a of arr) { - const val = predicate(a); - if (val !== undefined) return val; - } - - return undefined; -} diff --git a/packages/lib/src/registry.ts b/packages/lib/src/registry.ts new file mode 100644 index 000000000..04805fff4 --- /dev/null +++ b/packages/lib/src/registry.ts @@ -0,0 +1,85 @@ +import { NSRegistry } from './gir/registry.js' +import { SanitizedIdentifiers } from './gir/util.js' +export { FormatGenerator } from './generators/generator.js' + +import { GenerationOptions, Metadata } from './types.js' + +export * as dts from './generators/dts-modules.js' + +export * as json from './generators/json.js' + +export * from './generators/index.js' + +export * from './types.js' + +export { isInvalid, isPrimitiveType, isSubtypeOf, sanitizeIdentifierName } from './gir/util.js' + +export { NSRegistry as GirNSRegistry } from './gir/registry.js' +export { Formatter } from './formatters/formatter.js' + +export function getSanitizedIdentifiers(): ReadonlyMap { + return SanitizedIdentifiers +} + +export function createRegistry(): NSRegistry { + return new NSRegistry() +} + +export interface GeneratedModule { + meta: Metadata + formattedOutput: string +} + +export async function generateModule( + options: GenerationOptions, + registry: NSRegistry, + name: string, + version: string, +): Promise { + const ns = registry.namespace(name, version) + + const format = 'dts' // TODO: options.format; + + if (ns) { + const Generator = await registry.getGenerator(format) + + if (!Generator) { + throw new Error(`Invalid output format selected: ${format}.`) + } + + const generator = new Generator(ns, options) + + let generated: string | null = null + + try { + generated = await generator.stringifyNamespace(ns) + } catch (error) { + console.error(`Failed to generate ${ns.name} ${ns.version}...`) + + if (options.verbose) { + console.error(error) + } + } + + if (!generated) { + return null + } + + const meta: Metadata = { + name: ns.name, + api_version: ns.version, + package_version: ns.package_version.join('.'), + imports: Object.fromEntries(ns.getImports()), + } + + const formatter = registry.getFormatter(format) + const formatted = !options.noPrettyPrint ? await formatter.format(generated) : generated + + return { + formattedOutput: formatted, + meta, + } + } + + return null +} diff --git a/packages/lib/src/newlib/types.ts b/packages/lib/src/types.ts similarity index 61% rename from packages/lib/src/newlib/types.ts rename to packages/lib/src/types.ts index f9d9dbf4c..ff3970131 100644 --- a/packages/lib/src/newlib/types.ts +++ b/packages/lib/src/types.ts @@ -1,25 +1,25 @@ -import { GenerateConfig } from "../types"; +import { GenerateConfig } from './types/generate-config.js' -export type PropertyCase = "both" | "camel" | "underscore"; -export type Format = "dts" | "json"; +export type PropertyCase = 'both' | 'camel' | 'underscore' +export type Format = 'dts' | 'json' export interface Options { - environment: "gjs"; - verbose: boolean; + environment: 'gjs' + verbose: boolean } export interface LoadOptions extends Options { - loadDocs: boolean; - propertyCase: PropertyCase; + loadDocs: boolean + propertyCase: PropertyCase } export interface TransformOptions extends Options { - inferGenerics: boolean; + inferGenerics: boolean } -export type OutputFormat = "file" | "folder"; +export type OutputFormat = 'file' | 'folder' -export type GenerationOptions = GenerateConfig; +export type GenerationOptions = GenerateConfig // [key: string]: boolean | string | number | undefined; // outputFormat?: string; // outputPath?: string; @@ -43,8 +43,8 @@ export type GenerationOptions = GenerateConfig; // } export interface Metadata { - name: string; - package_version: string; - api_version: string; - imports: { [lib: string]: string }; + name: string + package_version: string + api_version: string + imports: { [lib: string]: string } } diff --git a/packages/lib/src/types/index.ts b/packages/lib/src/types/index.ts index 4757266dd..907c7393a 100644 --- a/packages/lib/src/types/index.ts +++ b/packages/lib/src/types/index.ts @@ -125,4 +125,3 @@ export * from './type-ts-function.js' export * from './type-ts-property.js' export * from './user-config-load-result.js' export * from './user-config.js' -export * from '../newlib/gir.js' diff --git a/packages/lib/src/util.ts b/packages/lib/src/util.ts new file mode 100644 index 000000000..137be2332 --- /dev/null +++ b/packages/lib/src/util.ts @@ -0,0 +1,84 @@ +/** + * A simple two-key map. + */ +export class TwoKeyMap { + private baseMap = new Map>() + + forEach(op: (v: V) => void) { + this.baseMap.forEach((map) => { + map.forEach((v) => { + op(v) + }) + }) + } + + has(key1: K1, key2: K2): boolean { + const obj = this.baseMap.get(key1) + + if (!obj) { + return false + } + + return obj.has(key2) + } + + getIfOnly(key1: K1): readonly [K2, V] | undefined { + const obj = this.baseMap.get(key1) + + if (!obj) { + return undefined + } + + if (obj.size === 1) { + const [k2] = obj.keys() + const v = obj.get(k2) + + if (!v) { + return undefined + } + + return [k2, v] as const + } + + return undefined + } + + get(key1: K1, key2: K2): V | undefined { + const obj = this.baseMap.get(key1) + + if (!obj) { + return undefined + } + + return obj.get(key2) + } + + set(key1: K1, key2: K2, value: V): void { + let obj = this.baseMap.get(key1) + + if (!obj) { + obj = new Map() + + this.baseMap.set(key1, obj) + } + + obj.set(key2, value) + } +} + +/** + * If the predicate returns a value other than undefined, + * that value is returned. It combines the .find() and + * .map() APIs for convenience. + * + * @param arr + * @param predicate + */ +export function findMap(arr: T[], predicate: (p: T) => K | undefined): K | undefined { + for (const a of arr) { + const val = predicate(a) + if (val !== undefined) return val + } + + return undefined +} diff --git a/packages/lib/src/validators/.eslintrc.cjs b/packages/lib/src/validators/.eslintrc.cjs new file mode 100644 index 000000000..25ee0da0e --- /dev/null +++ b/packages/lib/src/validators/.eslintrc.cjs @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier" + ], + rules: { + semi: ["error", "always"], + quotes: ["error", "double", { avoidEscape: true }], + "no-debugger": "off", + "@typescript-eslint/triple-slash-reference": "off", + camelcase: "off", + "@typescript-eslint/camelcase": "off" + }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ["../../tsconfig.json"] + }, + globals: { + imports: true + } +}; diff --git a/packages/lib/src/validators/.prettierrc.json b/packages/lib/src/validators/.prettierrc.json new file mode 100644 index 000000000..71bd46baf --- /dev/null +++ b/packages/lib/src/validators/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "none", + "arrowParens": "avoid", + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 +} diff --git a/packages/lib/src/newlib/validators/class.ts b/packages/lib/src/validators/class.ts similarity index 100% rename from packages/lib/src/newlib/validators/class.ts rename to packages/lib/src/validators/class.ts diff --git a/packages/lib/src/newlib/validators/interface.ts b/packages/lib/src/validators/interface.ts similarity index 100% rename from packages/lib/src/newlib/validators/interface.ts rename to packages/lib/src/validators/interface.ts diff --git a/packages/lib/src/newlib/visitor.ts b/packages/lib/src/visitor.ts similarity index 52% rename from packages/lib/src/newlib/visitor.ts rename to packages/lib/src/visitor.ts index f9c4b0987..d32fe92f3 100644 --- a/packages/lib/src/newlib/visitor.ts +++ b/packages/lib/src/visitor.ts @@ -1,8 +1,8 @@ -import { TypeExpression } from "./gir.js"; -import { IntrospectedAlias } from "./gir/alias.js"; -import { IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from "./gir/class.js"; -import { IntrospectedConstant } from "./gir/const.js"; -import { GirEnumMember, IntrospectedError, IntrospectedEnum } from "./gir/enum.js"; +import { TypeExpression } from './gir.js' +import { IntrospectedAlias } from './gir/alias.js' +import { IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from './gir/class.js' +import { IntrospectedConstant } from './gir/const.js' +import { GirEnumMember, IntrospectedError, IntrospectedEnum } from './gir/enum.js' import { IntrospectedCallback, IntrospectedConstructor, @@ -12,40 +12,40 @@ import { IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction, IntrospectedDirectAllocationConstructor, - IntrospectedClassCallback -} from "./gir/function.js"; -import { IntrospectedNamespace } from "./gir/namespace.js"; -import { IntrospectedProperty, IntrospectedField } from "./gir/property.js"; -import { IntrospectedSignal, IntrospectedSignalType } from "./gir/signal.js"; + IntrospectedClassCallback, +} from './gir/function.js' +import { IntrospectedNamespace } from './gir/namespace.js' +import { IntrospectedProperty, IntrospectedField } from './gir/property.js' +import { IntrospectedSignal, IntrospectedSignalType } from './gir/signal.js' export abstract class GirVisitor { - visitType?: (node: TypeExpression) => TypeExpression; - visitCallback?: (node: IntrospectedCallback) => IntrospectedCallback; - visitClassCallback?: (node: IntrospectedClassCallback) => IntrospectedClassCallback; - visitAlias?: (node: IntrospectedAlias) => IntrospectedAlias; - visitConstructor?: (node: IntrospectedConstructor) => IntrospectedConstructor; + visitType?: (node: TypeExpression) => TypeExpression + visitCallback?: (node: IntrospectedCallback) => IntrospectedCallback + visitClassCallback?: (node: IntrospectedClassCallback) => IntrospectedClassCallback + visitAlias?: (node: IntrospectedAlias) => IntrospectedAlias + visitConstructor?: (node: IntrospectedConstructor) => IntrospectedConstructor visitDirectAllocationConstructor?: ( - node: IntrospectedDirectAllocationConstructor - ) => IntrospectedDirectAllocationConstructor; - visitConstructorFunction?: (node: IntrospectedConstructor) => IntrospectedConstructor; - visitRecord?: (node: IntrospectedRecord) => IntrospectedRecord; - visitInterface?: (node: IntrospectedInterface) => IntrospectedInterface; - visitEnumMember?: (node: GirEnumMember) => GirEnumMember; - visitError?: (node: IntrospectedError) => IntrospectedError; - visitEnum?: (node: IntrospectedEnum) => IntrospectedEnum; - visitConst?: (node: IntrospectedConstant) => IntrospectedConstant; - visitClass?: (node: IntrospectedClass) => IntrospectedClass; - visitParameter?: (node: IntrospectedFunctionParameter) => IntrospectedFunctionParameter; - visitProperty?: (node: IntrospectedProperty) => IntrospectedProperty; - visitField?: (node: IntrospectedField) => IntrospectedField; - visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal; - visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction; - visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction; - visitStaticClassFunction?: (node: IntrospectedStaticClassFunction) => IntrospectedStaticClassFunction; - visitVirtualClassFunction?: (node: IntrospectedVirtualClassFunction) => IntrospectedVirtualClassFunction; - visitNamespace?: (node: IntrospectedNamespace) => IntrospectedNamespace; + node: IntrospectedDirectAllocationConstructor, + ) => IntrospectedDirectAllocationConstructor + visitConstructorFunction?: (node: IntrospectedConstructor) => IntrospectedConstructor + visitRecord?: (node: IntrospectedRecord) => IntrospectedRecord + visitInterface?: (node: IntrospectedInterface) => IntrospectedInterface + visitEnumMember?: (node: GirEnumMember) => GirEnumMember + visitError?: (node: IntrospectedError) => IntrospectedError + visitEnum?: (node: IntrospectedEnum) => IntrospectedEnum + visitConst?: (node: IntrospectedConstant) => IntrospectedConstant + visitClass?: (node: IntrospectedClass) => IntrospectedClass + visitParameter?: (node: IntrospectedFunctionParameter) => IntrospectedFunctionParameter + visitProperty?: (node: IntrospectedProperty) => IntrospectedProperty + visitField?: (node: IntrospectedField) => IntrospectedField + visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal + visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction + visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction + visitStaticClassFunction?: (node: IntrospectedStaticClassFunction) => IntrospectedStaticClassFunction + visitVirtualClassFunction?: (node: IntrospectedVirtualClassFunction) => IntrospectedVirtualClassFunction + visitNamespace?: (node: IntrospectedNamespace) => IntrospectedNamespace } export function visit(namespace: IntrospectedNamespace, visitor: GirVisitor) { - namespace.accept(visitor); + namespace.accept(visitor) } diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json index f4b261da2..49f1430da 100644 --- a/packages/lib/tsconfig.json +++ b/packages/lib/tsconfig.json @@ -1,27 +1,22 @@ { - "compilerOptions": { - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "outDir": "lib", - "strict": true, - "noImplicitAny": false, - "strictNullChecks": true, - "noImplicitThis": true, - "alwaysStrict": true, - "esModuleInterop": true, - "moduleResolution": "node", - "sourceMap": true, - "rootDir": "src", - "resolveJsonModule": true, - "declaration": true, - "skipLibCheck": true, - }, - "include": ["src/**/*.ts", "src/**/*.tsx"], - "exclude": [ - "lib", - "node_modules", - "**/*.spec.ts", - "templates" - ] + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "outDir": "lib", + "strict": true, + "noImplicitAny": false, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "esModuleInterop": true, + "moduleResolution": "node", + "sourceMap": true, + "rootDir": "src", + "resolveJsonModule": true, + "declaration": true, + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["lib", "node_modules", "**/*.spec.ts", "templates"] } From 1828183f653f8e694b30f23d3493d2c2b1b2d5b7 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:52:48 -0800 Subject: [PATCH 13/53] yarn: Build parser package when building all packages --- package.json | 3 +- yarn.lock | 1370 +++++++++++++++++++------------------------------- 2 files changed, 533 insertions(+), 840 deletions(-) diff --git a/package.json b/package.json index 62b0de347..9707a6c0a 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,10 @@ "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:gjs:timezonemap1 && yarn validate:types:gjs", "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:gjs:rygelcore2 && yarn validate:types:gjs", "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gjs:gcalc && yarn validate:types:gjs", - "build": "yarn build:lib && yarn build:generators && yarn build:cli", + "build": "yarn build:parser && yarn build:lib && yarn build:generators && yarn build:cli", "build:cli": "yarn workspace @ts-for-gir/cli run build", "build:lib": "yarn workspace @ts-for-gir/lib run build", + "build:parser": "yarn workspace @gi.ts/parser run build", "build:generators": "yarn build:generator-base && yarn build:generator-typescript && yarn build:generator-html-doc", "build:generator-base": "yarn workspace @ts-for-gir/generator-base run build", "build:generator-typescript": "yarn workspace @ts-for-gir/generator-typescript run build", diff --git a/yarn.lock b/yarn.lock index f0bf4854f..3d94827d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -675,6 +675,23 @@ __metadata: languageName: node linkType: hard +"@eslint/eslintrc@npm:^2.1.2": + version: 2.1.2 + resolution: "@eslint/eslintrc@npm:2.1.2" + dependencies: + ajv: "npm:^6.12.4" + debug: "npm:^4.3.2" + espree: "npm:^9.6.0" + globals: "npm:^13.19.0" + ignore: "npm:^5.2.0" + import-fresh: "npm:^3.2.1" + js-yaml: "npm:^4.1.0" + minimatch: "npm:^3.1.2" + strip-json-comments: "npm:^3.1.1" + checksum: 10/fa25638f2666cac6810f98ee7d0f4b912f191806467c1b40d72bac759fffef0b3357f12a1869817286837b258e4de3517e0c7408520e156ca860fc53a1fbaed9 + languageName: node + linkType: hard + "@eslint/eslintrc@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/eslintrc@npm:2.1.4" @@ -692,6 +709,13 @@ __metadata: languageName: node linkType: hard +"@eslint/js@npm:8.52.0": + version: 8.52.0 + resolution: "@eslint/js@npm:8.52.0" + checksum: 10/86beff213d0ae4ced203a922b74e2cc4d767d109e7815f985bf648946ba072198977102e32afc9fa04f7825a6de83a831874f6b6675ba0c1d0743ade2dc2d53d + languageName: node + linkType: hard + "@eslint/js@npm:8.56.0": version: 8.56.0 resolution: "@eslint/js@npm:8.56.0" @@ -699,13 +723,6 @@ __metadata: languageName: node linkType: hard -"@gar/promisify@npm:^1.1.3": - version: 1.1.3 - resolution: "@gar/promisify@npm:1.1.3" - checksum: 10/052dd232140fa60e81588000cbe729a40146579b361f1070bce63e2a761388a22a16d00beeffc504bd3601cb8e055c57b21a185448b3ed550cf50716f4fd442e - languageName: node - linkType: hard - "@gi.ts/parser@workspace:^, @gi.ts/parser@workspace:packages/parser": version: 0.0.0-use.local resolution: "@gi.ts/parser@workspace:packages/parser" @@ -832,25 +849,6 @@ __metadata: languageName: node linkType: hard -"@mapbox/node-pre-gyp@npm:^1.0.10": - version: 1.0.11 - resolution: "@mapbox/node-pre-gyp@npm:1.0.11" - dependencies: - detect-libc: "npm:^2.0.0" - https-proxy-agent: "npm:^5.0.0" - make-dir: "npm:^3.1.0" - node-fetch: "npm:^2.6.7" - nopt: "npm:^5.0.0" - npmlog: "npm:^5.0.1" - rimraf: "npm:^3.0.2" - semver: "npm:^7.3.5" - tar: "npm:^6.1.11" - bin: - node-pre-gyp: bin/node-pre-gyp - checksum: 10/59529a2444e44fddb63057152452b00705aa58059079191126c79ac1388ae4565625afa84ed4dd1bf017d1111ab6e47907f7c5192e06d83c9496f2f3e708680a - languageName: node - linkType: hard - "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -891,16 +889,6 @@ __metadata: languageName: node linkType: hard -"@npmcli/fs@npm:^2.1.0": - version: 2.1.2 - resolution: "@npmcli/fs@npm:2.1.2" - dependencies: - "@gar/promisify": "npm:^1.1.3" - semver: "npm:^7.3.5" - checksum: 10/c5d4dfee80de2236e1e4ed595d17e217aada72ebd8215183fc46096fa010f583dd2aaaa486758de7cc0b89440dbc31cfe8b276269d75d47af35c716e896f78ec - languageName: node - linkType: hard - "@npmcli/fs@npm:^3.1.0": version: 3.1.0 resolution: "@npmcli/fs@npm:3.1.0" @@ -910,16 +898,6 @@ __metadata: languageName: node linkType: hard -"@npmcli/move-file@npm:^2.0.0": - version: 2.0.1 - resolution: "@npmcli/move-file@npm:2.0.1" - dependencies: - mkdirp: "npm:^1.0.4" - rimraf: "npm:^3.0.2" - checksum: 10/52dc02259d98da517fae4cb3a0a3850227bdae4939dda1980b788a7670636ca2b4a01b58df03dd5f65c1e3cb70c50fa8ce5762b582b3f499ec30ee5ce1fd9380 - languageName: node - linkType: hard - "@pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0" @@ -934,6 +912,20 @@ __metadata: languageName: node linkType: hard +"@pkgr/utils@npm:^2.3.1": + version: 2.4.2 + resolution: "@pkgr/utils@npm:2.4.2" + dependencies: + cross-spawn: "npm:^7.0.3" + fast-glob: "npm:^3.3.0" + is-glob: "npm:^4.0.3" + open: "npm:^9.1.0" + picocolors: "npm:^1.0.0" + tslib: "npm:^2.6.0" + checksum: 10/f0b0b305a83bd65fac5637d28ad3e33f19194043e03ceef6b4e13d260bfa2678b73df76dc56ed906469ffe0494d4bd214e6b92ca80684f38547982edf982dd15 + languageName: node + linkType: hard + "@rollup/plugin-babel@npm:^6.0.4": version: 6.0.4 resolution: "@rollup/plugin-babel@npm:6.0.4" @@ -1144,13 +1136,6 @@ __metadata: languageName: node linkType: hard -"@tootallnate/once@npm:2": - version: 2.0.0 - resolution: "@tootallnate/once@npm:2.0.0" - checksum: 10/ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 - languageName: node - linkType: hard - "@ts-for-gir/cli@workspace:^, @ts-for-gir/cli@workspace:packages/cli": version: 0.0.0-use.local resolution: "@ts-for-gir/cli@workspace:packages/cli" @@ -1430,6 +1415,31 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:^6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/eslint-plugin@npm:6.9.1" + dependencies: + "@eslint-community/regexpp": "npm:^4.5.1" + "@typescript-eslint/scope-manager": "npm:6.9.1" + "@typescript-eslint/type-utils": "npm:6.9.1" + "@typescript-eslint/utils": "npm:6.9.1" + "@typescript-eslint/visitor-keys": "npm:6.9.1" + debug: "npm:^4.3.4" + graphemer: "npm:^1.4.0" + ignore: "npm:^5.2.4" + natural-compare: "npm:^1.4.0" + semver: "npm:^7.5.4" + ts-api-utils: "npm:^1.0.1" + peerDependencies: + "@typescript-eslint/parser": ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/10a75e072be6645edd6fd74b200f3a3ee23e2ebb04a93d8e9be70f0a34dd94572146433a0a0f2732e9667ab8bdb2037d6d4261c10474fd94cfa9c56d02546215 + languageName: node + linkType: hard + "@typescript-eslint/eslint-plugin@npm:^7.0.1": version: 7.0.1 resolution: "@typescript-eslint/eslint-plugin@npm:7.0.1" @@ -1455,6 +1465,24 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/parser@npm:^6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/parser@npm:6.9.1" + dependencies: + "@typescript-eslint/scope-manager": "npm:6.9.1" + "@typescript-eslint/types": "npm:6.9.1" + "@typescript-eslint/typescript-estree": "npm:6.9.1" + "@typescript-eslint/visitor-keys": "npm:6.9.1" + debug: "npm:^4.3.4" + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/855a62180ad54f5a05ae4f15742e810b811aeceacd5be5a3498aeb11bd5c7877d25d4f7dc56d010a7b3ad2992e85f31d41340fb46a7fd68fc682ae65d82304d1 + languageName: node + linkType: hard + "@typescript-eslint/parser@npm:^7.0.1": version: 7.0.1 resolution: "@typescript-eslint/parser@npm:7.0.1" @@ -1473,6 +1501,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/scope-manager@npm:6.9.1" + dependencies: + "@typescript-eslint/types": "npm:6.9.1" + "@typescript-eslint/visitor-keys": "npm:6.9.1" + checksum: 10/a9ca328e42fbadaeffaed807c141d71f01d471b1aeeb1abbb107a0fe630963a33aeb6e215cb26874a01bee9589e8d773ad7a7fea7b14b9710d30dd1e0d6f6820 + languageName: node + linkType: hard + "@typescript-eslint/scope-manager@npm:7.0.1": version: 7.0.1 resolution: "@typescript-eslint/scope-manager@npm:7.0.1" @@ -1483,6 +1521,23 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/type-utils@npm:6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/type-utils@npm:6.9.1" + dependencies: + "@typescript-eslint/typescript-estree": "npm:6.9.1" + "@typescript-eslint/utils": "npm:6.9.1" + debug: "npm:^4.3.4" + ts-api-utils: "npm:^1.0.1" + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/cad9502565d9b0f203a4fa2a37f31cdde9734d050fa5324b7403d55d5125a891d0e8b6a8b2a1c0039b47b64f187219cc7fe37b905f48dee576b3b0e73f76a79c + languageName: node + linkType: hard + "@typescript-eslint/type-utils@npm:7.0.1": version: 7.0.1 resolution: "@typescript-eslint/type-utils@npm:7.0.1" @@ -1500,6 +1555,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/types@npm:6.9.1" + checksum: 10/28bf79fc9e30cafa1d747f20f95b2ce949816312bb9e1f4b0a4add6537fcf70a2b64c0da17b03c4cf70bf415263077de6edbd49ad08e482e9270454f2c61e1a3 + languageName: node + linkType: hard + "@typescript-eslint/types@npm:7.0.1": version: 7.0.1 resolution: "@typescript-eslint/types@npm:7.0.1" @@ -1507,6 +1569,24 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/typescript-estree@npm:6.9.1" + dependencies: + "@typescript-eslint/types": "npm:6.9.1" + "@typescript-eslint/visitor-keys": "npm:6.9.1" + debug: "npm:^4.3.4" + globby: "npm:^11.1.0" + is-glob: "npm:^4.0.3" + semver: "npm:^7.5.4" + ts-api-utils: "npm:^1.0.1" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/40d1d654c3d7223c84e9340740bde95484ef246f5248cf9f6cd5ae308c79463b52c2b964f935ff68577fb0ea9d6862c9a8547e9430449e1f4eb3c53da2dbfc55 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:7.0.1": version: 7.0.1 resolution: "@typescript-eslint/typescript-estree@npm:7.0.1" @@ -1526,6 +1606,23 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/utils@npm:6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/utils@npm:6.9.1" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.4.0" + "@types/json-schema": "npm:^7.0.12" + "@types/semver": "npm:^7.5.0" + "@typescript-eslint/scope-manager": "npm:6.9.1" + "@typescript-eslint/types": "npm:6.9.1" + "@typescript-eslint/typescript-estree": "npm:6.9.1" + semver: "npm:^7.5.4" + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + checksum: 10/36432f0f170a81d5a6e6c8919b7d492e9be323310124e9a9d03aa64db7f32c381bc3e7f894cefc9c2b427b0a6df95613477c2a00808911a7b8e95a37fcce54a1 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:7.0.1": version: 7.0.1 resolution: "@typescript-eslint/utils@npm:7.0.1" @@ -1543,6 +1640,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:6.9.1": + version: 6.9.1 + resolution: "@typescript-eslint/visitor-keys@npm:6.9.1" + dependencies: + "@typescript-eslint/types": "npm:6.9.1" + eslint-visitor-keys: "npm:^3.4.1" + checksum: 10/46d8a3335777798d43b9bf3393b96176881794184faf831670e4ee52493834cd6fbd3199ff387112ae795e344e3c92a8e78f79254d6c5bee012354859c8f333b + languageName: node + linkType: hard + "@typescript-eslint/visitor-keys@npm:7.0.1": version: 7.0.1 resolution: "@typescript-eslint/visitor-keys@npm:7.0.1" @@ -1758,13 +1865,6 @@ __metadata: languageName: node linkType: hard -"abbrev@npm:1, abbrev@npm:^1.0.0": - version: 1.1.1 - resolution: "abbrev@npm:1.1.1" - checksum: 10/2d882941183c66aa665118bafdab82b7a177e9add5eb2776c33e960a4f3c89cff88a1b38aba13a456de01d0dd9d66a8bea7c903268b21ea91dd1097e1e2e8243 - languageName: node - linkType: hard - "abbrev@npm:^2.0.0": version: 2.0.0 resolution: "abbrev@npm:2.0.0" @@ -1806,15 +1906,6 @@ __metadata: languageName: node linkType: hard -"agent-base@npm:6, agent-base@npm:^6.0.2": - version: 6.0.2 - resolution: "agent-base@npm:6.0.2" - dependencies: - debug: "npm:4" - checksum: 10/21fb903e0917e5cb16591b4d0ef6a028a54b83ac30cd1fca58dece3d4e0990512a8723f9f83130d88a41e2af8b1f7be1386fda3ea2d181bb1a62155e75e95e23 - languageName: node - linkType: hard - "agent-base@npm:^7.0.2, agent-base@npm:^7.1.0": version: 7.1.0 resolution: "agent-base@npm:7.1.0" @@ -1824,15 +1915,6 @@ __metadata: languageName: node linkType: hard -"agentkeepalive@npm:^4.2.1": - version: 4.5.0 - resolution: "agentkeepalive@npm:4.5.0" - dependencies: - humanize-ms: "npm:^1.2.1" - checksum: 10/dd210ba2a2e2482028f027b1156789744aadbfd773a6c9dd8e4e8001930d5af82382abe19a69240307b1d8003222ce6b0542935038313434b900e351914fc15f - languageName: node - linkType: hard - "aggregate-error@npm:^3.0.0": version: 3.1.0 resolution: "aggregate-error@npm:3.1.0" @@ -1922,33 +2004,6 @@ __metadata: languageName: node linkType: hard -"aproba@npm:^1.0.3 || ^2.0.0": - version: 2.0.0 - resolution: "aproba@npm:2.0.0" - checksum: 10/c2b9a631298e8d6f3797547e866db642f68493808f5b37cd61da778d5f6ada890d16f668285f7d60bd4fc3b03889bd590ffe62cf81b700e9bb353431238a0a7b - languageName: node - linkType: hard - -"are-we-there-yet@npm:^2.0.0": - version: 2.0.0 - resolution: "are-we-there-yet@npm:2.0.0" - dependencies: - delegates: "npm:^1.0.0" - readable-stream: "npm:^3.6.0" - checksum: 10/ea6f47d14fc33ae9cbea3e686eeca021d9d7b9db83a306010dd04ad5f2c8b7675291b127d3fcbfcbd8fec26e47b3324ad5b469a6cc3733a582f2fe4e12fc6756 - languageName: node - linkType: hard - -"are-we-there-yet@npm:^3.0.0": - version: 3.0.1 - resolution: "are-we-there-yet@npm:3.0.1" - dependencies: - delegates: "npm:^1.0.0" - readable-stream: "npm:^3.6.0" - checksum: 10/390731720e1bf9ed5d0efc635ea7df8cbc4c90308b0645a932f06e8495a0bf1ecc7987d3b97e805f62a17d6c4b634074b25200aa4d149be2a7b17250b9744bc4 - languageName: node - linkType: hard - "arg@npm:^4.1.0": version: 4.1.3 resolution: "arg@npm:4.1.3" @@ -1977,13 +2032,6 @@ __metadata: languageName: node linkType: hard -"available-typed-arrays@npm:^1.0.5": - version: 1.0.5 - resolution: "available-typed-arrays@npm:1.0.5" - checksum: 10/4d4d5e86ea0425696f40717882f66a570647b94ac8d273ddc7549a9b61e5da099e149bf431530ccbd776bd74e02039eb8b5edf426e3e2211ee61af16698a9064 - languageName: node - linkType: hard - "balanced-match@npm:^1.0.0": version: 1.0.2 resolution: "balanced-match@npm:1.0.2" @@ -1998,6 +2046,13 @@ __metadata: languageName: node linkType: hard +"big-integer@npm:^1.6.44": + version: 1.6.51 + resolution: "big-integer@npm:1.6.51" + checksum: 10/c7a12640901906d6f6b6bdb42a4eaba9578397b6d9a0dd090cf001ec813ff2bfcd441e364068ea0416db6175d2615f8ed19cff7d1a795115bf7c92d44993f991 + languageName: node + linkType: hard + "big.js@npm:^5.2.2": version: 5.2.2 resolution: "big.js@npm:5.2.2" @@ -2023,6 +2078,15 @@ __metadata: languageName: node linkType: hard +"bplist-parser@npm:^0.2.0": + version: 0.2.0 + resolution: "bplist-parser@npm:0.2.0" + dependencies: + big-integer: "npm:^1.6.44" + checksum: 10/15d31c1b0c7e0fb384e96349453879a33609d92d91b55a9ccee04b4be4b0645f1c823253d73326a1a23104521fbc45c2dd97fb05adf61863841b68cbb2ca7a3d + languageName: node + linkType: hard + "brace-expansion@npm:^1.1.7": version: 1.1.11 resolution: "brace-expansion@npm:1.1.11" @@ -2096,29 +2160,12 @@ __metadata: languageName: node linkType: hard -"cacache@npm:^16.1.0": - version: 16.1.3 - resolution: "cacache@npm:16.1.3" +"bundle-name@npm:^3.0.0": + version: 3.0.0 + resolution: "bundle-name@npm:3.0.0" dependencies: - "@npmcli/fs": "npm:^2.1.0" - "@npmcli/move-file": "npm:^2.0.0" - chownr: "npm:^2.0.0" - fs-minipass: "npm:^2.1.0" - glob: "npm:^8.0.1" - infer-owner: "npm:^1.0.4" - lru-cache: "npm:^7.7.1" - minipass: "npm:^3.1.6" - minipass-collect: "npm:^1.0.2" - minipass-flush: "npm:^1.0.5" - minipass-pipeline: "npm:^1.2.4" - mkdirp: "npm:^1.0.4" - p-map: "npm:^4.0.0" - promise-inflight: "npm:^1.0.1" - rimraf: "npm:^3.0.2" - ssri: "npm:^9.0.0" - tar: "npm:^6.1.11" - unique-filename: "npm:^2.0.0" - checksum: 10/a14524d90e377ee691d63a81173b33c473f8bc66eb299c64290b58e1d41b28842397f8d6c15a01b4c57ca340afcec019ae112a45c2f67a79f76130d326472e92 + run-applescript: "npm:^5.0.0" + checksum: 10/edf2b1fbe6096ed32e7566947ace2ea937ee427391744d7510a2880c4b9a5b3543d3f6c551236a29e5c87d3195f8e2912516290e638c15bcbede7b37cc375615 languageName: node linkType: hard @@ -2142,17 +2189,6 @@ __metadata: languageName: node linkType: hard -"call-bind@npm:^1.0.2, call-bind@npm:^1.0.4": - version: 1.0.5 - resolution: "call-bind@npm:1.0.5" - dependencies: - function-bind: "npm:^1.1.2" - get-intrinsic: "npm:^1.2.1" - set-function-length: "npm:^1.1.1" - checksum: 10/246d44db6ef9bbd418828dbd5337f80b46be4398d522eded015f31554cbb2ea33025b0203b75c7ab05a1a255b56ef218880cca1743e4121e306729f9e414da39 - languageName: node - linkType: hard - "call-bind@npm:^1.0.5": version: 1.0.7 resolution: "call-bind@npm:1.0.7" @@ -2346,15 +2382,6 @@ __metadata: languageName: node linkType: hard -"color-support@npm:^1.1.2, color-support@npm:^1.1.3": - version: 1.1.3 - resolution: "color-support@npm:1.1.3" - bin: - color-support: bin.js - checksum: 10/4bcfe30eea1498fe1cabc852bbda6c9770f230ea0e4faf4611c5858b1b9e4dde3730ac485e65f54ca182f4c50b626c1bea7c8441ceda47367a54a818c248aa7a - languageName: node - linkType: hard - "colorette@npm:^2.0.14, colorette@npm:^2.0.20": version: 2.0.20 resolution: "colorette@npm:2.0.20" @@ -2403,13 +2430,6 @@ __metadata: languageName: node linkType: hard -"console-control-strings@npm:^1.0.0, console-control-strings@npm:^1.1.0": - version: 1.1.0 - resolution: "console-control-strings@npm:1.1.0" - checksum: 10/27b5fa302bc8e9ae9e98c03c66d76ca289ad0c61ce2fe20ab288d288bee875d217512d2edb2363fc83165e88f1c405180cf3f5413a46e51b4fe1a004840c6cdb - languageName: node - linkType: hard - "convert-source-map@npm:^2.0.0": version: 2.0.0 resolution: "convert-source-map@npm:2.0.0" @@ -2478,7 +2498,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -2504,6 +2524,28 @@ __metadata: languageName: node linkType: hard +"default-browser-id@npm:^3.0.0": + version: 3.0.0 + resolution: "default-browser-id@npm:3.0.0" + dependencies: + bplist-parser: "npm:^0.2.0" + untildify: "npm:^4.0.0" + checksum: 10/279c7ad492542e5556336b6c254a4eaf31b2c63a5433265655ae6e47301197b6cfb15c595a6fdc6463b2ff8e1a1a1ed3cba56038a60e1527ba4ab1628c6b9941 + languageName: node + linkType: hard + +"default-browser@npm:^4.0.0": + version: 4.0.0 + resolution: "default-browser@npm:4.0.0" + dependencies: + bundle-name: "npm:^3.0.0" + default-browser-id: "npm:^3.0.0" + execa: "npm:^7.1.1" + titleize: "npm:^3.0.0" + checksum: 10/40c5af984799042b140300be5639c9742599bda76dc9eba5ac9ad5943c83dd36cebc4471eafcfddf8e0ec817166d5ba89d56f08e66a126c7c7908a179cead1a7 + languageName: node + linkType: hard + "defaults@npm:^1.0.3": version: 1.0.4 resolution: "defaults@npm:1.0.4" @@ -2513,17 +2555,6 @@ __metadata: languageName: node linkType: hard -"define-data-property@npm:^1.1.1": - version: 1.1.1 - resolution: "define-data-property@npm:1.1.1" - dependencies: - get-intrinsic: "npm:^1.2.1" - gopd: "npm:^1.0.1" - has-property-descriptors: "npm:^1.0.0" - checksum: 10/5573c8df96b5857408cad64d9b91b69152e305ce4b06218e5f49b59c6cafdbb90a8bd8a0bb83c7bc67a8d479c04aa697063c9bc28d849b7282f9327586d6bc7b - languageName: node - linkType: hard - "define-data-property@npm:^1.1.2": version: 1.1.4 resolution: "define-data-property@npm:1.1.4" @@ -2535,17 +2566,10 @@ __metadata: languageName: node linkType: hard -"delegates@npm:^1.0.0": - version: 1.0.0 - resolution: "delegates@npm:1.0.0" - checksum: 10/a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd - languageName: node - linkType: hard - -"detect-libc@npm:^2.0.0": - version: 2.0.2 - resolution: "detect-libc@npm:2.0.2" - checksum: 10/6118f30c0c425b1e56b9d2609f29bec50d35a6af0b762b6ad127271478f3bbfda7319ce869230cf1a351f2b219f39332cde290858553336d652c77b970f15de8 +"define-lazy-prop@npm:^3.0.0": + version: 3.0.0 + resolution: "define-lazy-prop@npm:3.0.0" + checksum: 10/f28421cf9ee86eecaf5f3b8fe875f13d7009c2625e97645bfff7a2a49aca678270b86c39f9c32939e5ca7ab96b551377ed4139558c795e076774287ad3af1aa4 languageName: node linkType: hard @@ -2879,6 +2903,17 @@ __metadata: languageName: node linkType: hard +"eslint-config-prettier@npm:^9.0.0": + version: 9.0.0 + resolution: "eslint-config-prettier@npm:9.0.0" + peerDependencies: + eslint: ">=7.0.0" + bin: + eslint-config-prettier: bin/cli.js + checksum: 10/276b0b5b5b19066962a9ff3a16a553bdad28e1c0a2ea33a1d75d65c0428bb7b37f6e85ac111ebefcc9bdefb544385856dbe6eaeda5279c639e5549c113d27dda + languageName: node + linkType: hard + "eslint-config-prettier@npm:^9.1.0": version: 9.1.0 resolution: "eslint-config-prettier@npm:9.1.0" @@ -2890,6 +2925,25 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-prettier@npm:^5.0.1": + version: 5.0.1 + resolution: "eslint-plugin-prettier@npm:5.0.1" + dependencies: + prettier-linter-helpers: "npm:^1.0.0" + synckit: "npm:^0.8.5" + peerDependencies: + "@types/eslint": ">=8.0.0" + eslint: ">=8.0.0" + prettier: ">=3.0.0" + peerDependenciesMeta: + "@types/eslint": + optional: true + eslint-config-prettier: + optional: true + checksum: 10/1a43dcca90f61fde0167347e0e870b579835ba6b9d697a862c29c76097a7bb0e8f07a7cf88be33517ca11203d9d4aa335d794c377640c2fe5acd06871db67d34 + languageName: node + linkType: hard + "eslint-plugin-prettier@npm:^5.1.3": version: 5.1.3 resolution: "eslint-plugin-prettier@npm:5.1.3" @@ -2937,14 +2991,14 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.56.0": - version: 8.56.0 - resolution: "eslint@npm:8.56.0" +"eslint@npm:^8.52.0": + version: 8.52.0 + resolution: "eslint@npm:8.52.0" dependencies: "@eslint-community/eslint-utils": "npm:^4.2.0" "@eslint-community/regexpp": "npm:^4.6.1" - "@eslint/eslintrc": "npm:^2.1.4" - "@eslint/js": "npm:8.56.0" + "@eslint/eslintrc": "npm:^2.1.2" + "@eslint/js": "npm:8.52.0" "@humanwhocodes/config-array": "npm:^0.11.13" "@humanwhocodes/module-importer": "npm:^1.0.1" "@nodelib/fs.walk": "npm:^1.2.8" @@ -2981,31 +3035,79 @@ __metadata: text-table: "npm:^0.2.0" bin: eslint: bin/eslint.js - checksum: 10/ef6193c6e4cef20774b985a5cc2fd4bf6d3c4decd423117cbc4a0196617861745db291217ad3c537bc3a160650cca965bc818f55e1f3e446af1fcb293f9940a5 - languageName: node - linkType: hard - -"espree@npm:^9.6.0, espree@npm:^9.6.1": - version: 9.6.1 - resolution: "espree@npm:9.6.1" - dependencies: - acorn: "npm:^8.9.0" - acorn-jsx: "npm:^5.3.2" - eslint-visitor-keys: "npm:^3.4.1" - checksum: 10/255ab260f0d711a54096bdeda93adff0eadf02a6f9b92f02b323e83a2b7fc258797919437ad331efec3930475feb0142c5ecaaf3cdab4befebd336d47d3f3134 + checksum: 10/01784ab15351d749bc95446039ed7acd5124f7cc84acdbf98c7199272eae06212a8f3ea4a9b47e7cc54ab17ca094c3a664bbfc3002c7de27936220e278b5028a languageName: node linkType: hard -"esquery@npm:^1.4.2": - version: 1.5.0 - resolution: "esquery@npm:1.5.0" +"eslint@npm:^8.56.0": + version: 8.56.0 + resolution: "eslint@npm:8.56.0" dependencies: - estraverse: "npm:^5.1.0" - checksum: 10/e65fcdfc1e0ff5effbf50fb4f31ea20143ae5df92bb2e4953653d8d40aa4bc148e0d06117a592ce4ea53eeab1dafdfded7ea7e22a5be87e82d73757329a1b01d - languageName: node - linkType: hard - -"esrecurse@npm:^4.3.0": + "@eslint-community/eslint-utils": "npm:^4.2.0" + "@eslint-community/regexpp": "npm:^4.6.1" + "@eslint/eslintrc": "npm:^2.1.4" + "@eslint/js": "npm:8.56.0" + "@humanwhocodes/config-array": "npm:^0.11.13" + "@humanwhocodes/module-importer": "npm:^1.0.1" + "@nodelib/fs.walk": "npm:^1.2.8" + "@ungap/structured-clone": "npm:^1.2.0" + ajv: "npm:^6.12.4" + chalk: "npm:^4.0.0" + cross-spawn: "npm:^7.0.2" + debug: "npm:^4.3.2" + doctrine: "npm:^3.0.0" + escape-string-regexp: "npm:^4.0.0" + eslint-scope: "npm:^7.2.2" + eslint-visitor-keys: "npm:^3.4.3" + espree: "npm:^9.6.1" + esquery: "npm:^1.4.2" + esutils: "npm:^2.0.2" + fast-deep-equal: "npm:^3.1.3" + file-entry-cache: "npm:^6.0.1" + find-up: "npm:^5.0.0" + glob-parent: "npm:^6.0.2" + globals: "npm:^13.19.0" + graphemer: "npm:^1.4.0" + ignore: "npm:^5.2.0" + imurmurhash: "npm:^0.1.4" + is-glob: "npm:^4.0.0" + is-path-inside: "npm:^3.0.3" + js-yaml: "npm:^4.1.0" + json-stable-stringify-without-jsonify: "npm:^1.0.1" + levn: "npm:^0.4.1" + lodash.merge: "npm:^4.6.2" + minimatch: "npm:^3.1.2" + natural-compare: "npm:^1.4.0" + optionator: "npm:^0.9.3" + strip-ansi: "npm:^6.0.1" + text-table: "npm:^0.2.0" + bin: + eslint: bin/eslint.js + checksum: 10/ef6193c6e4cef20774b985a5cc2fd4bf6d3c4decd423117cbc4a0196617861745db291217ad3c537bc3a160650cca965bc818f55e1f3e446af1fcb293f9940a5 + languageName: node + linkType: hard + +"espree@npm:^9.6.0, espree@npm:^9.6.1": + version: 9.6.1 + resolution: "espree@npm:9.6.1" + dependencies: + acorn: "npm:^8.9.0" + acorn-jsx: "npm:^5.3.2" + eslint-visitor-keys: "npm:^3.4.1" + checksum: 10/255ab260f0d711a54096bdeda93adff0eadf02a6f9b92f02b323e83a2b7fc258797919437ad331efec3930475feb0142c5ecaaf3cdab4befebd336d47d3f3134 + languageName: node + linkType: hard + +"esquery@npm:^1.4.2": + version: 1.5.0 + resolution: "esquery@npm:1.5.0" + dependencies: + estraverse: "npm:^5.1.0" + checksum: 10/e65fcdfc1e0ff5effbf50fb4f31ea20143ae5df92bb2e4953653d8d40aa4bc148e0d06117a592ce4ea53eeab1dafdfded7ea7e22a5be87e82d73757329a1b01d + languageName: node + linkType: hard + +"esrecurse@npm:^4.3.0": version: 4.3.0 resolution: "esrecurse@npm:4.3.0" dependencies: @@ -3049,6 +3151,40 @@ __metadata: languageName: node linkType: hard +"execa@npm:^5.0.0": + version: 5.1.1 + resolution: "execa@npm:5.1.1" + dependencies: + cross-spawn: "npm:^7.0.3" + get-stream: "npm:^6.0.0" + human-signals: "npm:^2.1.0" + is-stream: "npm:^2.0.0" + merge-stream: "npm:^2.0.0" + npm-run-path: "npm:^4.0.1" + onetime: "npm:^5.1.2" + signal-exit: "npm:^3.0.3" + strip-final-newline: "npm:^2.0.0" + checksum: 10/8ada91f2d70f7dff702c861c2c64f21dfdc1525628f3c0454fd6f02fce65f7b958616cbd2b99ca7fa4d474e461a3d363824e91b3eb881705231abbf387470597 + languageName: node + linkType: hard + +"execa@npm:^7.1.1": + version: 7.2.0 + resolution: "execa@npm:7.2.0" + dependencies: + cross-spawn: "npm:^7.0.3" + get-stream: "npm:^6.0.1" + human-signals: "npm:^4.3.0" + is-stream: "npm:^3.0.0" + merge-stream: "npm:^2.0.0" + npm-run-path: "npm:^5.1.0" + onetime: "npm:^6.0.0" + signal-exit: "npm:^3.0.7" + strip-final-newline: "npm:^3.0.0" + checksum: 10/473feff60f9d4dbe799225948de48b5158c1723021d19c4b982afe37bcd111ae84e1b4c9dfe967fae5101b0894b1a62e4dd564a286dfa3e46d7b0cfdbf7fe62b + languageName: node + linkType: hard + "exponential-backoff@npm:^3.1.1": version: 3.1.1 resolution: "exponential-backoff@npm:3.1.1" @@ -3081,7 +3217,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.9": +"fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": version: 3.3.1 resolution: "fast-glob@npm:3.3.1" dependencies: @@ -3218,15 +3354,6 @@ __metadata: languageName: node linkType: hard -"for-each@npm:^0.3.3": - version: 0.3.3 - resolution: "for-each@npm:0.3.3" - dependencies: - is-callable: "npm:^1.1.3" - checksum: 10/fdac0cde1be35610bd635ae958422e8ce0cc1313e8d32ea6d34cfda7b60850940c1fd07c36456ad76bd9c24aef6ff5e03b02beb58c83af5ef6c968a64eada676 - languageName: node - linkType: hard - "foreground-child@npm:^3.1.0": version: 3.1.1 resolution: "foreground-child@npm:3.1.1" @@ -3271,7 +3398,7 @@ __metadata: languageName: node linkType: hard -"fs-minipass@npm:^2.0.0, fs-minipass@npm:^2.1.0": +"fs-minipass@npm:^2.0.0": version: 2.1.0 resolution: "fs-minipass@npm:2.1.0" dependencies: @@ -3329,39 +3456,6 @@ __metadata: languageName: node linkType: hard -"gauge@npm:^3.0.0": - version: 3.0.2 - resolution: "gauge@npm:3.0.2" - dependencies: - aproba: "npm:^1.0.3 || ^2.0.0" - color-support: "npm:^1.1.2" - console-control-strings: "npm:^1.0.0" - has-unicode: "npm:^2.0.1" - object-assign: "npm:^4.1.1" - signal-exit: "npm:^3.0.0" - string-width: "npm:^4.2.3" - strip-ansi: "npm:^6.0.1" - wide-align: "npm:^1.1.2" - checksum: 10/46df086451672a5fecd58f7ec86da74542c795f8e00153fbef2884286ce0e86653c3eb23be2d0abb0c4a82b9b2a9dec3b09b6a1cf31c28085fa0376599a26589 - languageName: node - linkType: hard - -"gauge@npm:^4.0.3": - version: 4.0.4 - resolution: "gauge@npm:4.0.4" - dependencies: - aproba: "npm:^1.0.3 || ^2.0.0" - color-support: "npm:^1.1.3" - console-control-strings: "npm:^1.1.0" - has-unicode: "npm:^2.0.1" - signal-exit: "npm:^3.0.7" - string-width: "npm:^4.2.3" - strip-ansi: "npm:^6.0.1" - wide-align: "npm:^1.1.5" - checksum: 10/09535dd53b5ced6a34482b1fa9f3929efdeac02f9858569cde73cef3ed95050e0f3d095706c1689614059898924b7a74aa14042f51381a1ccc4ee5c29d2389c4 - languageName: node - linkType: hard - "gensync@npm:^1.0.0-beta.2": version: 1.0.0-beta.2 resolution: "gensync@npm:1.0.0-beta.2" @@ -3376,7 +3470,7 @@ __metadata: languageName: node linkType: hard -"get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.1, get-intrinsic@npm:^1.2.2": +"get-intrinsic@npm:^1.1.3": version: 1.2.2 resolution: "get-intrinsic@npm:1.2.2" dependencies: @@ -3401,6 +3495,13 @@ __metadata: languageName: node linkType: hard +"get-stream@npm:^6.0.0, get-stream@npm:^6.0.1": + version: 6.0.1 + resolution: "get-stream@npm:6.0.1" + checksum: 10/781266d29725f35c59f1d214aedc92b0ae855800a980800e2923b3fbc4e56b3cb6e462c42e09a1cf1a00c64e056a78fa407cbe06c7c92b7e5cd49b4b85c2a497 + languageName: node + linkType: hard + "glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" @@ -3441,7 +3542,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.1.3, glob@npm:^7.1.4": +"glob@npm:^7.1.3": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: @@ -3455,19 +3556,6 @@ __metadata: languageName: node linkType: hard -"glob@npm:^8.0.1": - version: 8.1.0 - resolution: "glob@npm:8.1.0" - dependencies: - fs.realpath: "npm:^1.0.0" - inflight: "npm:^1.0.4" - inherits: "npm:2" - minimatch: "npm:^5.0.1" - once: "npm:^1.3.0" - checksum: 10/9aab1c75eb087c35dbc41d1f742e51d0507aa2b14c910d96fb8287107a10a22f4bbdce26fc0a3da4c69a20f7b26d62f1640b346a4f6e6becfff47f335bb1dc5e - languageName: node - linkType: hard - "globals@npm:^11.1.0": version: 11.12.0 resolution: "globals@npm:11.12.0" @@ -3549,15 +3637,6 @@ __metadata: languageName: node linkType: hard -"has-property-descriptors@npm:^1.0.0": - version: 1.0.1 - resolution: "has-property-descriptors@npm:1.0.1" - dependencies: - get-intrinsic: "npm:^1.2.2" - checksum: 10/21a47bb080a24e79594aef1ce71e1a18a1c5ab4120308e218088f67ebb7f6f408847541e2d96e5bd00e90eef5c5a49e4ebbdc8fc2d5b365a2c379aef071642f0 - languageName: node - linkType: hard - "has-property-descriptors@npm:^1.0.1": version: 1.0.2 resolution: "has-property-descriptors@npm:1.0.2" @@ -3574,29 +3653,13 @@ __metadata: languageName: node linkType: hard -"has-symbols@npm:^1.0.2, has-symbols@npm:^1.0.3": +"has-symbols@npm:^1.0.3": version: 1.0.3 resolution: "has-symbols@npm:1.0.3" checksum: 10/464f97a8202a7690dadd026e6d73b1ceeddd60fe6acfd06151106f050303eaa75855aaa94969df8015c11ff7c505f196114d22f7386b4a471038da5874cf5e9b languageName: node linkType: hard -"has-tostringtag@npm:^1.0.0": - version: 1.0.0 - resolution: "has-tostringtag@npm:1.0.0" - dependencies: - has-symbols: "npm:^1.0.2" - checksum: 10/95546e7132efc895a9ae64a8a7cf52588601fc3d52e0304ed228f336992cdf0baaba6f3519d2655e560467db35a1ed79f6420c286cc91a13aa0647a31ed92570 - languageName: node - linkType: hard - -"has-unicode@npm:^2.0.1": - version: 2.0.1 - resolution: "has-unicode@npm:2.0.1" - checksum: 10/041b4293ad6bf391e21c5d85ed03f412506d6623786b801c4ab39e4e6ca54993f13201bceb544d92963f9e0024e6e7fbf0cb1d84c9d6b31cb9c79c8c990d13d8 - languageName: node - linkType: hard - "hasown@npm:^2.0.0": version: 2.0.0 resolution: "hasown@npm:2.0.0" @@ -3606,24 +3669,13 @@ __metadata: languageName: node linkType: hard -"http-cache-semantics@npm:^4.1.0, http-cache-semantics@npm:^4.1.1": +"http-cache-semantics@npm:^4.1.1": version: 4.1.1 resolution: "http-cache-semantics@npm:4.1.1" checksum: 10/362d5ed66b12ceb9c0a328fb31200b590ab1b02f4a254a697dc796850cc4385603e75f53ec59f768b2dad3bfa1464bd229f7de278d2899a0e3beffc634b6683f languageName: node linkType: hard -"http-proxy-agent@npm:^5.0.0": - version: 5.0.0 - resolution: "http-proxy-agent@npm:5.0.0" - dependencies: - "@tootallnate/once": "npm:2" - agent-base: "npm:6" - debug: "npm:4" - checksum: 10/5ee19423bc3e0fd5f23ce991b0755699ad2a46a440ce9cec99e8126bb98448ad3479d2c0ea54be5519db5b19a4ffaa69616bac01540db18506dd4dac3dc418f0 - languageName: node - linkType: hard - "http-proxy-agent@npm:^7.0.0": version: 7.0.0 resolution: "http-proxy-agent@npm:7.0.0" @@ -3634,16 +3686,6 @@ __metadata: languageName: node linkType: hard -"https-proxy-agent@npm:^5.0.0": - version: 5.0.1 - resolution: "https-proxy-agent@npm:5.0.1" - dependencies: - agent-base: "npm:6" - debug: "npm:4" - checksum: 10/f0dce7bdcac5e8eaa0be3c7368bb8836ed010fb5b6349ffb412b172a203efe8f807d9a6681319105ea1b6901e1972c7b5ea899672a7b9aad58309f766dcbe0df - languageName: node - linkType: hard - "https-proxy-agent@npm:^7.0.1": version: 7.0.2 resolution: "https-proxy-agent@npm:7.0.2" @@ -3654,12 +3696,17 @@ __metadata: languageName: node linkType: hard -"humanize-ms@npm:^1.2.1": - version: 1.2.1 - resolution: "humanize-ms@npm:1.2.1" - dependencies: - ms: "npm:^2.0.0" - checksum: 10/9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 +"human-signals@npm:^2.1.0": + version: 2.1.0 + resolution: "human-signals@npm:2.1.0" + checksum: 10/df59be9e0af479036798a881d1f136c4a29e0b518d4abb863afbd11bf30efa3eeb1d0425fc65942dcc05ab3bf40205ea436b0ff389f2cd20b75b8643d539bf86 + languageName: node + linkType: hard + +"human-signals@npm:^4.3.0": + version: 4.3.1 + resolution: "human-signals@npm:4.3.1" + checksum: 10/fa59894c358fe9f2b5549be2fb083661d5e1dff618d3ac70a49ca73495a72e873fbf6c0878561478e521e17d498292746ee391791db95ffe5747bfb5aef8765b languageName: node linkType: hard @@ -3731,13 +3778,6 @@ __metadata: languageName: node linkType: hard -"infer-owner@npm:^1.0.4": - version: 1.0.4 - resolution: "infer-owner@npm:1.0.4" - checksum: 10/181e732764e4a0611576466b4b87dac338972b839920b2a8cde43642e4ed6bd54dc1fb0b40874728f2a2df9a1b097b8ff83b56d5f8f8e3927f837fdcb47d8a89 - languageName: node - linkType: hard - "inflight@npm:^1.0.4": version: 1.0.6 resolution: "inflight@npm:1.0.6" @@ -3792,16 +3832,6 @@ __metadata: languageName: node linkType: hard -"is-arguments@npm:^1.0.4": - version: 1.1.1 - resolution: "is-arguments@npm:1.1.1" - dependencies: - call-bind: "npm:^1.0.2" - has-tostringtag: "npm:^1.0.0" - checksum: 10/a170c7e26082e10de9be6e96d32ae3db4d5906194051b792e85fae3393b53cf2cb5b3557863e5c8ccbab55e2fd8f2f75aa643d437613f72052cf0356615c34be - languageName: node - linkType: hard - "is-arrayish@npm:^0.2.1": version: 0.2.1 resolution: "is-arrayish@npm:0.2.1" @@ -3818,13 +3848,6 @@ __metadata: languageName: node linkType: hard -"is-callable@npm:^1.1.3": - version: 1.2.7 - resolution: "is-callable@npm:1.2.7" - checksum: 10/48a9297fb92c99e9df48706241a189da362bff3003354aea4048bd5f7b2eb0d823cd16d0a383cece3d76166ba16d85d9659165ac6fcce1ac12e6c649d66dbdb9 - languageName: node - linkType: hard - "is-core-module@npm:^2.13.0": version: 2.13.1 resolution: "is-core-module@npm:2.13.1" @@ -3834,6 +3857,24 @@ __metadata: languageName: node linkType: hard +"is-docker@npm:^2.0.0": + version: 2.2.1 + resolution: "is-docker@npm:2.2.1" + bin: + is-docker: cli.js + checksum: 10/3fef7ddbf0be25958e8991ad941901bf5922ab2753c46980b60b05c1bf9c9c2402d35e6dc32e4380b980ef5e1970a5d9d5e5aa2e02d77727c3b6b5e918474c56 + languageName: node + linkType: hard + +"is-docker@npm:^3.0.0": + version: 3.0.0 + resolution: "is-docker@npm:3.0.0" + bin: + is-docker: cli.js + checksum: 10/b698118f04feb7eaf3338922bd79cba064ea54a1c3db6ec8c0c8d8ee7613e7e5854d802d3ef646812a8a3ace81182a085dfa0a71cc68b06f3fa794b9783b3c90 + languageName: node + linkType: hard + "is-extglob@npm:^2.1.1": version: 2.1.1 resolution: "is-extglob@npm:2.1.1" @@ -3848,15 +3889,6 @@ __metadata: languageName: node linkType: hard -"is-generator-function@npm:^1.0.7": - version: 1.0.10 - resolution: "is-generator-function@npm:1.0.10" - dependencies: - has-tostringtag: "npm:^1.0.0" - checksum: 10/499a3ce6361064c3bd27fbff5c8000212d48506ebe1977842bbd7b3e708832d0deb1f4cc69186ece3640770e8c4f1287b24d99588a0b8058b2dbdd344bc1f47f - languageName: node - linkType: hard - "is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": version: 4.0.3 resolution: "is-glob@npm:4.0.3" @@ -3866,6 +3898,17 @@ __metadata: languageName: node linkType: hard +"is-inside-container@npm:^1.0.0": + version: 1.0.0 + resolution: "is-inside-container@npm:1.0.0" + dependencies: + is-docker: "npm:^3.0.0" + bin: + is-inside-container: cli.js + checksum: 10/c50b75a2ab66ab3e8b92b3bc534e1ea72ca25766832c0623ac22d134116a98bcf012197d1caabe1d1c4bd5f84363d4aa5c36bb4b585fbcaf57be172cd10a1a03 + languageName: node + linkType: hard + "is-interactive@npm:^1.0.0": version: 1.0.0 resolution: "is-interactive@npm:1.0.0" @@ -3903,12 +3946,17 @@ __metadata: languageName: node linkType: hard -"is-typed-array@npm:^1.1.3": - version: 1.1.12 - resolution: "is-typed-array@npm:1.1.12" - dependencies: - which-typed-array: "npm:^1.1.11" - checksum: 10/d953adfd3c41618d5e01b2a10f21817e4cdc9572772fa17211100aebb3811b6e3c2e308a0558cc87d218a30504cb90154b833013437776551bfb70606fb088ca +"is-stream@npm:^2.0.0": + version: 2.0.1 + resolution: "is-stream@npm:2.0.1" + checksum: 10/b8e05ccdf96ac330ea83c12450304d4a591f9958c11fd17bed240af8d5ffe08aedafa4c0f4cfccd4d28dc9d4d129daca1023633d5c11601a6cbc77521f6fae66 + languageName: node + linkType: hard + +"is-stream@npm:^3.0.0": + version: 3.0.0 + resolution: "is-stream@npm:3.0.0" + checksum: 10/172093fe99119ffd07611ab6d1bcccfe8bc4aa80d864b15f43e63e54b7abc71e779acd69afdb854c4e2a67fdc16ae710e370eda40088d1cfc956a50ed82d8f16 languageName: node linkType: hard @@ -3919,6 +3967,15 @@ __metadata: languageName: node linkType: hard +"is-wsl@npm:^2.2.0": + version: 2.2.0 + resolution: "is-wsl@npm:2.2.0" + dependencies: + is-docker: "npm:^2.0.0" + checksum: 10/20849846ae414997d290b75e16868e5261e86ff5047f104027026fd61d8b5a9b0b3ade16239f35e1a067b3c7cc02f70183cb661010ed16f4b6c7c93dad1b19d8 + languageName: node + linkType: hard + "isexe@npm:^2.0.0": version: 2.0.0 resolution: "isexe@npm:2.0.0" @@ -4124,20 +4181,6 @@ __metadata: languageName: node linkType: hard -"lodash.camelcase@npm:4.3.0": - version: 4.3.0 - resolution: "lodash.camelcase@npm:4.3.0" - checksum: 10/c301cc379310441dc73cd6cebeb91fb254bea74e6ad3027f9346fc43b4174385153df420ffa521654e502fd34c40ef69ca4e7d40ee7129a99e06f306032bfc65 - languageName: node - linkType: hard - -"lodash.isequal@npm:4.5.0": - version: 4.5.0 - resolution: "lodash.isequal@npm:4.5.0" - checksum: 10/82fc58a83a1555f8df34ca9a2cd300995ff94018ac12cc47c349655f0ae1d4d92ba346db4c19bbfc90510764e0c00ddcc985a358bdcd4b3b965abf8f2a48a214 - languageName: node - linkType: hard - "lodash.merge@npm:^4.6.2": version: 4.6.2 resolution: "lodash.merge@npm:4.6.2" @@ -4145,13 +4188,6 @@ __metadata: languageName: node linkType: hard -"lodash.snakecase@npm:^4.1.1": - version: 4.1.1 - resolution: "lodash.snakecase@npm:4.1.1" - checksum: 10/82ed40935d840477ef8fee64f9f263f75989c6cde36b84aae817246d95826228e1b5a7f6093c51de324084f86433634c7af244cb89496633cacfe443071450d0 - languageName: node - linkType: hard - "lodash@npm:^4.17.21": version: 4.17.21 resolution: "lodash@npm:4.17.21" @@ -4194,22 +4230,6 @@ __metadata: languageName: node linkType: hard -"lru-cache@npm:^7.7.1": - version: 7.18.3 - resolution: "lru-cache@npm:7.18.3" - checksum: 10/6029ca5aba3aacb554e919d7ef804fffd4adfc4c83db00fac8248c7c78811fb6d4b6f70f7fd9d55032b3823446546a007edaa66ad1f2377ae833bd983fac5d98 - languageName: node - linkType: hard - -"make-dir@npm:^3.1.0": - version: 3.1.0 - resolution: "make-dir@npm:3.1.0" - dependencies: - semver: "npm:^6.0.0" - checksum: 10/484200020ab5a1fdf12f393fe5f385fc8e4378824c940fba1729dcd198ae4ff24867bc7a5646331e50cead8abff5d9270c456314386e629acec6dff4b8016b78 - languageName: node - linkType: hard - "make-error@npm:^1.1.1": version: 1.3.6 resolution: "make-error@npm:1.3.6" @@ -4217,30 +4237,6 @@ __metadata: languageName: node linkType: hard -"make-fetch-happen@npm:^10.0.3": - version: 10.2.1 - resolution: "make-fetch-happen@npm:10.2.1" - dependencies: - agentkeepalive: "npm:^4.2.1" - cacache: "npm:^16.1.0" - http-cache-semantics: "npm:^4.1.0" - http-proxy-agent: "npm:^5.0.0" - https-proxy-agent: "npm:^5.0.0" - is-lambda: "npm:^1.0.1" - lru-cache: "npm:^7.7.1" - minipass: "npm:^3.1.6" - minipass-collect: "npm:^1.0.2" - minipass-fetch: "npm:^2.0.3" - minipass-flush: "npm:^1.0.5" - minipass-pipeline: "npm:^1.2.4" - negotiator: "npm:^0.6.3" - promise-retry: "npm:^2.0.1" - socks-proxy-agent: "npm:^7.0.0" - ssri: "npm:^9.0.0" - checksum: 10/fef5acb865a46f25ad0b5ad7d979799125db5dbb24ea811ffa850fbb804bc8e495df2237a8ec3a4fc6250e73c2f95549cca6d6d36a73b1faa61224504eb1188f - languageName: node - linkType: hard - "make-fetch-happen@npm:^13.0.0": version: 13.0.0 resolution: "make-fetch-happen@npm:13.0.0" @@ -4316,6 +4312,13 @@ __metadata: languageName: node linkType: hard +"mimic-fn@npm:^4.0.0": + version: 4.0.0 + resolution: "mimic-fn@npm:4.0.0" + checksum: 10/995dcece15ee29aa16e188de6633d43a3db4611bcf93620e7e62109ec41c79c0f34277165b8ce5e361205049766e371851264c21ac64ca35499acb5421c2ba56 + languageName: node + linkType: hard + "minimatch@npm:9.0.3, minimatch@npm:^9.0.1": version: 9.0.3 resolution: "minimatch@npm:9.0.3" @@ -4352,21 +4355,6 @@ __metadata: languageName: node linkType: hard -"minipass-fetch@npm:^2.0.3": - version: 2.1.2 - resolution: "minipass-fetch@npm:2.1.2" - dependencies: - encoding: "npm:^0.1.13" - minipass: "npm:^3.1.6" - minipass-sized: "npm:^1.0.3" - minizlib: "npm:^2.1.2" - dependenciesMeta: - encoding: - optional: true - checksum: 10/8cfc589563ae2a11eebbf79121ef9a526fd078fca949ed3f1e4a51472ca4a4aad89fcea1738982ce9d7d833116ecc9c6ae9ebbd844832a94e3f4a3d4d1b9d3b9 - languageName: node - linkType: hard - "minipass-fetch@npm:^3.0.0": version: 3.0.4 resolution: "minipass-fetch@npm:3.0.4" @@ -4409,7 +4397,7 @@ __metadata: languageName: node linkType: hard -"minipass@npm:^3.0.0, minipass@npm:^3.1.1, minipass@npm:^3.1.6": +"minipass@npm:^3.0.0": version: 3.3.6 resolution: "minipass@npm:3.3.6" dependencies: @@ -4442,7 +4430,7 @@ __metadata: languageName: node linkType: hard -"mkdirp@npm:^1.0.3, mkdirp@npm:^1.0.4": +"mkdirp@npm:^1.0.3": version: 1.0.4 resolution: "mkdirp@npm:1.0.4" bin: @@ -4458,13 +4446,6 @@ __metadata: languageName: node linkType: hard -"ms@npm:^2.0.0": - version: 2.1.3 - resolution: "ms@npm:2.1.3" - checksum: 10/aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d - languageName: node - linkType: hard - "mute-stream@npm:1.0.0": version: 1.0.0 resolution: "mute-stream@npm:1.0.0" @@ -4472,15 +4453,6 @@ __metadata: languageName: node linkType: hard -"nan@npm:^2.17.0": - version: 2.18.0 - resolution: "nan@npm:2.18.0" - dependencies: - node-gyp: "npm:latest" - checksum: 10/5520e22c64e2b5b495b1d765d6334c989b848bbe1502fec89c5857cabcc7f9f0474563377259e7574bff1c8a041d3b90e9ffa1f5e15502ffddee7b2550cc26a0 - languageName: node - linkType: hard - "nanoid@npm:^3.3.7": version: 3.3.7 resolution: "nanoid@npm:3.3.7" @@ -4518,57 +4490,6 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^2.6.7": - version: 2.7.0 - resolution: "node-fetch@npm:2.7.0" - dependencies: - whatwg-url: "npm:^5.0.0" - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - checksum: 10/b24f8a3dc937f388192e59bcf9d0857d7b6940a2496f328381641cb616efccc9866e89ec43f2ec956bbd6c3d3ee05524ce77fe7b29ccd34692b3a16f237d6676 - languageName: node - linkType: hard - -"node-gtk@npm:^0.12.0": - version: 0.12.0 - resolution: "node-gtk@npm:0.12.0" - dependencies: - "@mapbox/node-pre-gyp": "npm:^1.0.10" - lodash.camelcase: "npm:4.3.0" - lodash.isequal: "npm:4.5.0" - lodash.snakecase: "npm:^4.1.1" - nan: "npm:^2.17.0" - node-gyp: "npm:^9.3.1" - remove-trailing-spaces: "npm:^1.0.7" - unindent: "npm:^2.0.0" - checksum: 10/aa020eaea1e7c3ffcde823ca0b67563b7414e7f9affca4ebd2edb210357159978a14fdc6087cef02fe99ba4be9ef4011f30f9a6a2354f09b80f5757d9eb5873c - languageName: node - linkType: hard - -"node-gyp@npm:^9.3.1": - version: 9.4.1 - resolution: "node-gyp@npm:9.4.1" - dependencies: - env-paths: "npm:^2.2.0" - exponential-backoff: "npm:^3.1.1" - glob: "npm:^7.1.4" - graceful-fs: "npm:^4.2.6" - make-fetch-happen: "npm:^10.0.3" - nopt: "npm:^6.0.0" - npmlog: "npm:^6.0.0" - rimraf: "npm:^3.0.2" - semver: "npm:^7.3.5" - tar: "npm:^6.1.2" - which: "npm:^2.0.2" - bin: - node-gyp: bin/node-gyp.js - checksum: 10/329b109b138e48cb0416a6bca56e171b0e479d6360a548b80f06eced4bef3cf37652a3d20d171c20023fb18d996bd7446a49d4297ddb59fc48100178a92f432d - languageName: node - linkType: hard - "node-gyp@npm:latest": version: 10.0.0 resolution: "node-gyp@npm:10.0.0" @@ -4596,28 +4517,6 @@ __metadata: languageName: node linkType: hard -"nopt@npm:^5.0.0": - version: 5.0.0 - resolution: "nopt@npm:5.0.0" - dependencies: - abbrev: "npm:1" - bin: - nopt: bin/nopt.js - checksum: 10/00f9bb2d16449469ba8ffcf9b8f0eae6bae285ec74b135fec533e5883563d2400c0cd70902d0a7759e47ac031ccf206ace4e86556da08ed3f1c66dda206e9ccd - languageName: node - linkType: hard - -"nopt@npm:^6.0.0": - version: 6.0.0 - resolution: "nopt@npm:6.0.0" - dependencies: - abbrev: "npm:^1.0.0" - bin: - nopt: bin/nopt.js - checksum: 10/3c1128e07cd0241ae66d6e6a472170baa9f3e84dd4203950ba8df5bafac4efa2166ce917a57ef02b01ba7c40d18b2cc64b29b225fd3640791fe07b24f0b33a32 - languageName: node - linkType: hard - "nopt@npm:^7.0.0": version: 7.2.0 resolution: "nopt@npm:7.2.0" @@ -4636,34 +4535,21 @@ __metadata: languageName: node linkType: hard -"npmlog@npm:^5.0.1": - version: 5.0.1 - resolution: "npmlog@npm:5.0.1" +"npm-run-path@npm:^4.0.1": + version: 4.0.1 + resolution: "npm-run-path@npm:4.0.1" dependencies: - are-we-there-yet: "npm:^2.0.0" - console-control-strings: "npm:^1.1.0" - gauge: "npm:^3.0.0" - set-blocking: "npm:^2.0.0" - checksum: 10/f42c7b9584cdd26a13c41a21930b6f5912896b6419ab15be88cc5721fc792f1c3dd30eb602b26ae08575694628ba70afdcf3675d86e4f450fc544757e52726ec + path-key: "npm:^3.0.0" + checksum: 10/5374c0cea4b0bbfdfae62da7bbdf1e1558d338335f4cacf2515c282ff358ff27b2ecb91ffa5330a8b14390ac66a1e146e10700440c1ab868208430f56b5f4d23 languageName: node linkType: hard -"npmlog@npm:^6.0.0": - version: 6.0.2 - resolution: "npmlog@npm:6.0.2" +"npm-run-path@npm:^5.1.0": + version: 5.1.0 + resolution: "npm-run-path@npm:5.1.0" dependencies: - are-we-there-yet: "npm:^3.0.0" - console-control-strings: "npm:^1.1.0" - gauge: "npm:^4.0.3" - set-blocking: "npm:^2.0.0" - checksum: 10/82b123677e62deb9e7472e27b92386c09e6e254ee6c8bcd720b3011013e4168bc7088e984f4fbd53cb6e12f8b4690e23e4fa6132689313e0d0dc4feea45489bb - languageName: node - linkType: hard - -"object-assign@npm:^4.1.1": - version: 4.1.1 - resolution: "object-assign@npm:4.1.1" - checksum: 10/fcc6e4ea8c7fe48abfbb552578b1c53e0d194086e2e6bbbf59e0a536381a292f39943c6e9628af05b5528aa5e3318bb30d6b2e53cadaf5b8fe9e12c4b69af23f + path-key: "npm:^4.0.0" + checksum: 10/dc184eb5ec239d6a2b990b43236845332ef12f4e0beaa9701de724aa797fe40b6bbd0157fb7639d24d3ab13f5d5cf22d223a19c6300846b8126f335f788bee66 languageName: node linkType: hard @@ -4676,7 +4562,7 @@ __metadata: languageName: node linkType: hard -"onetime@npm:^5.1.0": +"onetime@npm:^5.1.0, onetime@npm:^5.1.2": version: 5.1.2 resolution: "onetime@npm:5.1.2" dependencies: @@ -4685,6 +4571,27 @@ __metadata: languageName: node linkType: hard +"onetime@npm:^6.0.0": + version: 6.0.0 + resolution: "onetime@npm:6.0.0" + dependencies: + mimic-fn: "npm:^4.0.0" + checksum: 10/0846ce78e440841335d4e9182ef69d5762e9f38aa7499b19f42ea1c4cd40f0b4446094c455c713f9adac3f4ae86f613bb5e30c99e52652764d06a89f709b3788 + languageName: node + linkType: hard + +"open@npm:^9.1.0": + version: 9.1.0 + resolution: "open@npm:9.1.0" + dependencies: + default-browser: "npm:^4.0.0" + define-lazy-prop: "npm:^3.0.0" + is-inside-container: "npm:^1.0.0" + is-wsl: "npm:^2.2.0" + checksum: 10/b45bcc7a6795804a2f560f0ca9f5e5344114bc40754d10c28a811c0c8f7027356979192931a6a7df2ab9e5bab3058988c99ae55f4fb71db2ce9fc77c40f619aa + languageName: node + linkType: hard + "optionator@npm:^0.9.3": version: 0.9.3 resolution: "optionator@npm:0.9.3" @@ -4810,13 +4717,20 @@ __metadata: languageName: node linkType: hard -"path-key@npm:^3.1.0": +"path-key@npm:^3.0.0, path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" checksum: 10/55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 languageName: node linkType: hard +"path-key@npm:^4.0.0": + version: 4.0.0 + resolution: "path-key@npm:4.0.0" + checksum: 10/8e6c314ae6d16b83e93032c61020129f6f4484590a777eed709c4a01b50e498822b00f76ceaf94bc64dbd90b327df56ceadce27da3d83393790f1219e07721d7 + languageName: node + linkType: hard + "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -4891,6 +4805,15 @@ __metadata: languageName: node linkType: hard +"prettier@npm:^3.0.3": + version: 3.0.3 + resolution: "prettier@npm:3.0.3" + bin: + prettier: bin/prettier.cjs + checksum: 10/ccf1ead9794b017be6b42d0873f459070beef2069eb393c8b4c0d11aa3430acefc54f6d5f44a5b7ce9af05ad8daf694b912f0aa2808d1c22dfa86e61e9d563f8 + languageName: node + linkType: hard + "prettier@npm:^3.2.5": version: 3.2.5 resolution: "prettier@npm:3.2.5" @@ -4907,13 +4830,6 @@ __metadata: languageName: node linkType: hard -"promise-inflight@npm:^1.0.1": - version: 1.0.1 - resolution: "promise-inflight@npm:1.0.1" - checksum: 10/1560d413ea20c5a74f3631d39ba8cbd1972b9228072a755d01e1f5ca5110382d9af76a1582d889445adc6e75bb5ac4886b56dc4b6eae51b30145d7bb1ac7505b - languageName: node - linkType: hard - "promise-retry@npm:^2.0.1": version: 2.0.1 resolution: "promise-retry@npm:2.0.1" @@ -4959,7 +4875,7 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:^3.4.0, readable-stream@npm:^3.6.0": +"readable-stream@npm:^3.4.0": version: 3.6.2 resolution: "readable-stream@npm:3.6.2" dependencies: @@ -4995,13 +4911,6 @@ __metadata: languageName: node linkType: hard -"remove-trailing-spaces@npm:^1.0.7": - version: 1.0.8 - resolution: "remove-trailing-spaces@npm:1.0.8" - checksum: 10/81f615c5cd8dd6a5e3017dcc9af598965575d176d42ef99cfd7b894529991f464e629fd68aba089f5c6bebf5bb8070a5eee56f3b621aba55e8ef524d6a4d4f69 - languageName: node - linkType: hard - "require-directory@npm:^2.1.1": version: 2.1.1 resolution: "require-directory@npm:2.1.1" @@ -5208,6 +5117,15 @@ __metadata: languageName: node linkType: hard +"run-applescript@npm:^5.0.0": + version: 5.0.0 + resolution: "run-applescript@npm:5.0.0" + dependencies: + execa: "npm:^5.0.0" + checksum: 10/d00c2dbfa5b2d774de7451194b8b125f40f65fc183de7d9dcae97f57f59433586d3c39b9001e111c38bfa24c3436c99df1bb4066a2a0c90d39a8c4cd6889af77 + languageName: node + linkType: hard + "run-async@npm:^3.0.0": version: 3.0.0 resolution: "run-async@npm:3.0.0" @@ -5265,7 +5183,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^6.0.0, semver@npm:^6.3.1": +"semver@npm:^6.3.1": version: 6.3.1 resolution: "semver@npm:6.3.1" bin: @@ -5294,25 +5212,6 @@ __metadata: languageName: node linkType: hard -"set-blocking@npm:^2.0.0": - version: 2.0.0 - resolution: "set-blocking@npm:2.0.0" - checksum: 10/8980ebf7ae9eb945bb036b6e283c547ee783a1ad557a82babf758a065e2fb6ea337fd82cac30dd565c1e606e423f30024a19fff7afbf4977d784720c4026a8ef - languageName: node - linkType: hard - -"set-function-length@npm:^1.1.1": - version: 1.1.1 - resolution: "set-function-length@npm:1.1.1" - dependencies: - define-data-property: "npm:^1.1.1" - get-intrinsic: "npm:^1.2.1" - gopd: "npm:^1.0.1" - has-property-descriptors: "npm:^1.0.0" - checksum: 10/745ed1d7dc69a6185e0820082fe73838ab3dfd01e75cce83a41e4c1d68bbf34bc5fb38f32ded542ae0b557536b5d2781594499b5dcd19e7db138e06292a76c7b - languageName: node - linkType: hard - "set-function-length@npm:^1.2.1": version: 1.2.1 resolution: "set-function-length@npm:1.2.1" @@ -5359,7 +5258,7 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.0, signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.7": +"signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" checksum: 10/a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 @@ -5387,17 +5286,6 @@ __metadata: languageName: node linkType: hard -"socks-proxy-agent@npm:^7.0.0": - version: 7.0.0 - resolution: "socks-proxy-agent@npm:7.0.0" - dependencies: - agent-base: "npm:^6.0.2" - debug: "npm:^4.3.3" - socks: "npm:^2.6.2" - checksum: 10/26c75d9c62a9ed3fd494df60e65e88da442f78e0d4bc19bfd85ac37bd2c67470d6d4bba5202e804561cda6674db52864c9e2a2266775f879bc8d89c1445a5f4c - languageName: node - linkType: hard - "socks-proxy-agent@npm:^8.0.1": version: 8.0.2 resolution: "socks-proxy-agent@npm:8.0.2" @@ -5409,7 +5297,7 @@ __metadata: languageName: node linkType: hard -"socks@npm:^2.6.2, socks@npm:^2.7.1": +"socks@npm:^2.7.1": version: 2.7.1 resolution: "socks@npm:2.7.1" dependencies: @@ -5466,16 +5354,7 @@ __metadata: languageName: node linkType: hard -"ssri@npm:^9.0.0": - version: 9.0.1 - resolution: "ssri@npm:9.0.1" - dependencies: - minipass: "npm:^3.1.1" - checksum: 10/7638a61e91432510718e9265d48d0438a17d53065e5184f1336f234ef6aa3479663942e41e97df56cda06bb24d9d0b5ef342c10685add3cac7267a82d7fa6718 - languageName: node - linkType: hard - -"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": +"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" dependencies: @@ -5524,6 +5403,20 @@ __metadata: languageName: node linkType: hard +"strip-final-newline@npm:^2.0.0": + version: 2.0.0 + resolution: "strip-final-newline@npm:2.0.0" + checksum: 10/69412b5e25731e1938184b5d489c32e340605bb611d6140344abc3421b7f3c6f9984b21dff296dfcf056681b82caa3bb4cc996a965ce37bcfad663e92eae9c64 + languageName: node + linkType: hard + +"strip-final-newline@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-final-newline@npm:3.0.0" + checksum: 10/23ee263adfa2070cd0f23d1ac14e2ed2f000c9b44229aec9c799f1367ec001478469560abefd00c5c99ee6f0b31c137d53ec6029c53e9f32a93804e18c201050 + languageName: node + linkType: hard + "strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -5572,6 +5465,16 @@ __metadata: languageName: node linkType: hard +"synckit@npm:^0.8.5": + version: 0.8.5 + resolution: "synckit@npm:0.8.5" + dependencies: + "@pkgr/utils": "npm:^2.3.1" + tslib: "npm:^2.5.0" + checksum: 10/fb6798a2db2650ca3a2435ad32d4fc14842da807993a1a350b64d267e0e770aa7f26492b119aa7500892d3d07a5af1eec7bfbd6e23a619451558be0f226a6094 + languageName: node + linkType: hard + "synckit@npm:^0.8.6": version: 0.8.8 resolution: "synckit@npm:0.8.8" @@ -5656,6 +5559,13 @@ __metadata: languageName: node linkType: hard +"titleize@npm:^3.0.0": + version: 3.0.0 + resolution: "titleize@npm:3.0.0" + checksum: 10/71fbbeabbfb36ccd840559f67f21e356e1d03da2915b32d2ae1a60ddcc13a124be2739f696d2feb884983441d159a18649e8d956648d591bdad35c430a6b6d28 + languageName: node + linkType: hard + "tmp@npm:^0.0.33": version: 0.0.33 resolution: "tmp@npm:0.0.33" @@ -5681,13 +5591,6 @@ __metadata: languageName: node linkType: hard -"tr46@npm:~0.0.3": - version: 0.0.3 - resolution: "tr46@npm:0.0.3" - checksum: 10/8f1f5aa6cb232f9e1bdc86f485f916b7aa38caee8a778b378ffec0b70d9307873f253f5cbadbe2955ece2ac5c83d0dc14a77513166ccd0a0c7fe197e21396695 - languageName: node - linkType: hard - "tree-kill@npm:^1.2.2": version: 1.2.2 resolution: "tree-kill@npm:1.2.2" @@ -5954,118 +5857,6 @@ __metadata: languageName: unknown linkType: soft -"ts-for-gir-node-glib-2-spawn-command-example@workspace:examples/node-gtk/glib-2-spawn-command": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-glib-2-spawn-command-example@workspace:examples/node-gtk/glib-2-spawn-command" - dependencies: - "@ts-for-gir/cli": "workspace:^" - "@types/node": "npm:^20.11.18" - fork-ts-checker-webpack-plugin: "npm:^9.0.2" - node-gtk: "npm:^0.12.0" - raw-loader: "npm:^4.0.2" - ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" - webpack-cli: "npm:^5.1.4" - webpack-node-externals: "npm:^3.0.0" - languageName: unknown - linkType: soft - -"ts-for-gir-node-gtk-3-browser-example@workspace:examples/node-gtk/gtk-3-browser": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-3-browser-example@workspace:examples/node-gtk/gtk-3-browser" - dependencies: - "@ts-for-gir/cli": "workspace:^" - "@types/node": "npm:^20.11.18" - fork-ts-checker-webpack-plugin: "npm:^9.0.2" - node-gtk: "npm:^0.12.0" - ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - util: "npm:^0.12.5" - webpack: "npm:^5.90.2" - webpack-cli: "npm:^5.1.4" - webpack-node-externals: "npm:^3.0.0" - languageName: unknown - linkType: soft - -"ts-for-gir-node-gtk-3-builder-auto-connect-signals-example@workspace:examples/node-gtk/gtk-3-builder-auto-connect-signals": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-3-builder-auto-connect-signals-example@workspace:examples/node-gtk/gtk-3-builder-auto-connect-signals" - dependencies: - "@ts-for-gir/cli": "workspace:^" - "@types/node": "npm:^20.11.18" - fork-ts-checker-webpack-plugin: "npm:^9.0.2" - node-gtk: "npm:^0.12.0" - raw-loader: "npm:^4.0.2" - ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" - webpack-cli: "npm:^5.1.4" - webpack-node-externals: "npm:^3.0.0" - languageName: unknown - linkType: soft - -"ts-for-gir-node-gtk-3-builder-example@workspace:examples/node-gtk/gtk-3-builder": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-3-builder-example@workspace:examples/node-gtk/gtk-3-builder" - dependencies: - "@ts-for-gir/cli": "workspace:^" - "@types/node": "npm:^20.11.18" - fork-ts-checker-webpack-plugin: "npm:^9.0.2" - node-gtk: "npm:^0.12.0" - raw-loader: "npm:^4.0.2" - terser-webpack-plugin: "npm:^5.3.10" - ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" - webpack-cli: "npm:^5.1.4" - webpack-node-externals: "npm:^3.0.0" - languageName: unknown - linkType: soft - -"ts-for-gir-node-gtk-3-editor-example@workspace:examples/node-gtk/gtk-3-editor": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-3-editor-example@workspace:examples/node-gtk/gtk-3-editor" - dependencies: - "@ts-for-gir/cli": "workspace:^" - "@types/node": "npm:^20.11.18" - fork-ts-checker-webpack-plugin: "npm:^9.0.2" - node-gtk: "npm:^0.12.0" - ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" - webpack-cli: "npm:^5.1.4" - webpack-node-externals: "npm:^3.0.0" - languageName: unknown - linkType: soft - -"ts-for-gir-node-gtk-3-hello-example@workspace:examples/node-gtk/gtk-3-hello": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-3-hello-example@workspace:examples/node-gtk/gtk-3-hello" - dependencies: - "@ts-for-gir/cli": "workspace:^" - "@types/node": "npm:^20.11.18" - fork-ts-checker-webpack-plugin: "npm:^9.0.2" - node-gtk: "npm:^0.12.0" - raw-loader: "npm:^4.0.2" - ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" - webpack-cli: "npm:^5.1.4" - webpack-node-externals: "npm:^3.0.0" - languageName: unknown - linkType: soft - -"ts-for-gir-node-gtk-gio-2-cat-promisify-packages@workspace:examples/node-gtk/gio-2-cat-packages": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-gio-2-cat-promisify-packages@workspace:examples/node-gtk/gio-2-cat-packages" - dependencies: - esbuild: "npm:^0.20.0" - node-gtk: "npm:^0.12.0" - typescript: "npm:5.2.2" - languageName: unknown - linkType: soft - "ts-for-gir-node-gtk-gtk-4-application-example@workspace:examples/node-gtk/gtk-4-application": version: 0.0.0-use.local resolution: "ts-for-gir-node-gtk-gtk-4-application-example@workspace:examples/node-gtk/gtk-4-application" @@ -6076,28 +5867,6 @@ __metadata: languageName: unknown linkType: soft -"ts-for-gir-node-gtk-gtk-4-custom-widget-example@workspace:examples/node-gtk/gtk-4-custom-widget": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-gtk-4-custom-widget-example@workspace:examples/node-gtk/gtk-4-custom-widget" - dependencies: - "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - node-gtk: "npm:^0.12.0" - typescript: "npm:5.2.2" - languageName: unknown - linkType: soft - -"ts-for-gir-node-soup-3-http-example@workspace:examples/node-gtk/soup-3-http": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-soup-3-http-example@workspace:examples/node-gtk/soup-3-http" - dependencies: - "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - node-gtk: "npm:^0.12.0" - typescript: "npm:5.2.2" - languageName: unknown - linkType: soft - "ts-for-gir-run-async-example@workspace:examples/gjs/run-async": version: 0.0.0-use.local resolution: "ts-for-gir-run-async-example@workspace:examples/gjs/run-async" @@ -6208,7 +5977,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.1.0, tslib@npm:^2.6.2": +"tslib@npm:^2.1.0, tslib@npm:^2.5.0, tslib@npm:^2.6.0, tslib@npm:^2.6.2": version: 2.6.2 resolution: "tslib@npm:2.6.2" checksum: 10/bd26c22d36736513980091a1e356378e8b662ded04204453d353a7f34a4c21ed0afc59b5f90719d4ba756e581a162ecbf93118dc9c6be5acf70aa309188166ca @@ -6285,22 +6054,6 @@ __metadata: languageName: node linkType: hard -"unindent@npm:^2.0.0": - version: 2.0.0 - resolution: "unindent@npm:2.0.0" - checksum: 10/ae80e043d0457417710a490287ab1f0c65f142b89a09f2413f23db8dcd6826c1c6f11e97cfa507eb28999a8b723ac5bdfc8b9ea0959c3ba09b8fd69e735dd7f1 - languageName: node - linkType: hard - -"unique-filename@npm:^2.0.0": - version: 2.0.1 - resolution: "unique-filename@npm:2.0.1" - dependencies: - unique-slug: "npm:^3.0.0" - checksum: 10/807acf3381aff319086b64dc7125a9a37c09c44af7620bd4f7f3247fcd5565660ac12d8b80534dcbfd067e6fe88a67e621386dd796a8af828d1337a8420a255f - languageName: node - linkType: hard - "unique-filename@npm:^3.0.0": version: 3.0.0 resolution: "unique-filename@npm:3.0.0" @@ -6310,15 +6063,6 @@ __metadata: languageName: node linkType: hard -"unique-slug@npm:^3.0.0": - version: 3.0.0 - resolution: "unique-slug@npm:3.0.0" - dependencies: - imurmurhash: "npm:^0.1.4" - checksum: 10/26fc5bc209a875956dd5e84ca39b89bc3be777b112504667c35c861f9547df95afc80439358d836b878b6d91f6ee21fe5ba1a966e9ec2e9f071ddf3fd67d45ee - languageName: node - linkType: hard - "unique-slug@npm:^4.0.0": version: 4.0.0 resolution: "unique-slug@npm:4.0.0" @@ -6335,6 +6079,13 @@ __metadata: languageName: node linkType: hard +"untildify@npm:^4.0.0": + version: 4.0.0 + resolution: "untildify@npm:4.0.0" + checksum: 10/39ced9c418a74f73f0a56e1ba4634b4d959422dff61f4c72a8e39f60b99380c1b45ed776fbaa0a4101b157e4310d873ad7d114e8534ca02609b4916bb4187fb9 + languageName: node + linkType: hard + "update-browserslist-db@npm:^1.0.13": version: 1.0.13 resolution: "update-browserslist-db@npm:1.0.13" @@ -6365,19 +6116,6 @@ __metadata: languageName: node linkType: hard -"util@npm:^0.12.5": - version: 0.12.5 - resolution: "util@npm:0.12.5" - dependencies: - inherits: "npm:^2.0.3" - is-arguments: "npm:^1.0.4" - is-generator-function: "npm:^1.0.7" - is-typed-array: "npm:^1.1.3" - which-typed-array: "npm:^1.1.2" - checksum: 10/61a10de7753353dd4d744c917f74cdd7d21b8b46379c1e48e1c4fd8e83f8190e6bd9978fc4e5102ab6a10ebda6019d1b36572fa4a325e175ec8b789a121f6147 - languageName: node - linkType: hard - "v8-compile-cache-lib@npm:^3.0.1": version: 3.0.1 resolution: "v8-compile-cache-lib@npm:3.0.1" @@ -6444,13 +6182,6 @@ __metadata: languageName: node linkType: hard -"webidl-conversions@npm:^3.0.0": - version: 3.0.1 - resolution: "webidl-conversions@npm:3.0.1" - checksum: 10/b65b9f8d6854572a84a5c69615152b63371395f0c5dcd6729c45789052296df54314db2bc3e977df41705eacb8bc79c247cee139a63fa695192f95816ed528ad - languageName: node - linkType: hard - "webpack-cli@npm:^5.1.4": version: 5.1.4 resolution: "webpack-cli@npm:5.1.4" @@ -6494,13 +6225,6 @@ __metadata: languageName: node linkType: hard -"webpack-node-externals@npm:^3.0.0": - version: 3.0.0 - resolution: "webpack-node-externals@npm:3.0.0" - checksum: 10/1a08102f73be2d6e787d16cf677f98c413076f35f379d64a4c83aa83769099b38091a4592953fac5b2eb0c7e3eb1977f6b901ef2cba531d458e32665314b8025 - languageName: node - linkType: hard - "webpack-sources@npm:^3.2.3": version: 3.2.3 resolution: "webpack-sources@npm:3.2.3" @@ -6545,30 +6269,7 @@ __metadata: languageName: node linkType: hard -"whatwg-url@npm:^5.0.0": - version: 5.0.0 - resolution: "whatwg-url@npm:5.0.0" - dependencies: - tr46: "npm:~0.0.3" - webidl-conversions: "npm:^3.0.0" - checksum: 10/f95adbc1e80820828b45cc671d97da7cd5e4ef9deb426c31bcd5ab00dc7103042291613b3ef3caec0a2335ed09e0d5ed026c940755dbb6d404e2b27f940fdf07 - languageName: node - linkType: hard - -"which-typed-array@npm:^1.1.11, which-typed-array@npm:^1.1.2": - version: 1.1.13 - resolution: "which-typed-array@npm:1.1.13" - dependencies: - available-typed-arrays: "npm:^1.0.5" - call-bind: "npm:^1.0.4" - for-each: "npm:^0.3.3" - gopd: "npm:^1.0.1" - has-tostringtag: "npm:^1.0.0" - checksum: 10/605e3e10b7118af904a0e79d0d50b95275102f06ec902734024989cd71354929f7acee50de43529d3baf5858e2e4eb32c75e6ebd226c888ad976d8140e4a3e71 - languageName: node - linkType: hard - -"which@npm:^2.0.1, which@npm:^2.0.2": +"which@npm:^2.0.1": version: 2.0.2 resolution: "which@npm:2.0.2" dependencies: @@ -6590,15 +6291,6 @@ __metadata: languageName: node linkType: hard -"wide-align@npm:^1.1.2, wide-align@npm:^1.1.5": - version: 1.1.5 - resolution: "wide-align@npm:1.1.5" - dependencies: - string-width: "npm:^1.0.2 || 2 || 3 || 4" - checksum: 10/d5f8027b9a8255a493a94e4ec1b74a27bff6679d5ffe29316a3215e4712945c84ef73ca4045c7e20ae7d0c72f5f57f296e04a4928e773d4276a2f1222e4c2e99 - languageName: node - linkType: hard - "wildcard@npm:^2.0.0": version: 2.0.1 resolution: "wildcard@npm:2.0.1" From 25ab7a3493eb3aa37f43c2630b637c47f1045b8a Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:54:04 -0800 Subject: [PATCH 14/53] yarn: Generate SDKs for VSCode --- .yarn/sdks/eslint/bin/eslint.js | 20 ++ .yarn/sdks/eslint/lib/api.js | 20 ++ .yarn/sdks/eslint/lib/unsupported-api.js | 20 ++ .yarn/sdks/eslint/package.json | 14 ++ .yarn/sdks/integrations.yml | 5 + .yarn/sdks/prettier/bin/prettier.cjs | 20 ++ .yarn/sdks/prettier/index.cjs | 20 ++ .yarn/sdks/prettier/package.json | 7 + .yarn/sdks/typescript/bin/tsc | 20 ++ .yarn/sdks/typescript/bin/tsserver | 20 ++ .yarn/sdks/typescript/lib/tsc.js | 20 ++ .yarn/sdks/typescript/lib/tsserver.js | 225 +++++++++++++++++++ .yarn/sdks/typescript/lib/tsserverlibrary.js | 225 +++++++++++++++++++ .yarn/sdks/typescript/lib/typescript.js | 20 ++ .yarn/sdks/typescript/package.json | 10 + 15 files changed, 666 insertions(+) create mode 100755 .yarn/sdks/eslint/bin/eslint.js create mode 100644 .yarn/sdks/eslint/lib/api.js create mode 100644 .yarn/sdks/eslint/lib/unsupported-api.js create mode 100644 .yarn/sdks/eslint/package.json create mode 100644 .yarn/sdks/integrations.yml create mode 100755 .yarn/sdks/prettier/bin/prettier.cjs create mode 100644 .yarn/sdks/prettier/index.cjs create mode 100644 .yarn/sdks/prettier/package.json create mode 100755 .yarn/sdks/typescript/bin/tsc create mode 100755 .yarn/sdks/typescript/bin/tsserver create mode 100644 .yarn/sdks/typescript/lib/tsc.js create mode 100644 .yarn/sdks/typescript/lib/tsserver.js create mode 100644 .yarn/sdks/typescript/lib/tsserverlibrary.js create mode 100644 .yarn/sdks/typescript/lib/typescript.js create mode 100644 .yarn/sdks/typescript/package.json diff --git a/.yarn/sdks/eslint/bin/eslint.js b/.yarn/sdks/eslint/bin/eslint.js new file mode 100755 index 000000000..9ef98e400 --- /dev/null +++ b/.yarn/sdks/eslint/bin/eslint.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require eslint/bin/eslint.js + require(absPnpApiPath).setup(); + } +} + +// Defer to the real eslint/bin/eslint.js your application uses +module.exports = absRequire(`eslint/bin/eslint.js`); diff --git a/.yarn/sdks/eslint/lib/api.js b/.yarn/sdks/eslint/lib/api.js new file mode 100644 index 000000000..653b22bae --- /dev/null +++ b/.yarn/sdks/eslint/lib/api.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require eslint + require(absPnpApiPath).setup(); + } +} + +// Defer to the real eslint your application uses +module.exports = absRequire(`eslint`); diff --git a/.yarn/sdks/eslint/lib/unsupported-api.js b/.yarn/sdks/eslint/lib/unsupported-api.js new file mode 100644 index 000000000..30fdf158b --- /dev/null +++ b/.yarn/sdks/eslint/lib/unsupported-api.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require eslint/use-at-your-own-risk + require(absPnpApiPath).setup(); + } +} + +// Defer to the real eslint/use-at-your-own-risk your application uses +module.exports = absRequire(`eslint/use-at-your-own-risk`); diff --git a/.yarn/sdks/eslint/package.json b/.yarn/sdks/eslint/package.json new file mode 100644 index 000000000..f9672f354 --- /dev/null +++ b/.yarn/sdks/eslint/package.json @@ -0,0 +1,14 @@ +{ + "name": "eslint", + "version": "8.56.0-sdk", + "main": "./lib/api.js", + "type": "commonjs", + "bin": { + "eslint": "./bin/eslint.js" + }, + "exports": { + "./package.json": "./package.json", + ".": "./lib/api.js", + "./use-at-your-own-risk": "./lib/unsupported-api.js" + } +} diff --git a/.yarn/sdks/integrations.yml b/.yarn/sdks/integrations.yml new file mode 100644 index 000000000..aa9d0d0ad --- /dev/null +++ b/.yarn/sdks/integrations.yml @@ -0,0 +1,5 @@ +# This file is automatically generated by @yarnpkg/sdks. +# Manual changes might be lost! + +integrations: + - vscode diff --git a/.yarn/sdks/prettier/bin/prettier.cjs b/.yarn/sdks/prettier/bin/prettier.cjs new file mode 100755 index 000000000..5efad688e --- /dev/null +++ b/.yarn/sdks/prettier/bin/prettier.cjs @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require prettier/bin/prettier.cjs + require(absPnpApiPath).setup(); + } +} + +// Defer to the real prettier/bin/prettier.cjs your application uses +module.exports = absRequire(`prettier/bin/prettier.cjs`); diff --git a/.yarn/sdks/prettier/index.cjs b/.yarn/sdks/prettier/index.cjs new file mode 100644 index 000000000..8758e367a --- /dev/null +++ b/.yarn/sdks/prettier/index.cjs @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require prettier + require(absPnpApiPath).setup(); + } +} + +// Defer to the real prettier your application uses +module.exports = absRequire(`prettier`); diff --git a/.yarn/sdks/prettier/package.json b/.yarn/sdks/prettier/package.json new file mode 100644 index 000000000..6e68f38b6 --- /dev/null +++ b/.yarn/sdks/prettier/package.json @@ -0,0 +1,7 @@ +{ + "name": "prettier", + "version": "3.2.5-sdk", + "main": "./index.cjs", + "type": "commonjs", + "bin": "./bin/prettier.cjs" +} diff --git a/.yarn/sdks/typescript/bin/tsc b/.yarn/sdks/typescript/bin/tsc new file mode 100755 index 000000000..454b950b7 --- /dev/null +++ b/.yarn/sdks/typescript/bin/tsc @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/bin/tsc + require(absPnpApiPath).setup(); + } +} + +// Defer to the real typescript/bin/tsc your application uses +module.exports = absRequire(`typescript/bin/tsc`); diff --git a/.yarn/sdks/typescript/bin/tsserver b/.yarn/sdks/typescript/bin/tsserver new file mode 100755 index 000000000..d7a605684 --- /dev/null +++ b/.yarn/sdks/typescript/bin/tsserver @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/bin/tsserver + require(absPnpApiPath).setup(); + } +} + +// Defer to the real typescript/bin/tsserver your application uses +module.exports = absRequire(`typescript/bin/tsserver`); diff --git a/.yarn/sdks/typescript/lib/tsc.js b/.yarn/sdks/typescript/lib/tsc.js new file mode 100644 index 000000000..2f62fc96c --- /dev/null +++ b/.yarn/sdks/typescript/lib/tsc.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/lib/tsc.js + require(absPnpApiPath).setup(); + } +} + +// Defer to the real typescript/lib/tsc.js your application uses +module.exports = absRequire(`typescript/lib/tsc.js`); diff --git a/.yarn/sdks/typescript/lib/tsserver.js b/.yarn/sdks/typescript/lib/tsserver.js new file mode 100644 index 000000000..bbb1e4650 --- /dev/null +++ b/.yarn/sdks/typescript/lib/tsserver.js @@ -0,0 +1,225 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +const moduleWrapper = tsserver => { + if (!process.versions.pnp) { + return tsserver; + } + + const {isAbsolute} = require(`path`); + const pnpApi = require(`pnpapi`); + + const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//); + const isPortal = str => str.startsWith("portal:/"); + const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); + + const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { + return `${locator.name}@${locator.reference}`; + })); + + // VSCode sends the zip paths to TS using the "zip://" prefix, that TS + // doesn't understand. This layer makes sure to remove the protocol + // before forwarding it to TS, and to add it back on all returned paths. + + function toEditorPath(str) { + // We add the `zip:` prefix to both `.zip/` paths and virtual paths + if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) { + // We also take the opportunity to turn virtual paths into physical ones; + // this makes it much easier to work with workspaces that list peer + // dependencies, since otherwise Ctrl+Click would bring us to the virtual + // file instances instead of the real ones. + // + // We only do this to modules owned by the the dependency tree roots. + // This avoids breaking the resolution when jumping inside a vendor + // with peer dep (otherwise jumping into react-dom would show resolution + // errors on react). + // + const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str; + if (resolved) { + const locator = pnpApi.findPackageLocator(resolved); + if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) { + str = resolved; + } + } + + str = normalize(str); + + if (str.match(/\.zip\//)) { + switch (hostInfo) { + // Absolute VSCode `Uri.fsPath`s need to start with a slash. + // VSCode only adds it automatically for supported schemes, + // so we have to do it manually for the `zip` scheme. + // The path needs to start with a caret otherwise VSCode doesn't handle the protocol + // + // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910 + // + // 2021-10-08: VSCode changed the format in 1.61. + // Before | ^zip:/c:/foo/bar.zip/package.json + // After | ^/zip//c:/foo/bar.zip/package.json + // + // 2022-04-06: VSCode changed the format in 1.66. + // Before | ^/zip//c:/foo/bar.zip/package.json + // After | ^/zip/c:/foo/bar.zip/package.json + // + // 2022-05-06: VSCode changed the format in 1.68 + // Before | ^/zip/c:/foo/bar.zip/package.json + // After | ^/zip//c:/foo/bar.zip/package.json + // + case `vscode <1.61`: { + str = `^zip:${str}`; + } break; + + case `vscode <1.66`: { + str = `^/zip/${str}`; + } break; + + case `vscode <1.68`: { + str = `^/zip${str}`; + } break; + + case `vscode`: { + str = `^/zip/${str}`; + } break; + + // To make "go to definition" work, + // We have to resolve the actual file system path from virtual path + // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip) + case `coc-nvim`: { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = resolve(`zipfile:${str}`); + } break; + + // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server) + // We have to resolve the actual file system path from virtual path, + // everything else is up to neovim + case `neovim`: { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = `zipfile://${str}`; + } break; + + default: { + str = `zip:${str}`; + } break; + } + } else { + str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`); + } + } + + return str; + } + + function fromEditorPath(str) { + switch (hostInfo) { + case `coc-nvim`: { + str = str.replace(/\.zip::/, `.zip/`); + // The path for coc-nvim is in format of //zipfile://.yarn/... + // So in order to convert it back, we use .* to match all the thing + // before `zipfile:` + return process.platform === `win32` + ? str.replace(/^.*zipfile:\//, ``) + : str.replace(/^.*zipfile:/, ``); + } break; + + case `neovim`: { + str = str.replace(/\.zip::/, `.zip/`); + // The path for neovim is in format of zipfile:////.yarn/... + return str.replace(/^zipfile:\/\//, ``); + } break; + + case `vscode`: + default: { + return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) + } break; + } + } + + // Force enable 'allowLocalPluginLoads' + // TypeScript tries to resolve plugins using a path relative to itself + // which doesn't work when using the global cache + // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238 + // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but + // TypeScript already does local loads and if this code is running the user trusts the workspace + // https://github.com/microsoft/vscode/issues/45856 + const ConfiguredProject = tsserver.server.ConfiguredProject; + const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype; + ConfiguredProject.prototype.enablePluginsWithOptions = function() { + this.projectService.allowLocalPluginLoads = true; + return originalEnablePluginsWithOptions.apply(this, arguments); + }; + + // And here is the point where we hijack the VSCode <-> TS communications + // by adding ourselves in the middle. We locate everything that looks + // like an absolute path of ours and normalize it. + + const Session = tsserver.server.Session; + const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; + let hostInfo = `unknown`; + + Object.assign(Session.prototype, { + onMessage(/** @type {string | object} */ message) { + const isStringMessage = typeof message === 'string'; + const parsedMessage = isStringMessage ? JSON.parse(message) : message; + + if ( + parsedMessage != null && + typeof parsedMessage === `object` && + parsedMessage.arguments && + typeof parsedMessage.arguments.hostInfo === `string` + ) { + hostInfo = parsedMessage.arguments.hostInfo; + if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { + const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( + // The RegExp from https://semver.org/ but without the caret at the start + /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ + ) ?? []).map(Number) + + if (major === 1) { + if (minor < 61) { + hostInfo += ` <1.61`; + } else if (minor < 66) { + hostInfo += ` <1.66`; + } else if (minor < 68) { + hostInfo += ` <1.68`; + } + } + } + } + + const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { + return typeof value === 'string' ? fromEditorPath(value) : value; + }); + + return originalOnMessage.call( + this, + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + ); + }, + + send(/** @type {any} */ msg) { + return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => { + return typeof value === `string` ? toEditorPath(value) : value; + }))); + } + }); + + return tsserver; +}; + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/lib/tsserver.js + require(absPnpApiPath).setup(); + } +} + +// Defer to the real typescript/lib/tsserver.js your application uses +module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`)); diff --git a/.yarn/sdks/typescript/lib/tsserverlibrary.js b/.yarn/sdks/typescript/lib/tsserverlibrary.js new file mode 100644 index 000000000..a68f028fe --- /dev/null +++ b/.yarn/sdks/typescript/lib/tsserverlibrary.js @@ -0,0 +1,225 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +const moduleWrapper = tsserver => { + if (!process.versions.pnp) { + return tsserver; + } + + const {isAbsolute} = require(`path`); + const pnpApi = require(`pnpapi`); + + const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//); + const isPortal = str => str.startsWith("portal:/"); + const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); + + const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { + return `${locator.name}@${locator.reference}`; + })); + + // VSCode sends the zip paths to TS using the "zip://" prefix, that TS + // doesn't understand. This layer makes sure to remove the protocol + // before forwarding it to TS, and to add it back on all returned paths. + + function toEditorPath(str) { + // We add the `zip:` prefix to both `.zip/` paths and virtual paths + if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) { + // We also take the opportunity to turn virtual paths into physical ones; + // this makes it much easier to work with workspaces that list peer + // dependencies, since otherwise Ctrl+Click would bring us to the virtual + // file instances instead of the real ones. + // + // We only do this to modules owned by the the dependency tree roots. + // This avoids breaking the resolution when jumping inside a vendor + // with peer dep (otherwise jumping into react-dom would show resolution + // errors on react). + // + const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str; + if (resolved) { + const locator = pnpApi.findPackageLocator(resolved); + if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) { + str = resolved; + } + } + + str = normalize(str); + + if (str.match(/\.zip\//)) { + switch (hostInfo) { + // Absolute VSCode `Uri.fsPath`s need to start with a slash. + // VSCode only adds it automatically for supported schemes, + // so we have to do it manually for the `zip` scheme. + // The path needs to start with a caret otherwise VSCode doesn't handle the protocol + // + // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910 + // + // 2021-10-08: VSCode changed the format in 1.61. + // Before | ^zip:/c:/foo/bar.zip/package.json + // After | ^/zip//c:/foo/bar.zip/package.json + // + // 2022-04-06: VSCode changed the format in 1.66. + // Before | ^/zip//c:/foo/bar.zip/package.json + // After | ^/zip/c:/foo/bar.zip/package.json + // + // 2022-05-06: VSCode changed the format in 1.68 + // Before | ^/zip/c:/foo/bar.zip/package.json + // After | ^/zip//c:/foo/bar.zip/package.json + // + case `vscode <1.61`: { + str = `^zip:${str}`; + } break; + + case `vscode <1.66`: { + str = `^/zip/${str}`; + } break; + + case `vscode <1.68`: { + str = `^/zip${str}`; + } break; + + case `vscode`: { + str = `^/zip/${str}`; + } break; + + // To make "go to definition" work, + // We have to resolve the actual file system path from virtual path + // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip) + case `coc-nvim`: { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = resolve(`zipfile:${str}`); + } break; + + // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server) + // We have to resolve the actual file system path from virtual path, + // everything else is up to neovim + case `neovim`: { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = `zipfile://${str}`; + } break; + + default: { + str = `zip:${str}`; + } break; + } + } else { + str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`); + } + } + + return str; + } + + function fromEditorPath(str) { + switch (hostInfo) { + case `coc-nvim`: { + str = str.replace(/\.zip::/, `.zip/`); + // The path for coc-nvim is in format of //zipfile://.yarn/... + // So in order to convert it back, we use .* to match all the thing + // before `zipfile:` + return process.platform === `win32` + ? str.replace(/^.*zipfile:\//, ``) + : str.replace(/^.*zipfile:/, ``); + } break; + + case `neovim`: { + str = str.replace(/\.zip::/, `.zip/`); + // The path for neovim is in format of zipfile:////.yarn/... + return str.replace(/^zipfile:\/\//, ``); + } break; + + case `vscode`: + default: { + return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) + } break; + } + } + + // Force enable 'allowLocalPluginLoads' + // TypeScript tries to resolve plugins using a path relative to itself + // which doesn't work when using the global cache + // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238 + // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but + // TypeScript already does local loads and if this code is running the user trusts the workspace + // https://github.com/microsoft/vscode/issues/45856 + const ConfiguredProject = tsserver.server.ConfiguredProject; + const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype; + ConfiguredProject.prototype.enablePluginsWithOptions = function() { + this.projectService.allowLocalPluginLoads = true; + return originalEnablePluginsWithOptions.apply(this, arguments); + }; + + // And here is the point where we hijack the VSCode <-> TS communications + // by adding ourselves in the middle. We locate everything that looks + // like an absolute path of ours and normalize it. + + const Session = tsserver.server.Session; + const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; + let hostInfo = `unknown`; + + Object.assign(Session.prototype, { + onMessage(/** @type {string | object} */ message) { + const isStringMessage = typeof message === 'string'; + const parsedMessage = isStringMessage ? JSON.parse(message) : message; + + if ( + parsedMessage != null && + typeof parsedMessage === `object` && + parsedMessage.arguments && + typeof parsedMessage.arguments.hostInfo === `string` + ) { + hostInfo = parsedMessage.arguments.hostInfo; + if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { + const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( + // The RegExp from https://semver.org/ but without the caret at the start + /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ + ) ?? []).map(Number) + + if (major === 1) { + if (minor < 61) { + hostInfo += ` <1.61`; + } else if (minor < 66) { + hostInfo += ` <1.66`; + } else if (minor < 68) { + hostInfo += ` <1.68`; + } + } + } + } + + const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { + return typeof value === 'string' ? fromEditorPath(value) : value; + }); + + return originalOnMessage.call( + this, + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + ); + }, + + send(/** @type {any} */ msg) { + return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => { + return typeof value === `string` ? toEditorPath(value) : value; + }))); + } + }); + + return tsserver; +}; + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/lib/tsserverlibrary.js + require(absPnpApiPath).setup(); + } +} + +// Defer to the real typescript/lib/tsserverlibrary.js your application uses +module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`)); diff --git a/.yarn/sdks/typescript/lib/typescript.js b/.yarn/sdks/typescript/lib/typescript.js new file mode 100644 index 000000000..b5f4db25b --- /dev/null +++ b/.yarn/sdks/typescript/lib/typescript.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire} = require(`module`); +const {resolve} = require(`path`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absRequire = createRequire(absPnpApiPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript + require(absPnpApiPath).setup(); + } +} + +// Defer to the real typescript your application uses +module.exports = absRequire(`typescript`); diff --git a/.yarn/sdks/typescript/package.json b/.yarn/sdks/typescript/package.json new file mode 100644 index 000000000..d32f3913d --- /dev/null +++ b/.yarn/sdks/typescript/package.json @@ -0,0 +1,10 @@ +{ + "name": "typescript", + "version": "5.2.2-sdk", + "main": "./lib/typescript.js", + "type": "commonjs", + "bin": { + "tsc": "./bin/tsc", + "tsserver": "./bin/tsserver" + } +} From 3d4d5937bd47493fd090b3ce6c45cbc7469302bf Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:57:35 -0800 Subject: [PATCH 15/53] Up ts-for-gir version and point types to 'next' --- .ts-for-gir.gtk4.rc.js | 2 +- .ts-for-gir.packages-all.rc.js | 2 +- package.json | 4 +- yarn.lock | 488 ++------------------------------- 4 files changed, 28 insertions(+), 468 deletions(-) diff --git a/.ts-for-gir.gtk4.rc.js b/.ts-for-gir.gtk4.rc.js index 19755daec..20b0762a6 100644 --- a/.ts-for-gir.gtk4.rc.js +++ b/.ts-for-gir.gtk4.rc.js @@ -1,6 +1,6 @@ export default { environments: ['gjs'], - modules: ['Gtk-4.0'], + modules: ['Gtk-4.0', 'Adw-1.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], ignoreVersionConflicts: true, diff --git a/.ts-for-gir.packages-all.rc.js b/.ts-for-gir.packages-all.rc.js index cab70b116..1ee96df92 100644 --- a/.ts-for-gir.packages-all.rc.js +++ b/.ts-for-gir.packages-all.rc.js @@ -1,5 +1,5 @@ export default { - outdir: './types', + outdir: './types-next', environments: ['gjs'], modules: ['*'], girDirectories: [ diff --git a/package.json b/package.json index 9707a6c0a..9d38abaaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-for-gir", - "version": "3.2.3", + "version": "3.2.8", "description": "Typescript .d.ts generator from GIR for gjs", "type": "module", "private": true, @@ -33,9 +33,9 @@ "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:gjs:rygelcore2 && yarn validate:types:gjs", "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gjs:gcalc && yarn validate:types:gjs", "build": "yarn build:parser && yarn build:lib && yarn build:generators && yarn build:cli", + "build:parser": "yarn workspace @gi.ts/parser run build", "build:cli": "yarn workspace @ts-for-gir/cli run build", "build:lib": "yarn workspace @ts-for-gir/lib run build", - "build:parser": "yarn workspace @gi.ts/parser run build", "build:generators": "yarn build:generator-base && yarn build:generator-typescript && yarn build:generator-html-doc", "build:generator-base": "yarn workspace @ts-for-gir/generator-base run build", "build:generator-typescript": "yarn workspace @ts-for-gir/generator-typescript run build", diff --git a/yarn.lock b/yarn.lock index 3d94827d0..9cf8e22b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,17 +22,7 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.16.7, @babel/code-frame@npm:^7.22.13": - version: 7.22.13 - resolution: "@babel/code-frame@npm:7.22.13" - dependencies: - "@babel/highlight": "npm:^7.22.13" - chalk: "npm:^2.4.2" - checksum: 10/bf6ae6ba3a510adfda6a211b4a89b0f1c98ca1352b745c077d113f3b568141e0d44ce750b9ac2a80143ba5c8c4080c50fcfc1aa11d86e194ea6785f62520eb5a - languageName: node - linkType: hard - -"@babel/code-frame@npm:^7.23.5": +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.16.7, @babel/code-frame@npm:^7.23.5": version: 7.23.5 resolution: "@babel/code-frame@npm:7.23.5" dependencies: @@ -204,17 +194,6 @@ __metadata: languageName: node linkType: hard -"@babel/highlight@npm:^7.22.13": - version: 7.22.20 - resolution: "@babel/highlight@npm:7.22.20" - dependencies: - "@babel/helper-validator-identifier": "npm:^7.22.20" - chalk: "npm:^2.4.2" - js-tokens: "npm:^4.0.0" - checksum: 10/1aabc95b2cb7f67adc26c7049554306f1435bfedb76b9731c36ff3d7cdfcb32bd65a6dd06985644124eb2100bd911721d9e5c4f5ac40b7f0da2995a61bf8da92 - languageName: node - linkType: hard - "@babel/highlight@npm:^7.23.4": version: 7.23.4 resolution: "@babel/highlight@npm:7.23.4" @@ -226,15 +205,6 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.22.15": - version: 7.23.0 - resolution: "@babel/parser@npm:7.23.0" - bin: - parser: ./bin/babel-parser.js - checksum: 10/201641e068f8cca1ff12b141fcba32d7ccbabc586961bd1b85ae89d9695867f84d57fc2e1176dc4981fd28e5e97ca0e7c32cd688bd5eabb641a302abc0cb5040 - languageName: node - linkType: hard - "@babel/parser@npm:^7.23.9": version: 7.23.9 resolution: "@babel/parser@npm:7.23.9" @@ -253,18 +223,7 @@ __metadata: languageName: node linkType: hard -"@babel/template@npm:^7.22.15": - version: 7.22.15 - resolution: "@babel/template@npm:7.22.15" - dependencies: - "@babel/code-frame": "npm:^7.22.13" - "@babel/parser": "npm:^7.22.15" - "@babel/types": "npm:^7.22.15" - checksum: 10/21e768e4eed4d1da2ce5d30aa51db0f4d6d8700bc1821fec6292587df7bba2fe1a96451230de8c64b989740731888ebf1141138bfffb14cacccf4d05c66ad93f - languageName: node - linkType: hard - -"@babel/template@npm:^7.23.9": +"@babel/template@npm:^7.22.15, @babel/template@npm:^7.23.9": version: 7.23.9 resolution: "@babel/template@npm:7.23.9" dependencies: @@ -304,18 +263,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.23.6": - version: 7.23.6 - resolution: "@babel/types@npm:7.23.6" - dependencies: - "@babel/helper-string-parser": "npm:^7.23.4" - "@babel/helper-validator-identifier": "npm:^7.22.20" - to-fast-properties: "npm:^2.0.0" - checksum: 10/07e70bb94d30b0231396b5e9a7726e6d9227a0a62e0a6830c0bd3232f33b024092e3d5a7d1b096a65bbf2bb43a9ab4c721bf618e115bfbb87b454fa060f88cbf - languageName: node - linkType: hard - -"@babel/types@npm:^7.23.9": +"@babel/types@npm:^7.23.6, @babel/types@npm:^7.23.9": version: 7.23.9 resolution: "@babel/types@npm:7.23.9" dependencies: @@ -675,23 +623,6 @@ __metadata: languageName: node linkType: hard -"@eslint/eslintrc@npm:^2.1.2": - version: 2.1.2 - resolution: "@eslint/eslintrc@npm:2.1.2" - dependencies: - ajv: "npm:^6.12.4" - debug: "npm:^4.3.2" - espree: "npm:^9.6.0" - globals: "npm:^13.19.0" - ignore: "npm:^5.2.0" - import-fresh: "npm:^3.2.1" - js-yaml: "npm:^4.1.0" - minimatch: "npm:^3.1.2" - strip-json-comments: "npm:^3.1.1" - checksum: 10/fa25638f2666cac6810f98ee7d0f4b912f191806467c1b40d72bac759fffef0b3357f12a1869817286837b258e4de3517e0c7408520e156ca860fc53a1fbaed9 - languageName: node - linkType: hard - "@eslint/eslintrc@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/eslintrc@npm:2.1.4" @@ -709,13 +640,6 @@ __metadata: languageName: node linkType: hard -"@eslint/js@npm:8.52.0": - version: 8.52.0 - resolution: "@eslint/js@npm:8.52.0" - checksum: 10/86beff213d0ae4ced203a922b74e2cc4d767d109e7815f985bf648946ba072198977102e32afc9fa04f7825a6de83a831874f6b6675ba0c1d0743ade2dc2d53d - languageName: node - linkType: hard - "@eslint/js@npm:8.56.0": version: 8.56.0 resolution: "@eslint/js@npm:8.56.0" @@ -830,7 +754,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.20, @jridgewell/trace-mapping@npm:^0.3.9": +"@jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.9": version: 0.3.20 resolution: "@jridgewell/trace-mapping@npm:0.3.20" dependencies: @@ -840,6 +764,16 @@ __metadata: languageName: node linkType: hard +"@jridgewell/trace-mapping@npm:^0.3.20": + version: 0.3.22 + resolution: "@jridgewell/trace-mapping@npm:0.3.22" + dependencies: + "@jridgewell/resolve-uri": "npm:^3.1.0" + "@jridgewell/sourcemap-codec": "npm:^1.4.14" + checksum: 10/48d3e3db00dbecb211613649a1849876ba5544a3f41cf5e6b99ea1130272d6cf18591b5b67389bce20f1c871b4ede5900c3b6446a7aab6d0a3b2fe806a834db7 + languageName: node + linkType: hard + "@ljharb/through@npm:^2.3.12": version: 2.3.12 resolution: "@ljharb/through@npm:2.3.12" @@ -912,20 +846,6 @@ __metadata: languageName: node linkType: hard -"@pkgr/utils@npm:^2.3.1": - version: 2.4.2 - resolution: "@pkgr/utils@npm:2.4.2" - dependencies: - cross-spawn: "npm:^7.0.3" - fast-glob: "npm:^3.3.0" - is-glob: "npm:^4.0.3" - open: "npm:^9.1.0" - picocolors: "npm:^1.0.0" - tslib: "npm:^2.6.0" - checksum: 10/f0b0b305a83bd65fac5637d28ad3e33f19194043e03ceef6b4e13d260bfa2678b73df76dc56ed906469ffe0494d4bd214e6b92ca80684f38547982edf982dd15 - languageName: node - linkType: hard - "@rollup/plugin-babel@npm:^6.0.4": version: 6.0.4 resolution: "@rollup/plugin-babel@npm:6.0.4" @@ -2046,13 +1966,6 @@ __metadata: languageName: node linkType: hard -"big-integer@npm:^1.6.44": - version: 1.6.51 - resolution: "big-integer@npm:1.6.51" - checksum: 10/c7a12640901906d6f6b6bdb42a4eaba9578397b6d9a0dd090cf001ec813ff2bfcd441e364068ea0416db6175d2615f8ed19cff7d1a795115bf7c92d44993f991 - languageName: node - linkType: hard - "big.js@npm:^5.2.2": version: 5.2.2 resolution: "big.js@npm:5.2.2" @@ -2078,15 +1991,6 @@ __metadata: languageName: node linkType: hard -"bplist-parser@npm:^0.2.0": - version: 0.2.0 - resolution: "bplist-parser@npm:0.2.0" - dependencies: - big-integer: "npm:^1.6.44" - checksum: 10/15d31c1b0c7e0fb384e96349453879a33609d92d91b55a9ccee04b4be4b0645f1c823253d73326a1a23104521fbc45c2dd97fb05adf61863841b68cbb2ca7a3d - languageName: node - linkType: hard - "brace-expansion@npm:^1.1.7": version: 1.1.11 resolution: "brace-expansion@npm:1.1.11" @@ -2160,15 +2064,6 @@ __metadata: languageName: node linkType: hard -"bundle-name@npm:^3.0.0": - version: 3.0.0 - resolution: "bundle-name@npm:3.0.0" - dependencies: - run-applescript: "npm:^5.0.0" - checksum: 10/edf2b1fbe6096ed32e7566947ace2ea937ee427391744d7510a2880c4b9a5b3543d3f6c551236a29e5c87d3195f8e2912516290e638c15bcbede7b37cc375615 - languageName: node - linkType: hard - "cacache@npm:^18.0.0": version: 18.0.0 resolution: "cacache@npm:18.0.0" @@ -2524,28 +2419,6 @@ __metadata: languageName: node linkType: hard -"default-browser-id@npm:^3.0.0": - version: 3.0.0 - resolution: "default-browser-id@npm:3.0.0" - dependencies: - bplist-parser: "npm:^0.2.0" - untildify: "npm:^4.0.0" - checksum: 10/279c7ad492542e5556336b6c254a4eaf31b2c63a5433265655ae6e47301197b6cfb15c595a6fdc6463b2ff8e1a1a1ed3cba56038a60e1527ba4ab1628c6b9941 - languageName: node - linkType: hard - -"default-browser@npm:^4.0.0": - version: 4.0.0 - resolution: "default-browser@npm:4.0.0" - dependencies: - bundle-name: "npm:^3.0.0" - default-browser-id: "npm:^3.0.0" - execa: "npm:^7.1.1" - titleize: "npm:^3.0.0" - checksum: 10/40c5af984799042b140300be5639c9742599bda76dc9eba5ac9ad5943c83dd36cebc4471eafcfddf8e0ec817166d5ba89d56f08e66a126c7c7908a179cead1a7 - languageName: node - linkType: hard - "defaults@npm:^1.0.3": version: 1.0.4 resolution: "defaults@npm:1.0.4" @@ -2566,13 +2439,6 @@ __metadata: languageName: node linkType: hard -"define-lazy-prop@npm:^3.0.0": - version: 3.0.0 - resolution: "define-lazy-prop@npm:3.0.0" - checksum: 10/f28421cf9ee86eecaf5f3b8fe875f13d7009c2625e97645bfff7a2a49aca678270b86c39f9c32939e5ca7ab96b551377ed4139558c795e076774287ad3af1aa4 - languageName: node - linkType: hard - "diff@npm:^4.0.1": version: 4.0.2 resolution: "diff@npm:4.0.2" @@ -2903,18 +2769,7 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:^9.0.0": - version: 9.0.0 - resolution: "eslint-config-prettier@npm:9.0.0" - peerDependencies: - eslint: ">=7.0.0" - bin: - eslint-config-prettier: bin/cli.js - checksum: 10/276b0b5b5b19066962a9ff3a16a553bdad28e1c0a2ea33a1d75d65c0428bb7b37f6e85ac111ebefcc9bdefb544385856dbe6eaeda5279c639e5549c113d27dda - languageName: node - linkType: hard - -"eslint-config-prettier@npm:^9.1.0": +"eslint-config-prettier@npm:^9.0.0, eslint-config-prettier@npm:^9.1.0": version: 9.1.0 resolution: "eslint-config-prettier@npm:9.1.0" peerDependencies: @@ -2925,26 +2780,7 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-prettier@npm:^5.0.1": - version: 5.0.1 - resolution: "eslint-plugin-prettier@npm:5.0.1" - dependencies: - prettier-linter-helpers: "npm:^1.0.0" - synckit: "npm:^0.8.5" - peerDependencies: - "@types/eslint": ">=8.0.0" - eslint: ">=8.0.0" - prettier: ">=3.0.0" - peerDependenciesMeta: - "@types/eslint": - optional: true - eslint-config-prettier: - optional: true - checksum: 10/1a43dcca90f61fde0167347e0e870b579835ba6b9d697a862c29c76097a7bb0e8f07a7cf88be33517ca11203d9d4aa335d794c377640c2fe5acd06871db67d34 - languageName: node - linkType: hard - -"eslint-plugin-prettier@npm:^5.1.3": +"eslint-plugin-prettier@npm:^5.0.1, eslint-plugin-prettier@npm:^5.1.3": version: 5.1.3 resolution: "eslint-plugin-prettier@npm:5.1.3" dependencies: @@ -2991,55 +2827,7 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.52.0": - version: 8.52.0 - resolution: "eslint@npm:8.52.0" - dependencies: - "@eslint-community/eslint-utils": "npm:^4.2.0" - "@eslint-community/regexpp": "npm:^4.6.1" - "@eslint/eslintrc": "npm:^2.1.2" - "@eslint/js": "npm:8.52.0" - "@humanwhocodes/config-array": "npm:^0.11.13" - "@humanwhocodes/module-importer": "npm:^1.0.1" - "@nodelib/fs.walk": "npm:^1.2.8" - "@ungap/structured-clone": "npm:^1.2.0" - ajv: "npm:^6.12.4" - chalk: "npm:^4.0.0" - cross-spawn: "npm:^7.0.2" - debug: "npm:^4.3.2" - doctrine: "npm:^3.0.0" - escape-string-regexp: "npm:^4.0.0" - eslint-scope: "npm:^7.2.2" - eslint-visitor-keys: "npm:^3.4.3" - espree: "npm:^9.6.1" - esquery: "npm:^1.4.2" - esutils: "npm:^2.0.2" - fast-deep-equal: "npm:^3.1.3" - file-entry-cache: "npm:^6.0.1" - find-up: "npm:^5.0.0" - glob-parent: "npm:^6.0.2" - globals: "npm:^13.19.0" - graphemer: "npm:^1.4.0" - ignore: "npm:^5.2.0" - imurmurhash: "npm:^0.1.4" - is-glob: "npm:^4.0.0" - is-path-inside: "npm:^3.0.3" - js-yaml: "npm:^4.1.0" - json-stable-stringify-without-jsonify: "npm:^1.0.1" - levn: "npm:^0.4.1" - lodash.merge: "npm:^4.6.2" - minimatch: "npm:^3.1.2" - natural-compare: "npm:^1.4.0" - optionator: "npm:^0.9.3" - strip-ansi: "npm:^6.0.1" - text-table: "npm:^0.2.0" - bin: - eslint: bin/eslint.js - checksum: 10/01784ab15351d749bc95446039ed7acd5124f7cc84acdbf98c7199272eae06212a8f3ea4a9b47e7cc54ab17ca094c3a664bbfc3002c7de27936220e278b5028a - languageName: node - linkType: hard - -"eslint@npm:^8.56.0": +"eslint@npm:^8.52.0, eslint@npm:^8.56.0": version: 8.56.0 resolution: "eslint@npm:8.56.0" dependencies: @@ -3151,40 +2939,6 @@ __metadata: languageName: node linkType: hard -"execa@npm:^5.0.0": - version: 5.1.1 - resolution: "execa@npm:5.1.1" - dependencies: - cross-spawn: "npm:^7.0.3" - get-stream: "npm:^6.0.0" - human-signals: "npm:^2.1.0" - is-stream: "npm:^2.0.0" - merge-stream: "npm:^2.0.0" - npm-run-path: "npm:^4.0.1" - onetime: "npm:^5.1.2" - signal-exit: "npm:^3.0.3" - strip-final-newline: "npm:^2.0.0" - checksum: 10/8ada91f2d70f7dff702c861c2c64f21dfdc1525628f3c0454fd6f02fce65f7b958616cbd2b99ca7fa4d474e461a3d363824e91b3eb881705231abbf387470597 - languageName: node - linkType: hard - -"execa@npm:^7.1.1": - version: 7.2.0 - resolution: "execa@npm:7.2.0" - dependencies: - cross-spawn: "npm:^7.0.3" - get-stream: "npm:^6.0.1" - human-signals: "npm:^4.3.0" - is-stream: "npm:^3.0.0" - merge-stream: "npm:^2.0.0" - npm-run-path: "npm:^5.1.0" - onetime: "npm:^6.0.0" - signal-exit: "npm:^3.0.7" - strip-final-newline: "npm:^3.0.0" - checksum: 10/473feff60f9d4dbe799225948de48b5158c1723021d19c4b982afe37bcd111ae84e1b4c9dfe967fae5101b0894b1a62e4dd564a286dfa3e46d7b0cfdbf7fe62b - languageName: node - linkType: hard - "exponential-backoff@npm:^3.1.1": version: 3.1.1 resolution: "exponential-backoff@npm:3.1.1" @@ -3217,7 +2971,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": +"fast-glob@npm:^3.2.9": version: 3.3.1 resolution: "fast-glob@npm:3.3.1" dependencies: @@ -3470,19 +3224,7 @@ __metadata: languageName: node linkType: hard -"get-intrinsic@npm:^1.1.3": - version: 1.2.2 - resolution: "get-intrinsic@npm:1.2.2" - dependencies: - function-bind: "npm:^1.1.2" - has-proto: "npm:^1.0.1" - has-symbols: "npm:^1.0.3" - hasown: "npm:^2.0.0" - checksum: 10/aa96db4f809734d26d49b59bc8669d73a0ae792da561514e987735573a1dfaede516cd102f217a078ea2b42d4c4fb1f83d487932cb15d49826b726cc9cd4470b - languageName: node - linkType: hard - -"get-intrinsic@npm:^1.2.3, get-intrinsic@npm:^1.2.4": +"get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.3, get-intrinsic@npm:^1.2.4": version: 1.2.4 resolution: "get-intrinsic@npm:1.2.4" dependencies: @@ -3495,13 +3237,6 @@ __metadata: languageName: node linkType: hard -"get-stream@npm:^6.0.0, get-stream@npm:^6.0.1": - version: 6.0.1 - resolution: "get-stream@npm:6.0.1" - checksum: 10/781266d29725f35c59f1d214aedc92b0ae855800a980800e2923b3fbc4e56b3cb6e462c42e09a1cf1a00c64e056a78fa407cbe06c7c92b7e5cd49b4b85c2a497 - languageName: node - linkType: hard - "glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" @@ -3696,20 +3431,6 @@ __metadata: languageName: node linkType: hard -"human-signals@npm:^2.1.0": - version: 2.1.0 - resolution: "human-signals@npm:2.1.0" - checksum: 10/df59be9e0af479036798a881d1f136c4a29e0b518d4abb863afbd11bf30efa3eeb1d0425fc65942dcc05ab3bf40205ea436b0ff389f2cd20b75b8643d539bf86 - languageName: node - linkType: hard - -"human-signals@npm:^4.3.0": - version: 4.3.1 - resolution: "human-signals@npm:4.3.1" - checksum: 10/fa59894c358fe9f2b5549be2fb083661d5e1dff618d3ac70a49ca73495a72e873fbf6c0878561478e521e17d498292746ee391791db95ffe5747bfb5aef8765b - languageName: node - linkType: hard - "iconv-lite@npm:^0.4.24": version: 0.4.24 resolution: "iconv-lite@npm:0.4.24" @@ -3857,24 +3578,6 @@ __metadata: languageName: node linkType: hard -"is-docker@npm:^2.0.0": - version: 2.2.1 - resolution: "is-docker@npm:2.2.1" - bin: - is-docker: cli.js - checksum: 10/3fef7ddbf0be25958e8991ad941901bf5922ab2753c46980b60b05c1bf9c9c2402d35e6dc32e4380b980ef5e1970a5d9d5e5aa2e02d77727c3b6b5e918474c56 - languageName: node - linkType: hard - -"is-docker@npm:^3.0.0": - version: 3.0.0 - resolution: "is-docker@npm:3.0.0" - bin: - is-docker: cli.js - checksum: 10/b698118f04feb7eaf3338922bd79cba064ea54a1c3db6ec8c0c8d8ee7613e7e5854d802d3ef646812a8a3ace81182a085dfa0a71cc68b06f3fa794b9783b3c90 - languageName: node - linkType: hard - "is-extglob@npm:^2.1.1": version: 2.1.1 resolution: "is-extglob@npm:2.1.1" @@ -3898,17 +3601,6 @@ __metadata: languageName: node linkType: hard -"is-inside-container@npm:^1.0.0": - version: 1.0.0 - resolution: "is-inside-container@npm:1.0.0" - dependencies: - is-docker: "npm:^3.0.0" - bin: - is-inside-container: cli.js - checksum: 10/c50b75a2ab66ab3e8b92b3bc534e1ea72ca25766832c0623ac22d134116a98bcf012197d1caabe1d1c4bd5f84363d4aa5c36bb4b585fbcaf57be172cd10a1a03 - languageName: node - linkType: hard - "is-interactive@npm:^1.0.0": version: 1.0.0 resolution: "is-interactive@npm:1.0.0" @@ -3946,20 +3638,6 @@ __metadata: languageName: node linkType: hard -"is-stream@npm:^2.0.0": - version: 2.0.1 - resolution: "is-stream@npm:2.0.1" - checksum: 10/b8e05ccdf96ac330ea83c12450304d4a591f9958c11fd17bed240af8d5ffe08aedafa4c0f4cfccd4d28dc9d4d129daca1023633d5c11601a6cbc77521f6fae66 - languageName: node - linkType: hard - -"is-stream@npm:^3.0.0": - version: 3.0.0 - resolution: "is-stream@npm:3.0.0" - checksum: 10/172093fe99119ffd07611ab6d1bcccfe8bc4aa80d864b15f43e63e54b7abc71e779acd69afdb854c4e2a67fdc16ae710e370eda40088d1cfc956a50ed82d8f16 - languageName: node - linkType: hard - "is-unicode-supported@npm:^0.1.0": version: 0.1.0 resolution: "is-unicode-supported@npm:0.1.0" @@ -3967,15 +3645,6 @@ __metadata: languageName: node linkType: hard -"is-wsl@npm:^2.2.0": - version: 2.2.0 - resolution: "is-wsl@npm:2.2.0" - dependencies: - is-docker: "npm:^2.0.0" - checksum: 10/20849846ae414997d290b75e16868e5261e86ff5047f104027026fd61d8b5a9b0b3ade16239f35e1a067b3c7cc02f70183cb661010ed16f4b6c7c93dad1b19d8 - languageName: node - linkType: hard - "isexe@npm:^2.0.0": version: 2.0.0 resolution: "isexe@npm:2.0.0" @@ -4312,13 +3981,6 @@ __metadata: languageName: node linkType: hard -"mimic-fn@npm:^4.0.0": - version: 4.0.0 - resolution: "mimic-fn@npm:4.0.0" - checksum: 10/995dcece15ee29aa16e188de6633d43a3db4611bcf93620e7e62109ec41c79c0f34277165b8ce5e361205049766e371851264c21ac64ca35499acb5421c2ba56 - languageName: node - linkType: hard - "minimatch@npm:9.0.3, minimatch@npm:^9.0.1": version: 9.0.3 resolution: "minimatch@npm:9.0.3" @@ -4535,24 +4197,6 @@ __metadata: languageName: node linkType: hard -"npm-run-path@npm:^4.0.1": - version: 4.0.1 - resolution: "npm-run-path@npm:4.0.1" - dependencies: - path-key: "npm:^3.0.0" - checksum: 10/5374c0cea4b0bbfdfae62da7bbdf1e1558d338335f4cacf2515c282ff358ff27b2ecb91ffa5330a8b14390ac66a1e146e10700440c1ab868208430f56b5f4d23 - languageName: node - linkType: hard - -"npm-run-path@npm:^5.1.0": - version: 5.1.0 - resolution: "npm-run-path@npm:5.1.0" - dependencies: - path-key: "npm:^4.0.0" - checksum: 10/dc184eb5ec239d6a2b990b43236845332ef12f4e0beaa9701de724aa797fe40b6bbd0157fb7639d24d3ab13f5d5cf22d223a19c6300846b8126f335f788bee66 - languageName: node - linkType: hard - "once@npm:^1.3.0": version: 1.4.0 resolution: "once@npm:1.4.0" @@ -4562,7 +4206,7 @@ __metadata: languageName: node linkType: hard -"onetime@npm:^5.1.0, onetime@npm:^5.1.2": +"onetime@npm:^5.1.0": version: 5.1.2 resolution: "onetime@npm:5.1.2" dependencies: @@ -4571,27 +4215,6 @@ __metadata: languageName: node linkType: hard -"onetime@npm:^6.0.0": - version: 6.0.0 - resolution: "onetime@npm:6.0.0" - dependencies: - mimic-fn: "npm:^4.0.0" - checksum: 10/0846ce78e440841335d4e9182ef69d5762e9f38aa7499b19f42ea1c4cd40f0b4446094c455c713f9adac3f4ae86f613bb5e30c99e52652764d06a89f709b3788 - languageName: node - linkType: hard - -"open@npm:^9.1.0": - version: 9.1.0 - resolution: "open@npm:9.1.0" - dependencies: - default-browser: "npm:^4.0.0" - define-lazy-prop: "npm:^3.0.0" - is-inside-container: "npm:^1.0.0" - is-wsl: "npm:^2.2.0" - checksum: 10/b45bcc7a6795804a2f560f0ca9f5e5344114bc40754d10c28a811c0c8f7027356979192931a6a7df2ab9e5bab3058988c99ae55f4fb71db2ce9fc77c40f619aa - languageName: node - linkType: hard - "optionator@npm:^0.9.3": version: 0.9.3 resolution: "optionator@npm:0.9.3" @@ -4717,20 +4340,13 @@ __metadata: languageName: node linkType: hard -"path-key@npm:^3.0.0, path-key@npm:^3.1.0": +"path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" checksum: 10/55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 languageName: node linkType: hard -"path-key@npm:^4.0.0": - version: 4.0.0 - resolution: "path-key@npm:4.0.0" - checksum: 10/8e6c314ae6d16b83e93032c61020129f6f4484590a777eed709c4a01b50e498822b00f76ceaf94bc64dbd90b327df56ceadce27da3d83393790f1219e07721d7 - languageName: node - linkType: hard - "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -4805,16 +4421,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^3.0.3": - version: 3.0.3 - resolution: "prettier@npm:3.0.3" - bin: - prettier: bin/prettier.cjs - checksum: 10/ccf1ead9794b017be6b42d0873f459070beef2069eb393c8b4c0d11aa3430acefc54f6d5f44a5b7ce9af05ad8daf694b912f0aa2808d1c22dfa86e61e9d563f8 - languageName: node - linkType: hard - -"prettier@npm:^3.2.5": +"prettier@npm:^3.0.3, prettier@npm:^3.2.5": version: 3.2.5 resolution: "prettier@npm:3.2.5" bin: @@ -5117,15 +4724,6 @@ __metadata: languageName: node linkType: hard -"run-applescript@npm:^5.0.0": - version: 5.0.0 - resolution: "run-applescript@npm:5.0.0" - dependencies: - execa: "npm:^5.0.0" - checksum: 10/d00c2dbfa5b2d774de7451194b8b125f40f65fc183de7d9dcae97f57f59433586d3c39b9001e111c38bfa24c3436c99df1bb4066a2a0c90d39a8c4cd6889af77 - languageName: node - linkType: hard - "run-async@npm:^3.0.0": version: 3.0.0 resolution: "run-async@npm:3.0.0" @@ -5258,7 +4856,7 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": +"signal-exit@npm:^3.0.2": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" checksum: 10/a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 @@ -5403,20 +5001,6 @@ __metadata: languageName: node linkType: hard -"strip-final-newline@npm:^2.0.0": - version: 2.0.0 - resolution: "strip-final-newline@npm:2.0.0" - checksum: 10/69412b5e25731e1938184b5d489c32e340605bb611d6140344abc3421b7f3c6f9984b21dff296dfcf056681b82caa3bb4cc996a965ce37bcfad663e92eae9c64 - languageName: node - linkType: hard - -"strip-final-newline@npm:^3.0.0": - version: 3.0.0 - resolution: "strip-final-newline@npm:3.0.0" - checksum: 10/23ee263adfa2070cd0f23d1ac14e2ed2f000c9b44229aec9c799f1367ec001478469560abefd00c5c99ee6f0b31c137d53ec6029c53e9f32a93804e18c201050 - languageName: node - linkType: hard - "strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -5465,16 +5049,6 @@ __metadata: languageName: node linkType: hard -"synckit@npm:^0.8.5": - version: 0.8.5 - resolution: "synckit@npm:0.8.5" - dependencies: - "@pkgr/utils": "npm:^2.3.1" - tslib: "npm:^2.5.0" - checksum: 10/fb6798a2db2650ca3a2435ad32d4fc14842da807993a1a350b64d267e0e770aa7f26492b119aa7500892d3d07a5af1eec7bfbd6e23a619451558be0f226a6094 - languageName: node - linkType: hard - "synckit@npm:^0.8.6": version: 0.8.8 resolution: "synckit@npm:0.8.8" @@ -5559,13 +5133,6 @@ __metadata: languageName: node linkType: hard -"titleize@npm:^3.0.0": - version: 3.0.0 - resolution: "titleize@npm:3.0.0" - checksum: 10/71fbbeabbfb36ccd840559f67f21e356e1d03da2915b32d2ae1a60ddcc13a124be2739f696d2feb884983441d159a18649e8d956648d591bdad35c430a6b6d28 - languageName: node - linkType: hard - "tmp@npm:^0.0.33": version: 0.0.33 resolution: "tmp@npm:0.0.33" @@ -5977,7 +5544,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.1.0, tslib@npm:^2.5.0, tslib@npm:^2.6.0, tslib@npm:^2.6.2": +"tslib@npm:^2.1.0, tslib@npm:^2.6.2": version: 2.6.2 resolution: "tslib@npm:2.6.2" checksum: 10/bd26c22d36736513980091a1e356378e8b662ded04204453d353a7f34a4c21ed0afc59b5f90719d4ba756e581a162ecbf93118dc9c6be5acf70aa309188166ca @@ -6079,13 +5646,6 @@ __metadata: languageName: node linkType: hard -"untildify@npm:^4.0.0": - version: 4.0.0 - resolution: "untildify@npm:4.0.0" - checksum: 10/39ced9c418a74f73f0a56e1ba4634b4d959422dff61f4c72a8e39f60b99380c1b45ed776fbaa0a4101b157e4310d873ad7d114e8534ca02609b4916bb4187fb9 - languageName: node - linkType: hard - "update-browserslist-db@npm:^1.0.13": version: 1.0.13 resolution: "update-browserslist-db@npm:1.0.13" From 545fcdcf78b2e147e75e918f7b4d62c501904f4b Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:57:57 -0800 Subject: [PATCH 16/53] Fix example esbuild configurations --- examples/gjs/gio-2-cat-alias/esbuild.js | 2 +- examples/gjs/gio-2-cat-packages/esbuild.js | 2 +- examples/gjs/gio-2-cat-promisify/esbuild.js | 2 +- examples/gjs/gio-2-cat-types-only/esbuild.js | 2 +- examples/gjs/gio-2-cat/esbuild.js | 2 +- examples/gjs/gio-2-dbus/esbuild.js | 2 +- examples/gjs/gtk-3-calc/esbuild.js | 2 +- examples/gjs/gtk-3-gettext/esbuild.js | 2 +- examples/gjs/gtk-3-hello-2/esbuild.js | 2 +- examples/gjs/gtk-3-template/esbuild.js | 2 +- examples/gjs/gtk-3-webkit/esbuild.js | 2 +- examples/gjs/gtk-4-application/esbuild.js | 2 +- examples/gjs/gtk-4-custom-widget/esbuild.js | 2 +- examples/gjs/gtk-4-template/esbuild.js | 2 +- examples/gjs/soup-3-http/esbuild.js | 2 +- examples/gjs/soup-3-websocket/esbuild.js | 2 +- examples/gjs/timers/esbuild.js | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/gjs/gio-2-cat-alias/esbuild.js b/examples/gjs/gio-2-cat-alias/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gio-2-cat-alias/esbuild.js +++ b/examples/gjs/gio-2-cat-alias/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-packages/esbuild.js b/examples/gjs/gio-2-cat-packages/esbuild.js index ed1de7599..5d596dfe6 100644 --- a/examples/gjs/gio-2-cat-packages/esbuild.js +++ b/examples/gjs/gio-2-cat-packages/esbuild.js @@ -11,5 +11,5 @@ await build({ // target: firefox102 // Since GJS 1.73.2 format: 'esm', // platform: 'node', - external: ['gi://*', 'gettext', 'system', 'cairo'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-promisify/esbuild.js b/examples/gjs/gio-2-cat-promisify/esbuild.js index 1828892ba..5d596dfe6 100644 --- a/examples/gjs/gio-2-cat-promisify/esbuild.js +++ b/examples/gjs/gio-2-cat-promisify/esbuild.js @@ -11,5 +11,5 @@ await build({ // target: firefox102 // Since GJS 1.73.2 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-types-only/esbuild.js b/examples/gjs/gio-2-cat-types-only/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gio-2-cat-types-only/esbuild.js +++ b/examples/gjs/gio-2-cat-types-only/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat/esbuild.js b/examples/gjs/gio-2-cat/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gio-2-cat/esbuild.js +++ b/examples/gjs/gio-2-cat/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gio-2-dbus/esbuild.js b/examples/gjs/gio-2-dbus/esbuild.js index 4e147bd88..f752460e0 100644 --- a/examples/gjs/gio-2-dbus/esbuild.js +++ b/examples/gjs/gio-2-dbus/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-calc/esbuild.js b/examples/gjs/gtk-3-calc/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-3-calc/esbuild.js +++ b/examples/gjs/gtk-3-calc/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-gettext/esbuild.js b/examples/gjs/gtk-3-gettext/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-3-gettext/esbuild.js +++ b/examples/gjs/gtk-3-gettext/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-hello-2/esbuild.js b/examples/gjs/gtk-3-hello-2/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-3-hello-2/esbuild.js +++ b/examples/gjs/gtk-3-hello-2/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-template/esbuild.js b/examples/gjs/gtk-3-template/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-3-template/esbuild.js +++ b/examples/gjs/gtk-3-template/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-3-webkit/esbuild.js b/examples/gjs/gtk-3-webkit/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-3-webkit/esbuild.js +++ b/examples/gjs/gtk-3-webkit/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-4-application/esbuild.js b/examples/gjs/gtk-4-application/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-4-application/esbuild.js +++ b/examples/gjs/gtk-4-application/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-4-custom-widget/esbuild.js b/examples/gjs/gtk-4-custom-widget/esbuild.js index 1ee1551f2..80c82efe1 100644 --- a/examples/gjs/gtk-4-custom-widget/esbuild.js +++ b/examples/gjs/gtk-4-custom-widget/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/gtk-4-template/esbuild.js b/examples/gjs/gtk-4-template/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/gtk-4-template/esbuild.js +++ b/examples/gjs/gtk-4-template/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/soup-3-http/esbuild.js b/examples/gjs/soup-3-http/esbuild.js index e669e8fba..8dea48125 100644 --- a/examples/gjs/soup-3-http/esbuild.js +++ b/examples/gjs/soup-3-http/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/soup-3-websocket/esbuild.js b/examples/gjs/soup-3-websocket/esbuild.js index 5a7081cb4..25b047d6d 100644 --- a/examples/gjs/soup-3-websocket/esbuild.js +++ b/examples/gjs/soup-3-websocket/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file diff --git a/examples/gjs/timers/esbuild.js b/examples/gjs/timers/esbuild.js index c013b7046..03cb394b5 100644 --- a/examples/gjs/timers/esbuild.js +++ b/examples/gjs/timers/esbuild.js @@ -10,5 +10,5 @@ await build({ // target: "firefox91", // Since GJS 1.71.1 format: 'esm', // platform: 'node', - external: ['gi://*'], + external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], }) \ No newline at end of file From aaef81b3703129bf6ad0fdce69def1770c3361eb Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Thu, 22 Feb 2024 05:19:23 +0100 Subject: [PATCH 17/53] fix(github): Removed nodeLinker: node_modules to fix no space left error on GitHub Action runner --- .yarnrc.yml | 2 -- packages/lib/package.json | 1 + yarn.lock | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index bd95ab27f..c98176faa 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -2,6 +2,4 @@ compressionLevel: mixed enableGlobalCache: false -nodeLinker: node-modules - yarnPath: .yarn/releases/yarn-4.1.0.cjs diff --git a/packages/lib/package.json b/packages/lib/package.json index b8b5a6aa7..3cf730f0c 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -59,6 +59,7 @@ "typescript": "5.2.2" }, "dependencies": { + "@gi.ts/parser": "workspace:^", "colorette": "^2.0.20", "ejs": "^3.1.9", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index 9cf8e22b1..cc8a206e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1144,6 +1144,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ts-for-gir/lib@workspace:packages/lib" dependencies: + "@gi.ts/parser": "workspace:^" "@types/ejs": "npm:^3.1.5" "@types/eslint": "npm:8.56.2" "@types/lodash": "npm:^4.14.202" From 0e03cb9997d3abf46b54df917908761b3714ca38 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:58:53 -0800 Subject: [PATCH 18/53] package: Fix dependencies and exports for lib --- packages/generator-typescript/package.json | 12 +++++++++- packages/generator-typescript/tsconfig.json | 3 +-- packages/lib/package.json | 9 +++++-- packages/lib/tsconfig.json | 1 - packages/parser/package.json | 1 - yarn.lock | 26 ++++++++++----------- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/generator-typescript/package.json b/packages/generator-typescript/package.json index 18e94fda8..21d641577 100644 --- a/packages/generator-typescript/package.json +++ b/packages/generator-typescript/package.json @@ -8,6 +8,12 @@ "engines": { "node": ">=18" }, + "exports": { + ".": { + "types": "./lib/index.d.ts", + "import": "./lib/index.js" + } + }, "scripts": { "build": "yarn lint && yarn build:ts", "build:ts": "tsc", @@ -35,7 +41,9 @@ "generator" ], "devDependencies": { + "@types/ejs": "^3.1.4", "@types/node": "^20.11.18", + "@types/xml2js": "^0", "@typescript-eslint/eslint-plugin": "^7.0.1", "@typescript-eslint/parser": "^7.0.1", "eslint": "^8.56.0", @@ -47,6 +55,8 @@ }, "dependencies": { "@ts-for-gir/generator-base": "workspace:^", - "@ts-for-gir/lib": "workspace:^" + "@ts-for-gir/lib": "workspace:^", + "ejs": "^3.1.9", + "xml2js": "^0.6.2" } } diff --git a/packages/generator-typescript/tsconfig.json b/packages/generator-typescript/tsconfig.json index f4b261da2..af2eba568 100644 --- a/packages/generator-typescript/tsconfig.json +++ b/packages/generator-typescript/tsconfig.json @@ -1,6 +1,5 @@ { - "compilerOptions": { - "lib": ["ESNext"], + "compilerOptions": { "target": "ESNext", "module": "ESNext", "outDir": "lib", diff --git a/packages/lib/package.json b/packages/lib/package.json index 3cf730f0c..4015395f9 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -8,6 +8,12 @@ "engines": { "node": ">=18" }, + "exports": { + ".": { + "types": "./lib/index.d.ts", + "import": "./lib/index.js" + } + }, "scripts": { "build": "yarn lint && yarn build:ts", "build:ts": "tsc", @@ -62,7 +68,6 @@ "@gi.ts/parser": "workspace:^", "colorette": "^2.0.20", "ejs": "^3.1.9", - "lodash": "^4.17.21", - "xml2js": "0.6.2" + "lodash": "^4.17.21" } } diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json index 49f1430da..9ba2b4747 100644 --- a/packages/lib/tsconfig.json +++ b/packages/lib/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "lib": ["ESNext"], "target": "ESNext", "module": "ESNext", "outDir": "lib", diff --git a/packages/parser/package.json b/packages/parser/package.json index 78939d02a..240ad0401 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -31,7 +31,6 @@ "fast-xml-parser": "^3.17.5" }, "devDependencies": { - "@types/xml2js": "^0.4.4", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", "eslint": "^8.52.0", diff --git a/yarn.lock b/yarn.lock index cc8a206e3..54b2ce855 100644 --- a/yarn.lock +++ b/yarn.lock @@ -651,7 +651,6 @@ __metadata: version: 0.0.0-use.local resolution: "@gi.ts/parser@workspace:packages/parser" dependencies: - "@types/xml2js": "npm:^0.4.4" "@typescript-eslint/eslint-plugin": "npm:^6.9.1" "@typescript-eslint/parser": "npm:^6.9.1" eslint: "npm:^8.52.0" @@ -1128,15 +1127,19 @@ __metadata: dependencies: "@ts-for-gir/generator-base": "workspace:^" "@ts-for-gir/lib": "workspace:^" + "@types/ejs": "npm:^3.1.4" "@types/node": "npm:^20.11.18" + "@types/xml2js": "npm:^0" "@typescript-eslint/eslint-plugin": "npm:^7.0.1" "@typescript-eslint/parser": "npm:^7.0.1" + ejs: "npm:^3.1.9" eslint: "npm:^8.56.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-prettier: "npm:^5.1.3" prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" typescript: "npm:5.2.2" + xml2js: "npm:^0.6.2" languageName: unknown linkType: soft @@ -1161,7 +1164,6 @@ __metadata: prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" typescript: "npm:5.2.2" - xml2js: "npm:0.6.2" languageName: unknown linkType: soft @@ -1193,6 +1195,13 @@ __metadata: languageName: node linkType: hard +"@types/ejs@npm:^3.1.4": + version: 3.1.4 + resolution: "@types/ejs@npm:3.1.4" + checksum: 10/9efe68d251a5db17a5d2bd4214d79cae36fc4105bc6199cfcefcd513071e6c46711b6d122785e05589815b04c8e45bfb3688b07cabae64d9c583a1af3cae9696 + languageName: node + linkType: hard + "@types/ejs@npm:^3.1.5": version: 3.1.5 resolution: "@types/ejs@npm:3.1.5" @@ -1302,7 +1311,7 @@ __metadata: languageName: node linkType: hard -"@types/xml2js@npm:^0.4.14": +"@types/xml2js@npm:^0, @types/xml2js@npm:^0.4.14": version: 0.4.14 resolution: "@types/xml2js@npm:0.4.14" dependencies: @@ -1311,15 +1320,6 @@ __metadata: languageName: node linkType: hard -"@types/xml2js@npm:^0.4.4": - version: 0.4.13 - resolution: "@types/xml2js@npm:0.4.13" - dependencies: - "@types/node": "npm:*" - checksum: 10/3dda8f82d86ac16d14b9da9125f2f4ea5a5c8958324daa744c0eb7d6d7f975d7c62dd5e1ac8a40bf8fdcf1b73f3f7bc39f4bd72c89c0c2f0a8d7711c8dfa91d4 - languageName: node - linkType: hard - "@types/yargs-parser@npm:*": version: 21.0.2 resolution: "@types/yargs-parser@npm:21.0.2" @@ -5899,7 +5899,7 @@ __metadata: languageName: node linkType: hard -"xml2js@npm:0.6.2": +"xml2js@npm:^0.6.2": version: 0.6.2 resolution: "xml2js@npm:0.6.2" dependencies: From f168168ab74310853da03ca0a6262cce88c989b0 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:59:23 -0800 Subject: [PATCH 19/53] Add Prettier extension as recommended --- ts-for-gir.code-workspace | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ts-for-gir.code-workspace b/ts-for-gir.code-workspace index 13d49ac8f..76e2be3ad 100644 --- a/ts-for-gir.code-workspace +++ b/ts-for-gir.code-workspace @@ -1,6 +1,6 @@ { "extensions": { - "recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint"], + "recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"], }, "launch": { "version": "0.2.0", @@ -628,6 +628,8 @@ "window.zoomLevel": "undefined", }, "typescript.tsdk": ".yarn/sdks/typescript/lib", + "eslint.nodePath": ".yarn/sdks", + "prettier.prettierPath": ".yarn/sdks/prettier/index.cjs", "files.exclude": { "**/.git": true, "**/.svn": true, From 2fc48304f1d4ffa60d8b9be3d3b624324f9028ea Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Thu, 22 Feb 2024 22:03:46 +0100 Subject: [PATCH 20/53] Removed environments, moduleType and package options Environment is always GJS. Module type is always ESM and NPM package build is always true now --- .ts-for-gir.packages-all.rc.js | 5 +- .../gjs/gio-2-cat-alias/.ts-for-girrc.json | 3 - .../gio-2-cat-promisify/.ts-for-girrc.json | 3 - .../gio-2-cat-types-only/.ts-for-girrc.json | 3 - packages/cli/README.md | 8 - packages/cli/package.json | 2 +- packages/cli/src/commands/doc.ts | 36 ++-- packages/cli/src/commands/generate.ts | 32 ++- packages/cli/src/config.ts | 95 +-------- packages/cli/src/generation-handler.ts | 4 +- packages/cli/src/module-loader.ts | 2 +- packages/generator-base/package.json | 2 +- packages/generator-html-doc/package.json | 2 +- .../src/html-doc-generator.ts | 2 +- packages/generator-typescript/package.json | 2 +- .../src/package-data-parser.ts | 2 +- .../src/template-processor.ts | 23 +-- .../src/type-definition-generator.ts | 188 +++++++----------- .../templates/gjs/ambient.d.ts | 40 ---- .../templates/gjs/cairo.d.ts | 4 - .../templates/gjs/cairo.js | 7 - .../templates/gjs/gettext.js | 7 - .../generator-typescript/templates/gjs/gjs.js | 6 - .../templates/gjs/module-ambient.d.ts | 18 +- .../templates/gjs/module-import.d.ts | 18 +- .../templates/gjs/module.d.ts | 2 - .../templates/gjs/module.js | 14 +- .../templates/gjs/system.js | 9 +- .../templates/node-gtk/ambient.js | 5 - .../templates/node-gtk/module-import.js | 10 - .../templates/package.json | 100 +--------- .../templates/tsconfig.json | 4 - packages/lib/package.json | 2 +- packages/lib/src/conflict-resolver.ts | 10 +- packages/lib/src/constants.ts | 20 +- packages/lib/src/dependency-manager.ts | 14 +- packages/lib/src/generators/dts-modules.ts | 5 +- packages/lib/src/gir-factory.ts | 24 +-- packages/lib/src/gir-module.ts | 6 +- packages/lib/src/injection/injector.ts | 11 +- packages/lib/src/logger.ts | 9 +- packages/lib/src/messages.ts | 7 +- packages/lib/src/symtable.ts | 2 +- packages/lib/src/transformation.ts | 99 ++------- packages/lib/src/types/build-type.ts | 1 - packages/lib/src/types/environment.ts | 1 - packages/lib/src/types/generate-config.ts | 10 - packages/lib/src/types/index.ts | 3 - packages/lib/src/types/module-type.ts | 1 - packages/lib/src/types/transformations.ts | 6 +- packages/lib/src/types/user-config.ts | 10 - 51 files changed, 211 insertions(+), 688 deletions(-) delete mode 100644 packages/generator-typescript/templates/node-gtk/ambient.js delete mode 100644 packages/generator-typescript/templates/node-gtk/module-import.js delete mode 100644 packages/lib/src/types/build-type.ts delete mode 100644 packages/lib/src/types/environment.ts delete mode 100644 packages/lib/src/types/module-type.ts diff --git a/.ts-for-gir.packages-all.rc.js b/.ts-for-gir.packages-all.rc.js index 1ee96df92..5dd31138b 100644 --- a/.ts-for-gir.packages-all.rc.js +++ b/.ts-for-gir.packages-all.rc.js @@ -1,6 +1,5 @@ export default { - outdir: './types-next', - environments: ['gjs'], + outdir: './types', modules: ['*'], girDirectories: [ // General gir files in this repository @@ -49,9 +48,7 @@ export default { 'Colorhug-1.0', // Duplicate of ColorHug-1.0 'GUPnP-DLNA-1.0', // Same namespace as GUPnP-1.0.gir, is this a bug or should we merge the type definitions? ], - moduleType: 'esm', ignoreVersionConflicts: true, promisify: true, - package: true, packageYarn: true, } diff --git a/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json b/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json index da43cd95f..21688bbbd 100644 --- a/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json +++ b/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json @@ -1,8 +1,5 @@ { - "environments": ["gjs"], "modules": ["Gio-2.0"], - "buildType": "lib", - "moduleType": "esm", "noNamespace": false, "outdir": "./@types", "generateAlias": true diff --git a/examples/gjs/gio-2-cat-promisify/.ts-for-girrc.json b/examples/gjs/gio-2-cat-promisify/.ts-for-girrc.json index 5073467a4..b301d99e1 100644 --- a/examples/gjs/gio-2-cat-promisify/.ts-for-girrc.json +++ b/examples/gjs/gio-2-cat-promisify/.ts-for-girrc.json @@ -1,8 +1,5 @@ { - "environments": ["gjs"], "modules": ["Gio-2.0"], - "buildType": "lib", - "moduleType": "esm", "noNamespace": false, "outdir": "./@types", "generateAlias": true, diff --git a/examples/gjs/gio-2-cat-types-only/.ts-for-girrc.json b/examples/gjs/gio-2-cat-types-only/.ts-for-girrc.json index 3035735ee..a109f0017 100644 --- a/examples/gjs/gio-2-cat-types-only/.ts-for-girrc.json +++ b/examples/gjs/gio-2-cat-types-only/.ts-for-girrc.json @@ -1,7 +1,4 @@ { - "environments": ["gjs"], "modules": ["Gio-2.0"], - "buildType": "types", - "moduleType": "esm", "outdir": "./@types" } \ No newline at end of file diff --git a/packages/cli/README.md b/packages/cli/README.md index 88fc6f130..7fc0aac3f 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -99,14 +99,8 @@ Options: [string] [default: "/home/jumplink/Projekte/ts-for-gir"] -o, --outdir Directory to output to [string] [default: "./@types"] - -e, --environments Javascript environment - [array] [choices: "gjs", "node"] [default: ["gjs"]] -i, --ignore Modules that should be ignored [array] [default: []] - -b, --buildType Definitions generation type - [string] [choices: "lib", "types"] [default: "lib"] - -t, --moduleType Specify what module code is generated. - [string] [choices: "esm", "commonjs", "cjs"] [default: "esm"] -v, --verbose Switch on/off the verbose mode [string] [default: false] --ignoreVersionConflicts Do not ask for package versions if multiple vers @@ -129,8 +123,6 @@ Options: calls [string] [default: true] --npmScope Scope of the generated NPM packages [string] [default: "@girs"] - --package Generates an NPM compatible packages for each GI - R module [string] [default: false] Examples: ts-for-gir generate Run 'ts-for-gir generate' in your gj diff --git a/packages/cli/package.json b/packages/cli/package.json index 5ee13a3e2..821e9fe63 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/cli", - "version": "3.2.8", + "version": "4.0.0", "description": "TypeScript type definition generator for GObject introspection GIR files", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/cli/src/commands/doc.ts b/packages/cli/src/commands/doc.ts index 4a919d974..8e84a18bf 100644 --- a/packages/cli/src/commands/doc.ts +++ b/packages/cli/src/commands/doc.ts @@ -28,27 +28,23 @@ const builder: BuilderCallback = (yargs: Argv) => { const handler = async (args: ConfigFlags) => { const config = await Config.load(args) - for (let i = 0; i < config.environments.length; i++) { - if (config.environments[i]) { - const generateConfig = Config.getGenerateConfig(config, config.environments[i]) - const moduleLoader = new ModuleLoader(generateConfig) - const { keep } = await moduleLoader.getModulesResolved( - config.modules, - config.ignore || [], - config.ignoreVersionConflicts, - ) - if (keep.length === 0) { - return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) - } - const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC) - const registry = moduleLoader.dependencyManager.registry - - await tsForGir.start( - Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module), - registry, - ) - } + const generateConfig = Config.getGenerateConfig(config) + const moduleLoader = new ModuleLoader(generateConfig) + const { keep } = await moduleLoader.getModulesResolved( + config.modules, + config.ignore || [], + config.ignoreVersionConflicts, + ) + if (keep.length === 0) { + return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) } + const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC) + const registry = moduleLoader.dependencyManager.registry + + await tsForGir.start( + Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module), + registry, + ) } const examples: ReadonlyArray<[string, string?]> = [] diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index 0930e9627..3c073c4c9 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -30,25 +30,23 @@ const builder: BuilderCallback = (yargs: Argv) => { const handler = async (args: ConfigFlags) => { const config = await Config.load(args) - for (const env of config.environments) { - const generateConfig = Config.getGenerateConfig(config, env) - const moduleLoader = new ModuleLoader(generateConfig) - const { keep } = await moduleLoader.getModulesResolved( - config.modules, - config.ignore || [], - config.ignoreVersionConflicts, - ) - if (keep.length === 0) { - return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) - } - const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES) + const generateConfig = Config.getGenerateConfig(config) + const moduleLoader = new ModuleLoader(generateConfig) + const { keep } = await moduleLoader.getModulesResolved( + config.modules, + config.ignore || [], + config.ignoreVersionConflicts, + ) + if (keep.length === 0) { + return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) + } + const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES) - const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module) - // const girModulesGrouped = Object.values(grouped) + const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module) + // const girModulesGrouped = Object.values(grouped) - moduleLoader.dependencyManager.registry.registerFormatter('dts', new TypeScriptFormatter()) - await tsForGir.start(girModules, moduleLoader.dependencyManager.registry) - } + moduleLoader.dependencyManager.registry.registerFormatter('dts', new TypeScriptFormatter()) + await tsForGir.start(girModules, moduleLoader.dependencyManager.registry) } const examples: ReadonlyArray<[string, string?]> = [ diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts index d9e9703ad..1272e4003 100644 --- a/packages/cli/src/config.ts +++ b/packages/cli/src/config.ts @@ -6,18 +6,9 @@ import { Options } from 'yargs' import { cosmiconfig, Options as ConfigSearchOptions } from 'cosmiconfig' import { join, extname, dirname, resolve } from 'path' import { writeFile } from 'fs/promises' -import { - merge, - isEqual, - Logger, - APP_NAME, - APP_USAGE, - ERROR_CONFIG_EXTENSION_UNSUPPORTED, - WARN_USE_ESM_FOR_ALIAS, - WARN_USE_GJS_FOR_ALIAS, -} from '@ts-for-gir/lib' +import { merge, isEqual, Logger, APP_NAME, APP_USAGE, ERROR_CONFIG_EXTENSION_UNSUPPORTED } from '@ts-for-gir/lib' -import type { Environment, UserConfig, ConfigFlags, UserConfigLoadResult, GenerateConfig } from '@ts-for-gir/lib' +import type { UserConfig, ConfigFlags, UserConfigLoadResult, GenerateConfig } from '@ts-for-gir/lib' export class Config { static appName = APP_NAME @@ -28,7 +19,6 @@ export class Config { * Default cli flag and argument values */ static defaults = { - environments: ['gjs'], print: false, configName: '.ts-for-girrc.js', root: process.cwd(), @@ -39,15 +29,12 @@ export class Config { verbose: false, ignoreVersionConflicts: false, noNamespace: false, - buildType: 'lib', - moduleType: 'esm', noComments: false, noDebugComments: false, fixConflicts: true, generateAlias: false, promisify: true, npmScope: '@girs', - package: false, packageYarn: false, } @@ -84,15 +71,6 @@ export class Config { default: Config.defaults.outdir, normalize: true, }, - environments: { - type: 'string', - alias: 'e', - description: 'Javascript environment', - array: true, - choices: ['gjs'], - default: Config.defaults.environments, - normalize: true, - }, ignore: { type: 'string', alias: 'i', @@ -101,23 +79,6 @@ export class Config { default: Config.defaults.ignore, normalize: true, }, - buildType: { - type: 'string', - alias: 'b', - description: 'Definitions generation type', - array: false, - choices: ['lib', 'types'], - default: Config.defaults.buildType, - normalize: true, - }, - moduleType: { - type: 'string', - alias: 't', - description: 'Specify what module code is generated.', - choices: ['esm', 'commonjs', 'cjs'], - default: Config.defaults.moduleType, - normalize: true, - }, verbose: { type: 'boolean', alias: 'v', @@ -189,12 +150,6 @@ export class Config { default: Config.defaults.npmScope, normalize: true, }, - package: { - type: 'boolean', - description: 'Generates an NPM compatible packages for each GIR module', - default: Config.defaults.package, - normalize: true, - }, packageYarn: { type: 'boolean', description: 'Adds Yarn workspace support to the NPM packages', @@ -211,10 +166,7 @@ export class Config { girDirectories: this.options.girDirectories, root: this.options.root, outdir: this.options.outdir, - environments: this.options.environments, ignore: this.options.ignore, - buildType: this.options.buildType, - moduleType: this.options.moduleType, verbose: this.options.verbose, ignoreVersionConflicts: this.options.ignoreVersionConflicts, print: this.options.print, @@ -226,7 +178,6 @@ export class Config { generateAlias: this.options.generateAlias, promisify: this.options.promisify, npmScope: this.options.npmScope, - package: this.options.package, packageYarn: this.options.packageYarn, } @@ -242,7 +193,6 @@ export class Config { modules: this.options.modules, girDirectories: Config.options.girDirectories, outdir: Config.options.outdir, - environments: Config.options.environments, ignore: Config.options.ignore, verbose: Config.options.verbose, ignoreVersionConflicts: Config.options.ignoreVersionConflicts, @@ -313,15 +263,12 @@ export class Config { return configFile } - public static getGenerateConfig(config: UserConfig, environment: Environment = 'gjs'): GenerateConfig { + public static getGenerateConfig(config: UserConfig): GenerateConfig { const generateConfig: GenerateConfig = { - environment: environment, girDirectories: config.girDirectories, root: config.root, outdir: config.outdir, verbose: config.verbose, - buildType: config.buildType, - moduleType: config.moduleType, noNamespace: config.noNamespace, noComments: config.noComments, noDebugComments: config.noDebugComments, @@ -329,7 +276,6 @@ export class Config { generateAlias: config.generateAlias, promisify: config.promisify, npmScope: config.npmScope, - package: config.package, packageYarn: config.packageYarn, noPrettyPrint: false, noAdvancedVariants: true, @@ -338,17 +284,6 @@ export class Config { } public static validate(config: UserConfig): UserConfig { - if (config.generateAlias) { - if (!config.environments.includes('gjs')) { - Logger.warn(WARN_USE_GJS_FOR_ALIAS) - config.environments.push('gjs') - } - if (config.moduleType !== 'esm') { - Logger.warn(WARN_USE_ESM_FOR_ALIAS) - config.moduleType = 'esm' - } - } - return config } @@ -362,9 +297,6 @@ export class Config { const configFileData = configFile?.config || {} const config: UserConfig = { - environments: options.environments, - buildType: options.buildType, - moduleType: options.moduleType, verbose: options.verbose, ignoreVersionConflicts: options.ignoreVersionConflicts, print: options.print, @@ -380,23 +312,10 @@ export class Config { generateAlias: options.generateAlias, promisify: options.promisify, npmScope: options.npmScope, - package: options.package, packageYarn: options.packageYarn, } if (configFileData) { - // environments - if (isEqual(config.environments, Config.defaults.environments) && configFileData.environments) { - config.environments = configFileData.environments - } - // buildType - if (config.buildType === Config.options.buildType.default && configFileData.buildType) { - config.buildType = configFileData.buildType - } - // moduleType - if (config.moduleType === Config.options.moduleType.default && configFileData.moduleType) { - config.moduleType = configFileData.moduleType - } // verbose if (config.verbose === Config.options.verbose.default && typeof configFileData.verbose === 'boolean') { config.verbose = configFileData.verbose @@ -487,10 +406,6 @@ export class Config { if (config.npmScope === Config.options.npmScope.default && configFileData.npmScope) { config.npmScope = configFileData.npmScope } - // package - if (config.package === Config.options.package.default && typeof configFileData.package === 'boolean') { - config.package = configFileData.package - } // packageYarn if ( config.packageYarn === Config.options.packageYarn.default && @@ -500,10 +415,6 @@ export class Config { } } - if ((config.moduleType as string) === 'commonjs') { - config.moduleType = 'cjs' - } - // If outdir is not absolute, make it absolute to the root path if (config.outdir && !config.outdir?.startsWith('/')) { config.outdir = resolve(config.root, config.outdir) diff --git a/packages/cli/src/generation-handler.ts b/packages/cli/src/generation-handler.ts index d8ef4a3b5..ec692ecb3 100644 --- a/packages/cli/src/generation-handler.ts +++ b/packages/cli/src/generation-handler.ts @@ -22,7 +22,7 @@ export class GenerationHandler { private readonly config: GenerateConfig, type: GeneratorType, ) { - this.log = new Logger(config.environment, config.verbose, 'GenerationHandler') + this.log = new Logger(config.verbose, 'GenerationHandler') switch (type) { case GeneratorType.TYPES: @@ -37,7 +37,7 @@ export class GenerationHandler { } public async start(girModules: GirModule[], registry: NSRegistry): Promise { - this.log.info(START_MODULE(this.config.environment, this.config.buildType)) + this.log.info(START_MODULE) if (girModules.length == 0) { this.log.error(ERROR_NO_MODULE_SPECIFIED) diff --git a/packages/cli/src/module-loader.ts b/packages/cli/src/module-loader.ts index 88fdbda8a..c0ab1a04d 100644 --- a/packages/cli/src/module-loader.ts +++ b/packages/cli/src/module-loader.ts @@ -36,7 +36,7 @@ export class ModuleLoader { /** Transitive module dependencies */ modDependencyMap: DependencyMap = {} constructor(protected readonly config: GenerateConfig) { - this.log = new Logger('', config.verbose, 'ModuleLoader') + this.log = new Logger(config.verbose, 'ModuleLoader') this.dependencyManager = DependencyManager.getInstance(config) } diff --git a/packages/generator-base/package.json b/packages/generator-base/package.json index 7da29e89a..aef892d07 100644 --- a/packages/generator-base/package.json +++ b/packages/generator-base/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/generator-base", - "version": "3.2.8", + "version": "4.0.0", "description": "Base generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-html-doc/package.json b/packages/generator-html-doc/package.json index 80e1fbebc..784fe5f04 100644 --- a/packages/generator-html-doc/package.json +++ b/packages/generator-html-doc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/generator-html-doc", - "version": "3.2.8", + "version": "4.0.0", "description": "HTML Documentation generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-html-doc/src/html-doc-generator.ts b/packages/generator-html-doc/src/html-doc-generator.ts index d262cf8f2..95ca2391b 100644 --- a/packages/generator-html-doc/src/html-doc-generator.ts +++ b/packages/generator-html-doc/src/html-doc-generator.ts @@ -10,7 +10,7 @@ import type { GenerateConfig, GirModule, NSRegistry } from '@ts-for-gir/lib' export class HtmlDocGenerator implements Generator { protected log: Logger constructor(protected readonly config: GenerateConfig) { - this.log = new Logger(config.environment, config.verbose, HtmlDocGenerator.name) + this.log = new Logger(config.verbose, HtmlDocGenerator.name) } async start(_registry: NSRegistry): Promise { diff --git a/packages/generator-typescript/package.json b/packages/generator-typescript/package.json index 21d641577..6be21a5bb 100644 --- a/packages/generator-typescript/package.json +++ b/packages/generator-typescript/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/generator-typescript", - "version": "3.2.8", + "version": "4.0.0", "description": "TypeScript type definition generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-typescript/src/package-data-parser.ts b/packages/generator-typescript/src/package-data-parser.ts index 4d1c076f4..1dbb1fba1 100644 --- a/packages/generator-typescript/src/package-data-parser.ts +++ b/packages/generator-typescript/src/package-data-parser.ts @@ -17,7 +17,7 @@ export class PackageDataParser { protected packages: PackageData[] = [] constructor(protected readonly config: GenerateConfig) { - this.log = new Logger('', config.verbose, 'ModuleLoader') + this.log = new Logger(config.verbose, 'ModuleLoader') } public get(name: string): PackageData | undefined { diff --git a/packages/generator-typescript/src/template-processor.ts b/packages/generator-typescript/src/template-processor.ts index c22adc08e..6b1a4d94a 100644 --- a/packages/generator-typescript/src/template-processor.ts +++ b/packages/generator-typescript/src/template-processor.ts @@ -21,7 +21,7 @@ import { Transformation, } from '@ts-for-gir/lib' -import type { GenerateConfig, Dependency, TemplateData, Environment } from '@ts-for-gir/lib' +import type { GenerateConfig, Dependency, TemplateData } from '@ts-for-gir/lib' const TEMPLATE_DIR = join(__dirname, '../templates') @@ -48,8 +48,8 @@ export class TemplateProcessor { APP_USAGE, APP_SOURCE, APP_VERSION, - PACKAGE_DESC: PACKAGE_DESC(packageName, this.config.environment, this.data?.girModule?.libraryVersion), - PACKAGE_KEYWORDS: PACKAGE_KEYWORDS(packageName, this.config.environment), + PACKAGE_DESC: PACKAGE_DESC(packageName, this.data?.girModule?.libraryVersion), + PACKAGE_KEYWORDS: PACKAGE_KEYWORDS(packageName), importName: this.transformation.transformImportName(packageName), dep, deps, @@ -57,8 +57,8 @@ export class TemplateProcessor { join, dirname, } - this.environmentTemplateDir = this.getEnvironmentDir(config.environment, TEMPLATE_DIR) - this.log = new Logger(config.environment, config.verbose, this.packageName) + this.environmentTemplateDir = this.getEnvironmentDir(TEMPLATE_DIR) + this.log = new Logger(config.verbose, this.packageName) } /** @@ -67,11 +67,10 @@ export class TemplateProcessor { * @param baseDir The base directory * @returns The path to the directory */ - protected getEnvironmentDir = (environment: Environment, baseDir: string): string => { - if (!baseDir.endsWith(environment)) - if (environment === 'gjs' && !baseDir.endsWith('/gjs')) { - return join(baseDir, 'gjs') - } + protected getEnvironmentDir = (baseDir: string): string => { + if (!baseDir.endsWith('/gjs')) { + return join(baseDir, 'gjs') + } return baseDir } @@ -193,9 +192,7 @@ export class TemplateProcessor { } public getOutputPath(baseOutputPath: string, outputFilename: string, prependEnv = true): string { - const filePath = this.config.package - ? join(this.data?.importName || this.packageName, outputFilename) - : outputFilename + const filePath = join(this.data?.importName || this.packageName, outputFilename) const outputPath = prependEnv ? getDestPath(baseOutputPath, filePath) : join(baseOutputPath, filePath) return outputPath } diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index cf9893483..5cd082026 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -99,11 +99,9 @@ class ModuleGenerator extends FormatGenerator { this.config = config - this.log = new Logger(this.config.environment, this.config.verbose, TypeDefinitionGenerator.name) + this.log = new Logger(this.config.verbose, TypeDefinitionGenerator.name) this.dependencyManager = DependencyManager.getInstance(this.config) - if (this.config.package) { - this.packageData = new PackageDataParser(this.config) - } + this.packageData = new PackageDataParser(this.config) const girModule = namespace let pkgData: PackageData | undefined if (this.packageData) { @@ -1388,23 +1386,14 @@ class ModuleGenerator extends FormatGenerator { // let target = `${girModule.importName}.d.ts` - // if (this.overrideConfig.moduleType) { - // if (this.overrideConfig.moduleType === 'cjs') { - // target = `${girModule.importName}.d.cts` - // } else { // target = `${girModule.importName}.d.mts` - // } - // } const out: string[] = [] out.push(...this.addTSDocCommentLines([girModule.packageName])) out.push('') - - // if (this.config.environment === 'gjs') { // out.push(...this.generateModuleDependenciesImport('Gjs') - // } // Module dependencies as type references or imports // TODO: Move to template @@ -1447,60 +1436,58 @@ class ModuleGenerator extends FormatGenerator { out.push(append + prepend) } - if (this.config.environment === 'gjs') { - // Properties added to every GIRepositoryNamespace - // https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L186-190 - out.push( - ...this.generateConst( - new IntrospectedConstant({ - // TODO: - doc: printGirDocComment( - { - text: 'Name of the imported GIR library', - tags: [ - { - text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188', - tagName: 'see', - paramName: '', - }, - ], - }, - this.config, - ), - namespace: this.namespace, - value: null, - name: '__name__', - type: new NativeType('string'), - // isInjected: false, - // tsTypeName: 'constant', - // girTypeName: 'constant', - }), - 0, - ), - ...this.generateConst( - new IntrospectedConstant({ - doc: printGirDocComment( - { - text: 'Version of the imported GIR library', - tags: [ - { - text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189', - tagName: 'see', - paramName: '', - }, - ], - }, - this.config, - ), - namespace: this.namespace, - name: '__version__', - type: new NativeType('string'), - value: null, - }), - 0, - ), - ) - } + // Properties added to every GIRepositoryNamespace + // https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L186-190 + out.push( + ...this.generateConst( + new IntrospectedConstant({ + // TODO: + doc: printGirDocComment( + { + text: 'Name of the imported GIR library', + tags: [ + { + text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188', + tagName: 'see', + paramName: '', + }, + ], + }, + this.config, + ), + namespace: this.namespace, + value: null, + name: '__name__', + type: new NativeType('string'), + // isInjected: false, + // tsTypeName: 'constant', + // girTypeName: 'constant', + }), + 0, + ), + ...this.generateConst( + new IntrospectedConstant({ + doc: printGirDocComment( + { + text: 'Version of the imported GIR library', + tags: [ + { + text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189', + tagName: 'see', + paramName: '', + }, + ], + }, + this.config, + ), + namespace: this.namespace, + name: '__version__', + type: new NativeType('string'), + value: null, + }), + 0, + ), + ) } // END Namespace if (!this.config.noNamespace) { @@ -1622,23 +1609,15 @@ class ModuleGenerator extends FormatGenerator { // ) await this.exportModuleTS() - if (this.config.buildType === 'lib') { - await this.exportModuleJS(girModule) - } + await this.exportModuleJS(girModule) await this.exportModuleAmbientTS(girModule) - if (this.config.buildType === 'lib') { - await this.exportModuleAmbientJS(girModule) - } + await this.exportModuleAmbientJS(girModule) await this.exportModuleImportTS(girModule) - if (this.config.buildType === 'lib') { - await this.exportModuleImportJS(girModule) - } + await this.exportModuleImportJS(girModule) - if (this.config.package) { - await this.exportNPMPackage(girModule.importName) - } + await this.exportNPMPackage(girModule.importName) } } @@ -1653,11 +1632,9 @@ export class TypeDefinitionGenerator implements Generator { * @param _config The config to use without the override config */ constructor(readonly config: GenerateConfig) { - this.log = new Logger(this.config.environment, this.config.verbose, TypeDefinitionGenerator.name) + this.log = new Logger(this.config.verbose, TypeDefinitionGenerator.name) this.dependencyManager = DependencyManager.getInstance(this.config) - if (this.config.package) { - this.packageData = new PackageDataParser(this.config) - } + this.packageData = new PackageDataParser(this.config) } /** @@ -1693,47 +1670,34 @@ export class TypeDefinitionGenerator implements Generator { const templateProcessor = new TemplateProcessor(registry, packageName, dependencies, this.config) - // TS await templateProcessor.create('gjs.d.ts', this.config.outdir, 'gjs.d.ts') + await templateProcessor.create('gjs.js', this.config.outdir, 'gjs.js') + await templateProcessor.create('gettext.d.ts', this.config.outdir, 'gettext.d.ts') + await templateProcessor.create('gettext.js', this.config.outdir, 'gettext.js') + await templateProcessor.create('system.d.ts', this.config.outdir, 'system.d.ts') - await templateProcessor.create('cairo.d.ts', this.config.outdir, 'cairo.d.ts') + await templateProcessor.create('system.js', this.config.outdir, 'system.js') - // JS - if (this.config.buildType === 'lib') { - await templateProcessor.create('gjs.js', this.config.outdir, 'gjs.js') - await templateProcessor.create('gettext.js', this.config.outdir, 'gettext.js') - await templateProcessor.create('system.js', this.config.outdir, 'system.js') - await templateProcessor.create('cairo.js', this.config.outdir, 'cairo.js') - } + await templateProcessor.create('cairo.d.ts', this.config.outdir, 'cairo.d.ts') + await templateProcessor.create('cairo.js', this.config.outdir, 'cairo.js') // Import ambient types await templateProcessor.create('ambient.d.ts', this.config.outdir, 'ambient.d.ts') - if (this.config.buildType === 'lib') { - await templateProcessor.create('ambient.js', this.config.outdir, 'ambient.js') - } + await templateProcessor.create('ambient.js', this.config.outdir, 'ambient.js') // DOM types await templateProcessor.create('dom.d.ts', this.config.outdir, 'dom.d.ts') - if (this.config.buildType === 'lib') { - await templateProcessor.create('dom.js', this.config.outdir, 'dom.js') - } + await templateProcessor.create('dom.js', this.config.outdir, 'dom.js') // Import ambient path alias if (this.config.generateAlias) { - if (this.config.package) { - // Write tsconfig.alias.json to the root of the package - await templateProcessor.create('tsconfig.alias.json', this.config.outdir, 'tsconfig.alias.json', true) - } else { - // Write tsconfig.alias.json to the root of the project - await templateProcessor.create('tsconfig.alias.json', './', 'tsconfig.alias.json', false) - } + // Write tsconfig.alias.json to the root of the package + await templateProcessor.create('tsconfig.alias.json', this.config.outdir, 'tsconfig.alias.json', true) } // Package - if (this.config.package) { - await this.module.exportNPMPackage('Gjs') - } + await this.module.exportNPMPackage('Gjs') } public async generate(registry: NSRegistry, module: GirModule) { @@ -1744,15 +1708,13 @@ export class TypeDefinitionGenerator implements Generator { public async start() { // this.dependencyManager.addAll(girModules) - if (this.config.package && this.packageData) { + if (this.packageData) { await this.packageData.start() } } public async finish(registry: NSRegistry) { - if (this.config.environment === 'gjs') { - // GJS internal stuff - await this.exportGjs(this.dependencyManager.core(), registry) - } + // GJS internal stuff + await this.exportGjs(this.dependencyManager.core(), registry) } } diff --git a/packages/generator-typescript/templates/gjs/ambient.d.ts b/packages/generator-typescript/templates/gjs/ambient.d.ts index c2b71d36c..076347535 100644 --- a/packages/generator-typescript/templates/gjs/ambient.d.ts +++ b/packages/generator-typescript/templates/gjs/ambient.d.ts @@ -2,58 +2,18 @@ // https://stackoverflow.com/questions/45099605/ambient-declaration-with-an-imported-type-in-typescript declare module 'gettext' { - <%_ if(package){ _%> export * from '@girs/gjs/gettext'; import Gettext from '@girs/gjs/gettext'; export default Gettext; - <%_ } else { _%> - const Gettext: typeof import('./gettext.js').default; - export default Gettext; - - export const LocaleCategory: typeof import('./gettext.js').LocaleCategory; - export const setlocale: typeof import('./gettext.js').setlocale; - export const textdomain: typeof import('./gettext.js').textdomain; - export const bindtextdomain: typeof import('./gettext.js').bindtextdomain; - export const gettext: typeof import('./gettext.js').gettext; - export const dgettext: typeof import('./gettext.js').dgettext; - export const dcgettext: typeof import('./gettext.js').dcgettext; - export const ngettext: typeof import('./gettext.js').ngettext; - export const dngettext: typeof import('./gettext.js').dngettext; - export const pgettext: typeof import('./gettext.js').pgettext; - export const dpgettext: typeof import('./gettext.js').dpgettext; - export const domain: typeof import('./gettext.js').domain; - <%_ } _%> } declare module 'system' { - <%_ if(package){ _%> export * from '@girs/gjs/system'; import System from '@girs/gjs/system'; export default System; - <%_ } else { _%> - const System: typeof import('./system.js').default; - export default System; - - export const programInvocationName: typeof import('./system.js').programInvocationName; - export const version: typeof import('./system.js').version; - export const programPath: typeof import('./system.js').programPath; - export const programArgs: typeof import('./system.js').programArgs; - export const exit: typeof import('./system.js').exit; - export const addressOfGObject: typeof import('./system.js').addressOfGObject; - export const addressOf: typeof import('./system.js').addressOf; - export const gc: typeof import('./system.js').gc; - export const refcount: typeof import('./system.js').refcount; - export const dumpHeap: typeof import('./system.js').dumpHeap; - export const dumpMemoryInfo: typeof import('./system.js').dumpMemoryInfo; - <%_ } _%> } declare module 'cairo' { - <%_ if(package){ _%> import Cairo from '@girs/gjs/cairo'; export default Cairo; - <%_ } else { _%> - const Cairo: typeof import('./cairo.js').default; - export default Cairo; - <%_ } _%> } \ No newline at end of file diff --git a/packages/generator-typescript/templates/gjs/cairo.d.ts b/packages/generator-typescript/templates/gjs/cairo.d.ts index baef09465..ffa123cf6 100644 --- a/packages/generator-typescript/templates/gjs/cairo.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo.d.ts @@ -2,7 +2,3 @@ declare const Cairo: any; export default Cairo; - -<% if(moduleType === 'cjs') { %> - // TODO declare named exports here, cairo doesn't have named exports for its esm module but for cjs we can use `const { Context } = imports.cairo` for that, see `./cairo.js` -<% } %> diff --git a/packages/generator-typescript/templates/gjs/cairo.js b/packages/generator-typescript/templates/gjs/cairo.js index 27b66d93f..d7942a4a0 100644 --- a/packages/generator-typescript/templates/gjs/cairo.js +++ b/packages/generator-typescript/templates/gjs/cairo.js @@ -1,11 +1,4 @@ -<% if(moduleType === 'esm') { %> import Cairo from 'cairo'; // cairo doesn't have named exports, see https://gitlab.gnome.org/GNOME/gjs/-/blob/c2a714f348d6848037f072063e0a914fd537c4f4/installed-tests/js/testCairoModule.js#L14 export default Cairo; -<% } else { %> -const Cairo = imports.cairo; - -module.exports = Cairo; -exports.default = Cairo; -<% } %> diff --git a/packages/generator-typescript/templates/gjs/gettext.js b/packages/generator-typescript/templates/gjs/gettext.js index 3bc5615fe..91dbc6b3b 100644 --- a/packages/generator-typescript/templates/gjs/gettext.js +++ b/packages/generator-typescript/templates/gjs/gettext.js @@ -1,11 +1,4 @@ -<% if(moduleType === 'esm') { %> import Gettext, { setlocale, textdomain, bindtextdomain, gettext, dgettext, dcgettext, ngettext, dngettext, pgettext, dpgettext, domain } from 'gettext'; export { setlocale, textdomain, bindtextdomain, gettext, dgettext, dcgettext, ngettext, dngettext, pgettext, dpgettext, domain } export default Gettext; -<% } else { %> -const Gettext = imports.gettext; - -module.exports = Gettext; -exports.default = Gettext; -<% } %> diff --git a/packages/generator-typescript/templates/gjs/gjs.js b/packages/generator-typescript/templates/gjs/gjs.js index a12faee64..a7199334a 100644 --- a/packages/generator-typescript/templates/gjs/gjs.js +++ b/packages/generator-typescript/templates/gjs/gjs.js @@ -1,10 +1,4 @@ const imports = globalThis.imports || {}; -<%_ if(moduleType === 'esm') { _%> export { imports } export default imports; -<%_ } else { _%> -module.exports = imports; -exports.default = imports; -<%_ } _%> - \ No newline at end of file diff --git a/packages/generator-typescript/templates/gjs/module-ambient.d.ts b/packages/generator-typescript/templates/gjs/module-ambient.d.ts index 5d6c59846..fdc96114f 100644 --- a/packages/generator-typescript/templates/gjs/module-ambient.d.ts +++ b/packages/generator-typescript/templates/gjs/module-ambient.d.ts @@ -4,18 +4,10 @@ _%> <%_ const pkg = dep.get(girModule.namespace, girModule.version) _%> <%_ let moduleImportStr = ""; _%> -<%_ if(package){ _%> - <%_ if(noNamespace){ _%> - <%_ moduleImportStr = `import * as ${girModule.importNamespace} from '${pkg.importPath}'`; _%> - <%_ } else { _%> - <%_ moduleImportStr = `import ${girModule.importNamespace} from '${pkg.importPath}'`; _%> - <%_ } _%> +<%_ if(noNamespace){ _%> + <%_ moduleImportStr = `import * as ${girModule.importNamespace} from '${pkg.importPath}'`; _%> <%_ } else { _%> - <%_ if(noNamespace){ _%> - <%_ moduleImportStr = `const ${girModule.importNamespace}: typeof import('${pkg.importPath}')`; _%> - <%_ } else { _%> - <%_ moduleImportStr = `const ${girModule.importNamespace}: typeof import('${pkg.importPath}').default`; _%> - <%_ } _%> + <%_ moduleImportStr = `import ${girModule.importNamespace} from '${pkg.importPath}'`; _%> <%_ } _%> declare module 'gi://<%= name %>?version=<%= version %>' { @@ -24,9 +16,7 @@ declare module 'gi://<%= name %>?version=<%= version %>' { } <%# // Generate ambient module declarations Without version number if there are no conflicts or the target is an NPM package _%> -<%_ if(package || !dep.hasConflict(name, version)){ _%> declare module 'gi://<%= name %>' { <%- moduleImportStr %>; export default <%- girModule.importNamespace -%>; -} -<%_ } _%> \ No newline at end of file +} \ No newline at end of file diff --git a/packages/generator-typescript/templates/gjs/module-import.d.ts b/packages/generator-typescript/templates/gjs/module-import.d.ts index b1d48402f..51e363ab9 100644 --- a/packages/generator-typescript/templates/gjs/module-import.d.ts +++ b/packages/generator-typescript/templates/gjs/module-import.d.ts @@ -1,32 +1,20 @@ <%# // This EJS template is used to extend the global GjsGiImports interface with the GIR module, for `imports.gi[namespace] GJS GIR types` _%> -<%_ if(!package && !dep.isLatestVersion(girModule.namespace, girModule.version)){ _%> +<%_ if(!dep.isLatestVersion(girModule.namespace, girModule.version)){ _%> <%_ return `// Module import type definition not generated, otherwise this would cause a type conflict, this is because several GIR modules were generated with the same namespace: "${ girModule.namespace }"` _%> <%_ } _%> <%_ const pkg = dep.get(girModule.namespace, girModule.version) _%> -<%_ if(package){ _%> - <%_ if(noNamespace){ _%> +<%_ if(noNamespace){ _%> import * as <%= girModule.importNamespace %> from '<%= pkg.importPath %>'; - <%_ } else { _%> -import <%= girModule.importNamespace %> from '<%= pkg.importPath %>'; - <%_ } _%> <%_ } else { _%> - <%_ if(noNamespace){ _%> -type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>'); - <%_ } else { _%> -type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>').default; - <%_ } _%> +import <%= girModule.importNamespace %> from '<%= pkg.importPath %>'; <%_ } _%> declare global { export interface GjsGiImports { - <%_ if(package){ _%> <%= name %>: typeof <%= girModule.importNamespace %>; - <%_ } else { _%> - <%= name %>: <%= girModule.importNamespace %>; - <%_ } _%> } } diff --git a/packages/generator-typescript/templates/gjs/module.d.ts b/packages/generator-typescript/templates/gjs/module.d.ts index 8c37cd516..f07a0822f 100644 --- a/packages/generator-typescript/templates/gjs/module.d.ts +++ b/packages/generator-typescript/templates/gjs/module.d.ts @@ -6,7 +6,5 @@ * If you found a bug fix it in `<%= APP_NAME %>` or create a bug report on <%= APP_SOURCE %> */ -<%_ if(package){ _%> import './<%= importName %>-ambient.d.ts'; -<%_ } _%> import './<%= importName %>-import.d.ts'; \ No newline at end of file diff --git a/packages/generator-typescript/templates/gjs/module.js b/packages/generator-typescript/templates/gjs/module.js index 4734a52c5..22e5f53ad 100644 --- a/packages/generator-typescript/templates/gjs/module.js +++ b/packages/generator-typescript/templates/gjs/module.js @@ -1,17 +1,5 @@ <%# This template is used for the generated `.js` file of each GIR module like Gtk-4.0, GObject-2.0, ... %> -<% if(moduleType === 'esm'){ %> // @ts-expect-error import <%= name %> from 'gi://<%= name %>?version=<%= version %>'; export { <%= name %> }; - export default <%= name %>; -<% } else { %> - imports.gi.versions.<%= name %> = '<%= version %>' - const <%= name %> = imports.gi.<%= name %>; - <% if(!noNamespace){ %> - module.exports = { <%= name %> }; - exports.default = <%= name %>; - <% } else { %> - module.exports = <%= name %>; - <% } %> -<% } %> - + export default <%= name %>; \ No newline at end of file diff --git a/packages/generator-typescript/templates/gjs/system.js b/packages/generator-typescript/templates/gjs/system.js index e495472ea..fba7a249d 100644 --- a/packages/generator-typescript/templates/gjs/system.js +++ b/packages/generator-typescript/templates/gjs/system.js @@ -1,11 +1,4 @@ -<% if(moduleType === 'esm') { %> import System, { programInvocationName, version, programPath, programArgs, exit, addressOfGObject, addressOf, gc, refcount, dumpHeap, dumpMemoryInfo } from 'system'; export { programInvocationName, version, programPath, programArgs, exit, addressOfGObject, addressOf, gc, refcount, dumpHeap, dumpMemoryInfo }; -export default System; -<% } else { %> -const System = imports.system; - -module.exports = System; -exports.default = System; -<% } %> \ No newline at end of file +export default System; \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/ambient.js b/packages/generator-typescript/templates/node-gtk/ambient.js deleted file mode 100644 index 4351cbe54..000000000 --- a/packages/generator-typescript/templates/node-gtk/ambient.js +++ /dev/null @@ -1,5 +0,0 @@ -<% if(moduleType === 'esm'){ %> - export {}; -<% } else { %> - module.exports = {}; -<% } %> \ No newline at end of file diff --git a/packages/generator-typescript/templates/node-gtk/module-import.js b/packages/generator-typescript/templates/node-gtk/module-import.js deleted file mode 100644 index aae833c57..000000000 --- a/packages/generator-typescript/templates/node-gtk/module-import.js +++ /dev/null @@ -1,10 +0,0 @@ -const gi = globalThis.imports?.gi || {}; -export default gi; - -<% if(moduleType === 'esm'){ %> - import * as gi from 'node-gtk'; - export default gi; -<% } else { %> - const gi = require('node-gtk'); - module.exports = gi; -<% } %> \ No newline at end of file diff --git a/packages/generator-typescript/templates/package.json b/packages/generator-typescript/templates/package.json index a9cd3c69d..2b70a7bf6 100644 --- a/packages/generator-typescript/templates/package.json +++ b/packages/generator-typescript/templates/package.json @@ -14,13 +14,8 @@ _%> "version": "<%- APP_VERSION %>", <%_ } _%> "description": "<%- PACKAGE_DESC %>", - <%_ if (moduleType === 'esm') { _%> "type": "module", "module": "<%- entryPointName %>.js", - <%_ } else { _%> - "type": "commonjs", - "module": "<%- entryPointName %>.mjs", - <%_ } _%> "main": "<%- entryPointName %>.js", "exports": { <%_ if (packageName === 'Gjs' && generateAlias) { _%> @@ -32,67 +27,16 @@ _%> "default": "./ambient.js" }, "./gettext": { - <%_ if (moduleType === 'esm') { _%> - "import": { - "types": "./gettext.d.ts", - "default": "./gettext.js" - }, - "require": { - "types": "./gettext.d.cts", - "default": "./gettext.cjs" - } - <%_ } else { _%> - "import": { - "types": "./gettext.d.mts", - "default": "./gettext.mjs" - }, - "require": { - "types": "./gettext.d.ts", - "default": "./gettext.js" - } - <%_ } _%> + "types": "./gettext.d.ts", + "default": "./gettext.js" }, "./system": { - <%_ if (moduleType === 'esm') { _%> - "import": { - "types": "./system.d.ts", - "default": "./system.js" - }, - "require": { - "types": "./system.d.cts", - "default": "./system.cjs" - } - <%_ } else { _%> - "import": { - "types": "./system.d.mts", - "default": "./system.mjs" - }, - "require": { - "types": "./system.d.ts", - "default": "./system.js" - } - <%_ } _%> + "types": "./system.d.ts", + "default": "./system.js" }, "./cairo": { - <%_ if (moduleType === 'esm') { _%> - "import": { - "types": "./cairo.d.ts", - "default": "./cairo.js" - }, - "require": { - "types": "./cairo.d.cts", - "default": "./cairo.cjs" - } - <%_ } else { _%> - "import": { - "types": "./cairo.d.mts", - "default": "./cairo.mjs" - }, - "require": { - "types": "./cairo.d.ts", - "default": "./cairo.js" - } - <%_ } _%> + "types": "./cairo.d.ts", + "default": "./cairo.js" }, <%_ } _%> "./ambient": { @@ -114,42 +58,16 @@ _%> }, <%_ } _%> ".": { - <%_ if (moduleType === 'esm') { _%> - "import": { - "types": "./<%- entryPointName %>.d.ts", - "default": "./<%- entryPointName %>.js" - }, - "require": { - "types": "./<%- entryPointName %>.d.cts", - "default": "./<%- entryPointName %>.cjs" - } - <%_ } else { _%> - "import": { - "types": "./<%- entryPointName %>.d.mts", - "default": "./<%- entryPointName %>.mjs" - }, - "require": { - "types": "./<%- entryPointName %>.d.ts", - "default": "./<%- entryPointName %>.js" - } - <%_ } _%> + "types": "./<%- entryPointName %>.d.ts", + "default": "./<%- entryPointName %>.js" } }, "scripts": { - "test": "yarn test:esm && yarn test:cjs", - <%_ if (moduleType === 'esm') { _%> - "test:esm": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit <%- entryPointName %>.d.ts", - "test:cjs": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit <%- entryPointName %>.d.cts" - <%_ } else { _%> - "test:esm": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit <%- entryPointName %>.d.mts", - "test:cjs": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit <%- entryPointName %>.d.ts" - <%_ } _%> + "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit <%- entryPointName %>.d.ts" }, "dependencies": { <%_ if (packageName !== 'Gjs') { _%> - <%_ if (environment === 'gjs') { _%> "<%- npmScope %>/gjs": "<%- depVersion %>"<%_ if(deps.length > 0 ) { _%>,<%_ } _%> - <%_ } _%> <%_ } _%> <%_ for (let i = 0; i < deps.length; i++ ) { _%> <%_ if (!packageYarn) { _%> diff --git a/packages/generator-typescript/templates/tsconfig.json b/packages/generator-typescript/templates/tsconfig.json index 9ca93fc4a..1045d288c 100644 --- a/packages/generator-typescript/templates/tsconfig.json +++ b/packages/generator-typescript/templates/tsconfig.json @@ -11,11 +11,7 @@ _%> "compilerOptions": { // General settings for code interpretation "target": "ESNext", - <%_ if (moduleType === 'esm') { _%> "module": "ESNext", - <%_ } else { _%> - "module": "CommonJS", - <%_ } _%> "lib": ["ESNext"], "types": [], "experimentalDecorators": true, diff --git a/packages/lib/package.json b/packages/lib/package.json index 4015395f9..e8f22e4df 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/lib", - "version": "3.2.3", + "version": "4.0.0", "description": "Typescript .d.ts generator from GIR for gjs", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/lib/src/conflict-resolver.ts b/packages/lib/src/conflict-resolver.ts index 8c97f6508..564626fac 100644 --- a/packages/lib/src/conflict-resolver.ts +++ b/packages/lib/src/conflict-resolver.ts @@ -5,7 +5,6 @@ import { isEqual } from './utils.js' import { SIGNAL_METHOD_NAMES, MAX_CLASS_PARENT_DEPTH } from './constants.js' import { - type Environment, type GirClassElement, type GirRecordElement, type GirUnionElement, @@ -41,11 +40,8 @@ export class ConflictResolver { private girFactory = new GirFactory() - constructor( - private readonly environment: Environment, - verbose: boolean, - ) { - this.log = new Logger(environment, verbose, 'ConflictResolver') + constructor(verbose: boolean) { + this.log = new Logger(verbose, 'ConflictResolver') } private girElArrToChildArr( @@ -385,7 +381,7 @@ export class ConflictResolver { // Only one property can be defined, no overloads !this.getTsElementByName(conflictProperties, prop.name) && // Do not set properties with signal method names - !SIGNAL_METHOD_NAMES(this.environment).includes(prop.name) + !SIGNAL_METHOD_NAMES.includes(prop.name) return canAdd } diff --git a/packages/lib/src/constants.ts b/packages/lib/src/constants.ts index 78e9160c3..8a7192ef9 100644 --- a/packages/lib/src/constants.ts +++ b/packages/lib/src/constants.ts @@ -2,8 +2,6 @@ import { LibraryVersion } from './library-version.js' import { __dirname, readJsonFile } from './utils.js' import { join } from 'path' -import type { Environment } from './types/index.js' - /** * In gjs all classes have a static name property but the classes listed below already have a static name property */ @@ -30,22 +28,16 @@ export const APP_USAGE = 'TypeScript type definition generator for GObject intro export const APP_SOURCE = 'https://github.com/gjsify/ts-for-gir' export const APP_VERSION = PACKAGE.version -export const PACKAGE_DESC = (packageName: string, environment: Environment, libraryVersion?: LibraryVersion) => { - const envStr = environment === 'gjs' ? 'GJS' : 'unknown environment' +export const PACKAGE_DESC = (packageName: string, libraryVersion?: LibraryVersion) => { if (libraryVersion) { - return `${envStr} TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}` + return `GJS TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}` } - return `${envStr} TypeScript type definitions for ${packageName}` + return `GJS TypeScript type definitions for ${packageName}` } -export const PACKAGE_KEYWORDS = (packageName: string, environment: Environment) => { - const envKeywords = environment === 'gjs' ? '"GJS"' : '' - return `"Gir", "TypeScript", "types", "GObject-Introspection", ${envKeywords}, "${packageName}"` +export const PACKAGE_KEYWORDS = (packageName: string) => { + return `"Gir", "TypeScript", "types", "GObject-Introspection", "GJS", "${packageName}"` } export const GENERIC_NAMES: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K'] -export const SIGNAL_METHOD_NAMES_GENERAL: string[] = ['connect', 'emit', 'disconnect'] -export const SIGNAL_METHOD_NAMES_GJS: string[] = ['connect_after', 'emit'] -export const SIGNAL_METHOD_NAMES = (env: Environment) => { - return [...SIGNAL_METHOD_NAMES_GENERAL, ...(env === 'gjs' ? SIGNAL_METHOD_NAMES_GJS : [])] -} +export const SIGNAL_METHOD_NAMES: string[] = ['connect', 'emit', 'disconnect', 'connect_after', 'emit'] diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index 5168ae221..d0695b395 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -13,22 +13,22 @@ export class DependencyManager { cache: { [packageName: string]: Dependency } = {} - static instances: { [env: string]: DependencyManager } = {} + static instance?: DependencyManager protected constructor(protected readonly config: GenerateConfig) { this.transformation = new Transformation(config) - this.log = new Logger(config.environment, config.verbose, 'DependencyManager') + this.log = new Logger(config.verbose, 'DependencyManager') } /** * Get the DependencyManager singleton instance */ static getInstance(config: GenerateConfig): DependencyManager { - if (this.instances[config.environment]) { - return this.instances[config.environment] + if (this.instance) { + return this.instance } - this.instances[config.environment] = new DependencyManager(config) - return this.instances[config.environment] + this.instance = new DependencyManager(config) + return this.instance } protected parseArgs(namespaceOrPackageName: string, version?: string) { @@ -73,7 +73,7 @@ export class DependencyManager { createImportPath(packageName: string): string { const importName = this.transformation.transformImportName(packageName) - const importPath = this.config.package ? `${this.config.npmScope}/${importName}` : `./${importName}.js` + const importPath = `${this.config.npmScope}/${importName}` return importPath } diff --git a/packages/lib/src/generators/dts-modules.ts b/packages/lib/src/generators/dts-modules.ts index ac142bf8b..82af35027 100644 --- a/packages/lib/src/generators/dts-modules.ts +++ b/packages/lib/src/generators/dts-modules.ts @@ -61,9 +61,8 @@ export class DtsModuleGenerator extends DtsGenerator { .join("\n"); const versionedImports = true; // TODO options.versionedImports - const pathSuffix = options.buildType === "lib" ? "/index.d.ts" : ".d.ts"; - const referenceType = - /*options.importPrefix.startsWith(".")*/ options.buildType === "lib" ? "path" : "types"; + const pathSuffix = "/index.d.ts"; + const referenceType = "path"; const references = [ ...(node.__dts__references ?? []), ...Array.from(node.getImports()).map( diff --git a/packages/lib/src/gir-factory.ts b/packages/lib/src/gir-factory.ts index 7cc546863..a12668fb8 100644 --- a/packages/lib/src/gir-factory.ts +++ b/packages/lib/src/gir-factory.ts @@ -21,7 +21,6 @@ import type { InjectionType, InjectionParameter, InjectionProperty, - Environment, TypeGirProperty, TypeGirElement, TypeGirFunction, @@ -341,7 +340,6 @@ export class GirFactory { callbackType: string | undefined, emitInParams: InjectionParameter[], parentClass: TsClass, - environment: Environment, withDisconnect = false, ) { const tsMethods: TsMethod[] = [] @@ -396,18 +394,16 @@ export class GirFactory { ) tsMethods.push(connectTsFn) - if (environment === 'gjs') { - const connectAfterTsFn = this.newTsFunction( - { - name: 'connect_after', - inParams: [sigNameInParam, callbackInParam], - returnTypes: [numberReturnType], - girTypeName, - }, - parentClass, - ) - tsMethods.push(connectAfterTsFn) - } + const connectAfterTsFn = this.newTsFunction( + { + name: 'connect_after', + inParams: [sigNameInParam, callbackInParam], + returnTypes: [numberReturnType], + girTypeName, + }, + parentClass, + ) + tsMethods.push(connectAfterTsFn) const emitTsFn = this.newTsFunction( { diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index b17556b6f..7dddd8ff2 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -852,9 +852,9 @@ export class GirModule { building.libraryVersion = new LibraryVersion(ns.constant, building.version) building.transformation = new Transformation(config) - building.log = new Logger(config.environment, config.verbose, building.packageName || 'GirModule') - building.conflictResolver = new ConflictResolver(config.environment, config.verbose) - building.inject = new Injector(building.config.environment) + building.log = new Logger(config.verbose, building.packageName || 'GirModule') + building.conflictResolver = new ConflictResolver(config.verbose) + building.inject = new Injector() building.importNamespace = building.transformation.transformModuleNamespaceName(building.packageName) building.importName = building.transformation.transformImportName(building.packageName) building.symTable = new SymTable(building.config, building.packageName, building.namespace) diff --git a/packages/lib/src/injection/injector.ts b/packages/lib/src/injection/injector.ts index 2c44b840a..4716ee54f 100644 --- a/packages/lib/src/injection/injector.ts +++ b/packages/lib/src/injection/injector.ts @@ -5,7 +5,6 @@ import type { GirInterfaceElement, GirCallbackElement, GirCallableParamElement, - Environment, } from '../types/index.js' import { Logger } from '../logger.js' @@ -19,8 +18,8 @@ export class Injector { girFactory = new GirFactory() log: Logger - constructor(private readonly environment: Environment) { - this.log = new Logger(environment, true, 'ConflictResolver') + constructor() { + this.log = new Logger(true, 'ConflictResolver') } /** Inject additional generics, methods, properties, etc to a existing class */ @@ -29,7 +28,7 @@ export class Injector { return } - const classes = this.environment === 'gjs' ? [...classesAll, ...classesGjs] : [...classesAll] + const classes = [...classesAll, ...classesGjs] const toClass = classes.find((cls) => { return ( @@ -84,7 +83,7 @@ export class Injector { /** Inject additional generics to existing callback interfaces */ toCallback(girCallback: GirCallbackElement) { - const callbacks = this.environment === 'gjs' ? [...callbacksAll, ...callbacksGjs] : [...callbacksAll] + const callbacks = [...callbacksAll, ...callbacksGjs] if (!girCallback._module || !girCallback._tsData) { return girCallback @@ -130,7 +129,7 @@ export class Injector { toParameterType(girParam: GirCallableParamElement) { const tsTypes = girParam._tsData?.type - const callbacks = this.environment === 'gjs' ? [...callbacksAll, ...callbacksGjs] : [...callbacksAll] + const callbacks = [...callbacksAll, ...callbacksGjs] if (!girParam._module || !girParam._tsData) { return girParam diff --git a/packages/lib/src/logger.ts b/packages/lib/src/logger.ts index 46d8e739e..fd5824909 100644 --- a/packages/lib/src/logger.ts +++ b/packages/lib/src/logger.ts @@ -4,11 +4,9 @@ */ import { blue, yellow, yellowBright, green, red, white } from 'colorette' -import { Environment } from './types/index.js' export class Logger { constructor( - private readonly environment: Environment | '', private readonly verbose: boolean, private readonly moduleName: string, ) {} @@ -24,11 +22,11 @@ export class Logger { * @param logLevel */ private prependInfos(args: unknown[], logLevel?: 'WARN:' | 'ERROR:' | 'INFO:' | 'DEBUG:'): unknown[] { - if (logLevel || this.moduleName.length > 0 || this.environment.length > 0) { + if (logLevel || this.moduleName.length > 0) { args = Logger.prepend(args, ' ') } if (logLevel) { - if (this.moduleName.length > 0 || this.environment.length > 0) { + if (this.moduleName.length > 0) { args = Logger.prepend(args, ' ' + logLevel) } else { args = Logger.prepend(args, logLevel) @@ -37,9 +35,6 @@ export class Logger { if (this.moduleName.length > 0) { args = Logger.prepend(args, `[${this.moduleName}]`) } - if (this.environment.length > 0) { - args = Logger.prepend(args, `[${this.environment}]`) - } return args } diff --git a/packages/lib/src/messages.ts b/packages/lib/src/messages.ts index a1049bf69..422d6c2af 100644 --- a/packages/lib/src/messages.ts +++ b/packages/lib/src/messages.ts @@ -1,5 +1,3 @@ -import type { Environment, BuildType } from './types/index.js' - export const NO_TSDATA = (namespace?: string) => { let message = 'You need to set the tsData first!' if (namespace) message = `[${namespace}] ${message}` @@ -20,8 +18,6 @@ export const ERROR_NO_MODULE_SPECIFIED = 'Need to specify modules!' export const WARN_NO_GIR_FILE_FOUND_FOR_PACKAGE = (packageName: string) => `No gir file found for '${packageName}', this module will be ignored` export const WARN_CONSTANT_ALREADY_EXPORTED = (name: string) => `The constant '${name}' has already been exported` -export const WARN_USE_ESM_FOR_ALIAS = "moduleType must be 'esm' if generateAlias is true!" -export const WARN_USE_GJS_FOR_ALIAS = "environments must include 'gjs' if generateAlias is true!" export const WARN_IGNORE_MULTIPLE_CALLBACKS = 'Multiple callbacks are ignored!' export const WARN_IGNORE_MULTIPLE_FUNC_DESC = 'Ignore multiline function description!' @@ -60,8 +56,7 @@ export const WARN_RENAMED_PARAMETER = (originalName: string, newName: string) => export const DANGER_HTML_DOC_GENERATOR_NOT_IMPLEMENTED = 'The HtmlDocGenerator is currently not implemented. Do nothing...' -export const START_MODULE = (environment: Environment, buildType?: BuildType) => - `Start to generate .d.ts files for '${environment}' as '${buildType || 'unknown'}'.` +export const START_MODULE = `Start to generate .d.ts files...` export const FILE_PARSING_DONE = 'Files parsed, loading types...' export const TSDATA_PARSING_DONE = 'Typescript data loaded, generating .d.ts...' export const GENERATING_TYPES_DONE = 'Done.' diff --git a/packages/lib/src/symtable.ts b/packages/lib/src/symtable.ts index 460983a21..e5d1fcdea 100644 --- a/packages/lib/src/symtable.ts +++ b/packages/lib/src/symtable.ts @@ -17,7 +17,7 @@ export class SymTable { private readonly modPackageName: string, private readonly modNamespace: string, ) { - this.log = new Logger(this.config.environment, this.config.verbose, 'SymTable') + this.log = new Logger(this.config.verbose, 'SymTable') } /** diff --git a/packages/lib/src/transformation.ts b/packages/lib/src/transformation.ts index f9d851102..0df80c9a7 100644 --- a/packages/lib/src/transformation.ts +++ b/packages/lib/src/transformation.ts @@ -5,7 +5,6 @@ import { Transformations, - Environment, ConstructName, GenerateConfig, GirCallableParamElement, @@ -126,21 +125,16 @@ export const PRIMITIVE_TYPE_MAP = { // Gjs is permissive for byte-array in parameters but strict for out/return // See -export const FULL_TYPE_MAP = (environment: Environment, value: string, out = true): string | undefined => { +export const FULL_TYPE_MAP = (value: string, out = true): string | undefined => { let ba: string let gb: string | undefined - if (environment === 'gjs') { - ba = 'Uint8Array' - if (out === false) { - ba += ' | imports.byteArray.ByteArray' - gb = 'GLib.Bytes | Uint8Array | imports.byteArray.ByteArray' - } else { - gb = undefined // No transformation - } + + ba = 'Uint8Array' + if (out === false) { + ba += ' | imports.byteArray.ByteArray' + gb = 'GLib.Bytes | Uint8Array | imports.byteArray.ByteArray' } else { - // TODO - ba = 'any' - gb = 'any' + gb = undefined // No transformation } const fullTypeMap = { @@ -258,66 +252,18 @@ export class Transformation { * For gjs see https://gjs-docs.gnome.org/ and https://wiki.gnome.org/Attic/Gjs */ private transformations: Transformations = { - functionName: { - gjs: { - transformation: 'original', - }, - }, - enumName: { - gjs: { - transformation: 'original', - }, - }, - enumMember: { - gjs: { - transformation: 'upperCase', - }, - }, - signalName: { - gjs: { - transformation: 'original', - }, - }, - propertyName: { - gjs: { - transformation: 'lowerCamelCase', - }, - }, - constructorPropertyName: { - gjs: { - transformation: 'lowerCamelCase', - }, - }, - parameterName: { - gjs: { - transformation: 'underscores', - }, - }, - fieldName: { - gjs: { - transformation: 'underscores', - }, - }, - constantName: { - gjs: { - transformation: 'original', - }, - }, - importNamespaceName: { - gjs: { - transformation: 'upperCamelCase', - }, - }, - signalInterfaceName: { - gjs: { - transformation: 'upperCamelCase', - }, - }, - importName: { - gjs: { - transformation: 'lowerCase', - }, - }, + functionName: 'original', + enumName: 'original', + enumMember: 'upperCase', + signalName: 'original', + propertyName: 'lowerCamelCase', + constructorPropertyName: 'lowerCamelCase', + parameterName: 'underscores', + fieldName: 'underscores', + constantName: 'original', + importNamespaceName: 'upperCamelCase', + signalInterfaceName: 'upperCamelCase', + importName: 'lowerCase', } private log: Logger @@ -326,7 +272,7 @@ export class Transformation { private readonly config: GenerateConfig, logName = 'Transformation', ) { - this.log = new Logger(config.environment, config.verbose, logName) + this.log = new Logger(config.verbose, logName) } public transformSignalInterfaceName(name: string): string { @@ -389,8 +335,7 @@ export class Transformation { public transformFunctionName(name: string, isVirtual: boolean): string { name = this.transform('functionName', name) - // node-gtk has no `vfunc_` prefix for virtual methods - if (isVirtual && this.config.environment === 'gjs') { + if (isVirtual) { name = 'vfunc_' + name } @@ -501,7 +446,7 @@ export class Transformation { } public transform(construct: ConstructName, transformMe: string): string { - const transformations = this.transformations[construct][this.config.environment].transformation + const transformations = this.transformations[construct] switch (transformations) { case 'lowerCamelCase': diff --git a/packages/lib/src/types/build-type.ts b/packages/lib/src/types/build-type.ts deleted file mode 100644 index 8b36ffe9e..000000000 --- a/packages/lib/src/types/build-type.ts +++ /dev/null @@ -1 +0,0 @@ -export type BuildType = 'lib' | 'types' diff --git a/packages/lib/src/types/environment.ts b/packages/lib/src/types/environment.ts deleted file mode 100644 index 034823203..000000000 --- a/packages/lib/src/types/environment.ts +++ /dev/null @@ -1 +0,0 @@ -export type Environment = 'gjs' diff --git a/packages/lib/src/types/generate-config.ts b/packages/lib/src/types/generate-config.ts index 7227bd9e1..857e4ff33 100644 --- a/packages/lib/src/types/generate-config.ts +++ b/packages/lib/src/types/generate-config.ts @@ -1,19 +1,11 @@ -import { BuildType, Environment, ModuleType } from './index.js' - /** * Type for currently used config e.g. in GirModule */ export interface GenerateConfig { - /** javascript environment */ - environment: Environment /** root / working directory of your project */ root: string /** directory to output to */ outdir: string | null - /** Definitions generation type */ - buildType?: BuildType - /** Module type, can be CommonJS or ESM */ - moduleType?: ModuleType /** GIR directories */ girDirectories: string[] /** Switch on/off the verbose mode */ @@ -35,8 +27,6 @@ export interface GenerateConfig { * @see https://docs.npmjs.com/cli/v7/using-npm/scope */ npmScope: string - /** Generates an NPM compatible packages for each GIR module */ - package: boolean /** Adds Yarn workspace support to the NPM packages */ packageYarn: boolean /** Disable pretty printing the output */ diff --git a/packages/lib/src/types/index.ts b/packages/lib/src/types/index.ts index 907c7393a..e88bc7f55 100644 --- a/packages/lib/src/types/index.ts +++ b/packages/lib/src/types/index.ts @@ -1,5 +1,4 @@ export * from './answer-version.js' -export * from './build-type.js' export * from './class-parent.js' export * from './config-flags.js' export * from './conflict-child-element.js' @@ -8,7 +7,6 @@ export * from './conflict-grouped-elements.js' export * from './construct-name.js' export * from './dependency-map.js' export * from './dependency.js' -export * from './environment.js' export * from './file-info.js' export * from './generate-config.js' export * from './gir-alias-element.js' @@ -75,7 +73,6 @@ export * from './local-name-check.js' export * from './local-name-type.js' export * from './local-name.js' export * from './local-names.js' -export * from './module-type.js' export * from './package-data-parsed.js' export * from './package-data.js' export * from './package-section-parsed.js' diff --git a/packages/lib/src/types/module-type.ts b/packages/lib/src/types/module-type.ts deleted file mode 100644 index 1a2a818d6..000000000 --- a/packages/lib/src/types/module-type.ts +++ /dev/null @@ -1 +0,0 @@ -export type ModuleType = 'esm' | 'cjs' diff --git a/packages/lib/src/types/transformations.ts b/packages/lib/src/types/transformations.ts index 36bb8dd00..1d5ad8ab8 100644 --- a/packages/lib/src/types/transformations.ts +++ b/packages/lib/src/types/transformations.ts @@ -1,9 +1,5 @@ import type { TransformationCase } from './transformation-case.js' export interface Transformations { - [type: string]: { - gjs: { - transformation: TransformationCase - } - } + [type: string]: TransformationCase } diff --git a/packages/lib/src/types/user-config.ts b/packages/lib/src/types/user-config.ts index 17da3735f..e5b303855 100644 --- a/packages/lib/src/types/user-config.ts +++ b/packages/lib/src/types/user-config.ts @@ -1,19 +1,11 @@ -import { BuildType, Environment, ModuleType } from './index.js' - /** * Types for config file */ export interface UserConfig { - /** javascript environment */ - environments: Environment[] /** root / working directory of your project */ root: string /** directory to output to */ outdir: string | null - /** Definitions generation type */ - buildType?: BuildType - /** Module type, can be CommonJS or ESM */ - moduleType?: ModuleType /** GIR directories */ girDirectories: string[] /** Switch on/off the verbose mode */ @@ -40,8 +32,6 @@ export interface UserConfig { promisify: boolean /** Scope of the generated NPM packages */ npmScope: string - /** Generates an NPM compatible packages for each GIR module */ - package: boolean /** Adds Yarn workspace support to the NPM packages */ packageYarn: boolean } From a25890ddbe7c62f81d8a9c45975068516020b188 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sat, 24 Feb 2024 07:23:37 +0100 Subject: [PATCH 21/53] Do not use removed CLI options --- .ts-for-gir.all.rc.js | 1 - .ts-for-gir.gcalc.rc.js | 1 - .ts-for-gir.gio.rc.js | 2 - .ts-for-gir.gtk2.rc.js | 1 - .ts-for-gir.gtk3+gtk4.rc.js | 1 - .ts-for-gir.gtk3.rc.js | 1 - .ts-for-gir.gtk4.rc.js | 1 - .ts-for-gir.modemmanager1.rc.js | 1 - .ts-for-gir.rygelcore2.rc.js | 1 - .ts-for-gir.timezonemap1.rc.js | 1 - .ts-for-gir.vda1.rc.js | 1 - .ts-for-gir.vte4.rc.js | 1 - .../gjs/glib-2-spawn-command/package.json | 2 +- package.json | 42 +++++++------------ ts-for-gir.code-workspace | 18 -------- 15 files changed, 16 insertions(+), 59 deletions(-) diff --git a/.ts-for-gir.all.rc.js b/.ts-for-gir.all.rc.js index 01a7b11b9..60eb00032 100644 --- a/.ts-for-gir.all.rc.js +++ b/.ts-for-gir.all.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['*'], girDirectories: ['./vala-girs/gir-1.0', './girs'], ignoreVersionConflicts: true, diff --git a/.ts-for-gir.gcalc.rc.js b/.ts-for-gir.gcalc.rc.js index c82439501..f2d2f8db7 100644 --- a/.ts-for-gir.gcalc.rc.js +++ b/.ts-for-gir.gcalc.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: [/*'GCalc-1',*/ 'GCalc-2'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gio.rc.js b/.ts-for-gir.gio.rc.js index bd10f825f..06844b543 100644 --- a/.ts-for-gir.gio.rc.js +++ b/.ts-for-gir.gio.rc.js @@ -1,10 +1,8 @@ export default { - environments: ['gjs'], modules: ['Gio-2.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], promisify: true, verbose: true, - package: true, outdir: './types', } diff --git a/.ts-for-gir.gtk2.rc.js b/.ts-for-gir.gtk2.rc.js index ae8dac27c..deee954a8 100644 --- a/.ts-for-gir.gtk2.rc.js +++ b/.ts-for-gir.gtk2.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['Gtk-2.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk3+gtk4.rc.js b/.ts-for-gir.gtk3+gtk4.rc.js index f69d98e81..478b23c56 100644 --- a/.ts-for-gir.gtk3+gtk4.rc.js +++ b/.ts-for-gir.gtk3+gtk4.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['Gtk-3.0', 'Gtk-4.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk3.rc.js b/.ts-for-gir.gtk3.rc.js index 921eac660..909393ec4 100644 --- a/.ts-for-gir.gtk3.rc.js +++ b/.ts-for-gir.gtk3.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['Gtk-3.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.gtk4.rc.js b/.ts-for-gir.gtk4.rc.js index 20b0762a6..60d9f51bc 100644 --- a/.ts-for-gir.gtk4.rc.js +++ b/.ts-for-gir.gtk4.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['Gtk-4.0', 'Adw-1.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.modemmanager1.rc.js b/.ts-for-gir.modemmanager1.rc.js index a1bd542fd..505a1fa28 100644 --- a/.ts-for-gir.modemmanager1.rc.js +++ b/.ts-for-gir.modemmanager1.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['ModemManager-1.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.rygelcore2.rc.js b/.ts-for-gir.rygelcore2.rc.js index c88406977..9f4ebb48b 100644 --- a/.ts-for-gir.rygelcore2.rc.js +++ b/.ts-for-gir.rygelcore2.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['RygelCore-2.6', 'RygelRenderer-2.6'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.timezonemap1.rc.js b/.ts-for-gir.timezonemap1.rc.js index 82c1dbfca..3cb2a5c08 100644 --- a/.ts-for-gir.timezonemap1.rc.js +++ b/.ts-for-gir.timezonemap1.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['TimezoneMap-1.0'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.vda1.rc.js b/.ts-for-gir.vda1.rc.js index 8f5c06210..0e35bdf45 100644 --- a/.ts-for-gir.vda1.rc.js +++ b/.ts-for-gir.vda1.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['Vda-1'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/.ts-for-gir.vte4.rc.js b/.ts-for-gir.vte4.rc.js index 012fd22f6..b17f590b2 100644 --- a/.ts-for-gir.vte4.rc.js +++ b/.ts-for-gir.vte4.rc.js @@ -1,5 +1,4 @@ export default { - environments: ['gjs'], modules: ['Vte-4*'], girDirectories: ['./vala-girs/gir-1.0'], ignore: [], diff --git a/examples/gjs/glib-2-spawn-command/package.json b/examples/gjs/glib-2-spawn-command/package.json index 9501663d5..fbe1ec326 100644 --- a/examples/gjs/glib-2-spawn-command/package.json +++ b/examples/gjs/glib-2-spawn-command/package.json @@ -10,7 +10,7 @@ "watch": "yarn build:app --watch", "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate GLib-2.0 --environments gjs --noNamespace -t cjs", + "build:types": "yarn ts-for-gir generate GLib-2.0 --noNamespace -t cjs", "clear:types": "rm -rf ./@types", "clear:ts": "rm -rf ./dist", "clear": "yarn clear:ts && yarn clear:types", diff --git a/package.json b/package.json index 9d38abaaf..21f3cfb09 100644 --- a/package.json +++ b/package.json @@ -19,19 +19,19 @@ "publish:types:next": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag next --access public", "publish:types:latest": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag latest --access public", "test": "yarn build:all && yarn test:girs:all && yarn validate:examples && yarn start:cli-examples:all", - "test:girs:all": "yarn clear:types && yarn build:types:all && yarn validate:types:all", - "test:girs:gjs": "yarn clear:types && yarn build:types:gjs && yarn validate:types:gjs", - "test:girs:gjs:vda1": "yarn clear:types && yarn build:types:gjs:vda1 && yarn validate:types:gjs", - "test:girs:gjs:gtk2": "yarn clear:types && yarn build:types:gjs:gtk2 && yarn validate:types:gjs", - "test:girs:gjs:gtk3": "yarn clear:types && yarn build:types:gjs:gtk3 && yarn validate:types:gjs", - "test:girs:gjs:gtk4": "yarn clear:types && yarn build:types:gjs:gtk4 && yarn validate:types:gjs", - "test:girs:gjs:gtk3+gtk4": "yarn clear:types && yarn build:types:gjs:gtk3+gtk4 && yarn validate:types:gjs", - "test:girs:gjs:gio": "yarn clear:types && yarn build:types:gjs:gio && yarn validate:types:gjs", - "test:girs:gjs:vte4": "yarn clear:types && yarn build:types:gjs:vte4 && yarn validate:types:gjs", - "test:girs:gjs:modemmanager1": "yarn clear:types && yarn build:types:gjs:modemmanager1 && yarn validate:types:gjs", - "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:gjs:timezonemap1 && yarn validate:types:gjs", - "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:gjs:rygelcore2 && yarn validate:types:gjs", - "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gjs:gcalc && yarn validate:types:gjs", + "test:girs:all": "yarn clear:types && yarn build:types:all && yarn validate:types:root", + "test:girs:gjs": "yarn clear:types && yarn build:types && yarn validate:types:root", + "test:girs:gjs:vda1": "yarn clear:types && yarn build:types:vda1 && yarn validate:types:root", + "test:girs:gjs:gtk2": "yarn clear:types && yarn build:types:gtk2 && yarn validate:types:root", + "test:girs:gjs:gtk3": "yarn clear:types && yarn build:types:gtk3 && yarn validate:types:root", + "test:girs:gjs:gtk4": "yarn clear:types && yarn build:types:gtk4 && yarn validate:types:root", + "test:girs:gjs:gtk3+gtk4": "yarn clear:types && yarn build:types:gtk3+gtk4 && yarn validate:types:root", + "test:girs:gjs:gio": "yarn clear:types && yarn build:types:gio && yarn validate:types:root", + "test:girs:gjs:vte4": "yarn clear:types && yarn build:types:vte4 && yarn validate:types:root", + "test:girs:gjs:modemmanager1": "yarn clear:types && yarn build:types:modemmanager1 && yarn validate:types:root", + "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:timezonemap1 && yarn validate:types:root", + "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:rygelcore2 && yarn validate:types:root", + "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gcalc && yarn validate:types:root", "build": "yarn build:parser && yarn build:lib && yarn build:generators && yarn build:cli", "build:parser": "yarn workspace @gi.ts/parser run build", "build:cli": "yarn workspace @ts-for-gir/cli run build", @@ -58,23 +58,11 @@ "build:types:timezonemap1": "yarn ts-for-gir generate --configName='.ts-for-gir.timezonemap1.rc.js'", "build:types:rygelcore2": "yarn ts-for-gir generate --configName='.ts-for-gir.rygelcore2.rc.js'", "build:types:gcalc": "yarn ts-for-gir generate --configName='.ts-for-gir.gcalc.rc.js'", - "build:types:gjs": "yarn build:types:all --environments=gjs", - "build:types:gjs:vda1": "yarn build:types:vda1 --environments=gjs", - "build:types:gjs:gtk2": "yarn build:types:gtk2 --environments=gjs", - "build:types:gjs:gtk3": "yarn build:types:gtk3 --environments=gjs", - "build:types:gjs:gtk4": "yarn build:types:gtk4 --environments=gjs", - "build:types:gjs:gtk3+gtk4": "yarn build:types:gtk3+gtk4 --environments=gjs", - "build:types:gjs:gio": "yarn build:types:gio --environments=gjs", - "build:types:gjs:vte4": "yarn build:types:vte4 --environments=gjs", - "build:types:gjs:modemmanager1": "yarn build:types:modemmanager1 --environments=gjs", - "build:types:gjs:timezonemap1": "yarn build:types:timezonemap1 --environments=gjs", - "build:types:gjs:rygelcore2": "yarn build:types:rygelcore2 --environments=gjs", - "build:types:gjs:gcalc": "yarn build:types:gcalc --environments=gjs", + "build:types": "yarn build:types:all", "validate": "yarn workspaces foreach -v --all --parallel run validate", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app", - "validate:types:all": "yarn validate:types:gjs", - "validate:types:gjs": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", + "validate:types:root": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", "clear": "yarn clear:build && yarn clear:types", "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", diff --git a/ts-for-gir.code-workspace b/ts-for-gir.code-workspace index 76e2be3ad..dbc2ece91 100644 --- a/ts-for-gir.code-workspace +++ b/ts-for-gir.code-workspace @@ -126,24 +126,6 @@ "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], "sourceMaps": true, }, - { - "name": "build:types:node", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}/packages/cli", - "runtimeExecutable": "${env:NVM_DIR}/nvm-exec", - "args": [ - "${workspaceRoot}/packages/cli/src/start.ts", - "generate", - "--configName=.ts-for-gir.all.rc.js", - "--verbose", - "--environments=node", - "--outdir", - "../../../tmp", - ], - "runtimeArgs": ["node", "--inspect", "--loader", "ts-node/esm"], - "sourceMaps": true, - }, ], }, "folders": [ From 9a182eca6e4e7a2b4bd5e321df96a3c8be4bf792 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 22:29:35 -0800 Subject: [PATCH 22/53] fix(github): build:types:gjs -> validate:types:all --- .github/workflows/ci.yml | 4 ++-- package.json | 28 ++++++++++++++-------------- ts-for-gir.code-workspace | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee1ab727f..b5b39ac68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,5 +66,5 @@ jobs: run: sudo apt-get --yes install build-essential gobject-introspection libgirepository1.0-dev libcairo2 libcairo2-dev - run: yarn install - run: yarn run build - - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:gjs - - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:gjs + - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:all + - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:all diff --git a/package.json b/package.json index 21f3cfb09..1b4f02517 100644 --- a/package.json +++ b/package.json @@ -19,19 +19,19 @@ "publish:types:next": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag next --access public", "publish:types:latest": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag latest --access public", "test": "yarn build:all && yarn test:girs:all && yarn validate:examples && yarn start:cli-examples:all", - "test:girs:all": "yarn clear:types && yarn build:types:all && yarn validate:types:root", - "test:girs:gjs": "yarn clear:types && yarn build:types && yarn validate:types:root", - "test:girs:gjs:vda1": "yarn clear:types && yarn build:types:vda1 && yarn validate:types:root", - "test:girs:gjs:gtk2": "yarn clear:types && yarn build:types:gtk2 && yarn validate:types:root", - "test:girs:gjs:gtk3": "yarn clear:types && yarn build:types:gtk3 && yarn validate:types:root", - "test:girs:gjs:gtk4": "yarn clear:types && yarn build:types:gtk4 && yarn validate:types:root", - "test:girs:gjs:gtk3+gtk4": "yarn clear:types && yarn build:types:gtk3+gtk4 && yarn validate:types:root", - "test:girs:gjs:gio": "yarn clear:types && yarn build:types:gio && yarn validate:types:root", - "test:girs:gjs:vte4": "yarn clear:types && yarn build:types:vte4 && yarn validate:types:root", - "test:girs:gjs:modemmanager1": "yarn clear:types && yarn build:types:modemmanager1 && yarn validate:types:root", - "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:timezonemap1 && yarn validate:types:root", - "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:rygelcore2 && yarn validate:types:root", - "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gcalc && yarn validate:types:root", + "test:girs:all": "yarn clear:types && yarn build:types:all && yarn validate:types:all", + "test:girs:gjs": "yarn clear:types && yarn build:types && yarn validate:types:all", + "test:girs:gjs:vda1": "yarn clear:types && yarn build:types:vda1 && yarn validate:types:all", + "test:girs:gjs:gtk2": "yarn clear:types && yarn build:types:gtk2 && yarn validate:types:all", + "test:girs:gjs:gtk3": "yarn clear:types && yarn build:types:gtk3 && yarn validate:types:all", + "test:girs:gjs:gtk4": "yarn clear:types && yarn build:types:gtk4 && yarn validate:types:all", + "test:girs:gjs:gtk3+gtk4": "yarn clear:types && yarn build:types:gtk3+gtk4 && yarn validate:types:all", + "test:girs:gjs:gio": "yarn clear:types && yarn build:types:gio && yarn validate:types:all", + "test:girs:gjs:vte4": "yarn clear:types && yarn build:types:vte4 && yarn validate:types:all", + "test:girs:gjs:modemmanager1": "yarn clear:types && yarn build:types:modemmanager1 && yarn validate:types:all", + "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:timezonemap1 && yarn validate:types:all", + "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:rygelcore2 && yarn validate:types:all", + "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gcalc && yarn validate:types:all", "build": "yarn build:parser && yarn build:lib && yarn build:generators && yarn build:cli", "build:parser": "yarn workspace @gi.ts/parser run build", "build:cli": "yarn workspace @ts-for-gir/cli run build", @@ -62,7 +62,7 @@ "validate": "yarn workspaces foreach -v --all --parallel run validate", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app", - "validate:types:root": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", + "validate:types:all": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", "clear": "yarn clear:build && yarn clear:types", "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", diff --git a/ts-for-gir.code-workspace b/ts-for-gir.code-workspace index dbc2ece91..15f260fe4 100644 --- a/ts-for-gir.code-workspace +++ b/ts-for-gir.code-workspace @@ -109,7 +109,7 @@ "sourceMaps": true, }, { - "name": "build:types:gjs", + "name": "build:types:all", "type": "node", "request": "launch", "cwd": "${workspaceRoot}/packages/cli", From 0fccf5c95567c5b762f9ef3f1292bef3031cc10c Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sun, 25 Feb 2024 01:44:35 +0100 Subject: [PATCH 23/53] Cleanup type generation configs --- .github/workflows/ci.yml | 4 ++-- .ts-for-gir.all.rc.js | 5 ++++- .ts-for-gir.gcalc.rc.js | 6 ------ .ts-for-gir.gio.rc.js | 8 ------- .ts-for-gir.gtk2.rc.js | 5 ----- .ts-for-gir.gtk3+gtk4.rc.js | 6 ------ .ts-for-gir.gtk3.rc.js | 5 ----- .ts-for-gir.gtk4.rc.js | 6 +++--- .ts-for-gir.modemmanager1.rc.js | 5 ----- .ts-for-gir.packages-all.rc.js | 3 +++ .ts-for-gir.packages-gtk4.rc.js | 2 +- .ts-for-gir.rygelcore2.rc.js | 5 ----- .ts-for-gir.timezonemap1.rc.js | 5 ----- .ts-for-gir.vda1.rc.js | 5 ----- .ts-for-gir.vte4.rc.js | 5 ----- DEVELOPMENT.md | 8 +++---- package.json | 37 +++++++-------------------------- ts-for-gir.code-workspace | 2 +- 18 files changed, 25 insertions(+), 97 deletions(-) delete mode 100644 .ts-for-gir.gcalc.rc.js delete mode 100644 .ts-for-gir.gio.rc.js delete mode 100644 .ts-for-gir.gtk2.rc.js delete mode 100644 .ts-for-gir.gtk3+gtk4.rc.js delete mode 100644 .ts-for-gir.gtk3.rc.js delete mode 100644 .ts-for-gir.modemmanager1.rc.js delete mode 100644 .ts-for-gir.rygelcore2.rc.js delete mode 100644 .ts-for-gir.timezonemap1.rc.js delete mode 100644 .ts-for-gir.vda1.rc.js delete mode 100644 .ts-for-gir.vte4.rc.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5b39ac68..5ee6d1079 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,5 +66,5 @@ jobs: run: sudo apt-get --yes install build-essential gobject-introspection libgirepository1.0-dev libcairo2 libcairo2-dev - run: yarn install - run: yarn run build - - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:all - - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:all + - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:local + - run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:local diff --git a/.ts-for-gir.all.rc.js b/.ts-for-gir.all.rc.js index 60eb00032..829eb580e 100644 --- a/.ts-for-gir.all.rc.js +++ b/.ts-for-gir.all.rc.js @@ -6,5 +6,8 @@ export default { ignore: [ 'Colorhug-1.0', // Duplicate of ColorHug-1.0 'GUPnP-DLNA-1.0', // Same namespace as GUPnP-1.0.gir, is this a bug or should we merge the type definitions? - ] + 'GstBase-1.0', // Unable to resolve type: BaseSink from GstBase in ClutterGst 1.0 + 'ClutterGst-1.0', // Depends on GstBase-1.0 + 'GstAudio-0.10', // Depends on GstBase-1.0 + ], } diff --git a/.ts-for-gir.gcalc.rc.js b/.ts-for-gir.gcalc.rc.js deleted file mode 100644 index f2d2f8db7..000000000 --- a/.ts-for-gir.gcalc.rc.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - modules: [/*'GCalc-1',*/ 'GCalc-2'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], - ignoreVersionConflicts: true -} diff --git a/.ts-for-gir.gio.rc.js b/.ts-for-gir.gio.rc.js deleted file mode 100644 index 06844b543..000000000 --- a/.ts-for-gir.gio.rc.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - modules: ['Gio-2.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], - promisify: true, - verbose: true, - outdir: './types', -} diff --git a/.ts-for-gir.gtk2.rc.js b/.ts-for-gir.gtk2.rc.js deleted file mode 100644 index deee954a8..000000000 --- a/.ts-for-gir.gtk2.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['Gtk-2.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/.ts-for-gir.gtk3+gtk4.rc.js b/.ts-for-gir.gtk3+gtk4.rc.js deleted file mode 100644 index 478b23c56..000000000 --- a/.ts-for-gir.gtk3+gtk4.rc.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - modules: ['Gtk-3.0', 'Gtk-4.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], - ignoreVersionConflicts: true -} diff --git a/.ts-for-gir.gtk3.rc.js b/.ts-for-gir.gtk3.rc.js deleted file mode 100644 index 909393ec4..000000000 --- a/.ts-for-gir.gtk3.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['Gtk-3.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/.ts-for-gir.gtk4.rc.js b/.ts-for-gir.gtk4.rc.js index 60d9f51bc..2ef566609 100644 --- a/.ts-for-gir.gtk4.rc.js +++ b/.ts-for-gir.gtk4.rc.js @@ -1,6 +1,6 @@ +import allLocalConfig from './.ts-for-gir.all.rc.js'; + export default { + ...allLocalConfig, modules: ['Gtk-4.0', 'Adw-1.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], - ignoreVersionConflicts: true, } diff --git a/.ts-for-gir.modemmanager1.rc.js b/.ts-for-gir.modemmanager1.rc.js deleted file mode 100644 index 505a1fa28..000000000 --- a/.ts-for-gir.modemmanager1.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['ModemManager-1.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/.ts-for-gir.packages-all.rc.js b/.ts-for-gir.packages-all.rc.js index 5dd31138b..26f1a46cc 100644 --- a/.ts-for-gir.packages-all.rc.js +++ b/.ts-for-gir.packages-all.rc.js @@ -47,6 +47,9 @@ export default { ignore: [ 'Colorhug-1.0', // Duplicate of ColorHug-1.0 'GUPnP-DLNA-1.0', // Same namespace as GUPnP-1.0.gir, is this a bug or should we merge the type definitions? + 'GstBase-1.0', // Unable to resolve type: BaseSink from GstBase in ClutterGst 1.0 + 'ClutterGst-1.0', // Depends on GstBase-1.0 + 'GstAudio-0.10', // Depends on GstBase-1.0 ], ignoreVersionConflicts: true, promisify: true, diff --git a/.ts-for-gir.packages-gtk4.rc.js b/.ts-for-gir.packages-gtk4.rc.js index 691163cdf..7485086e6 100644 --- a/.ts-for-gir.packages-gtk4.rc.js +++ b/.ts-for-gir.packages-gtk4.rc.js @@ -2,5 +2,5 @@ import allPackagesConfig from './.ts-for-gir.packages-all.rc.js'; export default { ...allPackagesConfig, - modules: ['Gtk-4.0'] + modules: ['Gtk-4.0', 'Adw-1.0'] } diff --git a/.ts-for-gir.rygelcore2.rc.js b/.ts-for-gir.rygelcore2.rc.js deleted file mode 100644 index 9f4ebb48b..000000000 --- a/.ts-for-gir.rygelcore2.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['RygelCore-2.6', 'RygelRenderer-2.6'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/.ts-for-gir.timezonemap1.rc.js b/.ts-for-gir.timezonemap1.rc.js deleted file mode 100644 index 3cb2a5c08..000000000 --- a/.ts-for-gir.timezonemap1.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['TimezoneMap-1.0'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/.ts-for-gir.vda1.rc.js b/.ts-for-gir.vda1.rc.js deleted file mode 100644 index 0e35bdf45..000000000 --- a/.ts-for-gir.vda1.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['Vda-1'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/.ts-for-gir.vte4.rc.js b/.ts-for-gir.vte4.rc.js deleted file mode 100644 index b17f590b2..000000000 --- a/.ts-for-gir.vte4.rc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - modules: ['Vte-4*'], - girDirectories: ['./vala-girs/gir-1.0'], - ignore: [], -} diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 45c6875b6..236d1e292 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -74,7 +74,7 @@ yarn run build Generate example type definitions: ```bash -yarn run test:girs:gjs:gtk4 +yarn run test:girs:local:gtk4 ``` ## Gir XML Format @@ -105,7 +105,7 @@ npm install -g yarn To validate all your generated type definition files in this project run ```bash -yarn run validate:types:all +yarn run validate:types:local ``` To validate only your type definition files for GJS @@ -141,9 +141,7 @@ git submodule update --init Now you can run the test with ```bash -yarn run test:girs:gjs -yarn run test:girs:node -# or yarn run test:girs:all +yarn run test:girs:local ``` # FAQ diff --git a/package.json b/package.json index 1b4f02517..56235a24f 100644 --- a/package.json +++ b/package.json @@ -18,20 +18,9 @@ "publish:app:latest": "yarn workspaces foreach -v --all --parallel --no-private --include '@ts-for-gir/*' npm publish --tolerate-republish --tag latest --access public", "publish:types:next": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag next --access public", "publish:types:latest": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag latest --access public", - "test": "yarn build:all && yarn test:girs:all && yarn validate:examples && yarn start:cli-examples:all", - "test:girs:all": "yarn clear:types && yarn build:types:all && yarn validate:types:all", - "test:girs:gjs": "yarn clear:types && yarn build:types && yarn validate:types:all", - "test:girs:gjs:vda1": "yarn clear:types && yarn build:types:vda1 && yarn validate:types:all", - "test:girs:gjs:gtk2": "yarn clear:types && yarn build:types:gtk2 && yarn validate:types:all", - "test:girs:gjs:gtk3": "yarn clear:types && yarn build:types:gtk3 && yarn validate:types:all", - "test:girs:gjs:gtk4": "yarn clear:types && yarn build:types:gtk4 && yarn validate:types:all", - "test:girs:gjs:gtk3+gtk4": "yarn clear:types && yarn build:types:gtk3+gtk4 && yarn validate:types:all", - "test:girs:gjs:gio": "yarn clear:types && yarn build:types:gio && yarn validate:types:all", - "test:girs:gjs:vte4": "yarn clear:types && yarn build:types:vte4 && yarn validate:types:all", - "test:girs:gjs:modemmanager1": "yarn clear:types && yarn build:types:modemmanager1 && yarn validate:types:all", - "test:girs:gjs:timezonemap1": "yarn clear:types && yarn build:types:timezonemap1 && yarn validate:types:all", - "test:girs:gjs:rygelcore2": "yarn clear:types && yarn build:types:rygelcore2 && yarn validate:types:all", - "test:girs:gjs:gcalc": "yarn clear:types && yarn build:types:gcalc && yarn validate:types:all", + "test": "yarn build:all && yarn test:girs:local && yarn validate:examples && yarn start:cli-examples:all", + "test:girs:local": "yarn clear:types && yarn build:types:local && yarn validate:types:local", + "test:girs:local:gtk4": "yarn clear:types && yarn build:types:local:gtk4 && yarn validate:types:local", "build": "yarn build:parser && yarn build:lib && yarn build:generators && yarn build:cli", "build:parser": "yarn workspace @gi.ts/parser run build", "build:cli": "yarn workspace @ts-for-gir/cli run build", @@ -44,25 +33,15 @@ "build:all": "yarn build && yarn build:examples", "start:cli-examples:all": "yarn start:cli-examples:gjs", "start:cli-examples:gjs": "yarn workspace ts-for-gir-glib-2-spawn-command-example run start && yarn workspace ts-for-gir-gio-2-cat-promisify-packages run start", - "build:types:packages:all": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-all.rc.js' && yarn install", + "build:types:packages": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-all.rc.js' && yarn install", "build:types:packages:gtk4": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-gtk4.rc.js' && yarn install", - "build:types:all": "yarn ts-for-gir generate --configName='.ts-for-gir.all.rc.js'", - "build:types:vda1": "yarn ts-for-gir generate --configName='.ts-for-gir.vda1.rc.js'", - "build:types:gtk2": "yarn ts-for-gir generate --configName='.ts-for-gir.gtk2.rc.js'", - "build:types:gtk3": "yarn ts-for-gir generate --configName='.ts-for-gir.gtk3.rc.js'", - "build:types:gtk4": "yarn ts-for-gir generate --configName='.ts-for-gir.gtk4.rc.js'", - "build:types:gtk3+gtk4": "yarn ts-for-gir generate --configName='.ts-for-gir.gtk3+gtk4.rc.js'", - "build:types:gio": "yarn ts-for-gir generate --configName='.ts-for-gir.gio.rc.js'", - "build:types:vte4": "yarn ts-for-gir generate --configName='.ts-for-gir.vte4.rc.js'", - "build:types:modemmanager1": "yarn ts-for-gir generate --configName='.ts-for-gir.modemmanager1.rc.js'", - "build:types:timezonemap1": "yarn ts-for-gir generate --configName='.ts-for-gir.timezonemap1.rc.js'", - "build:types:rygelcore2": "yarn ts-for-gir generate --configName='.ts-for-gir.rygelcore2.rc.js'", - "build:types:gcalc": "yarn ts-for-gir generate --configName='.ts-for-gir.gcalc.rc.js'", - "build:types": "yarn build:types:all", + "build:types:local": "yarn ts-for-gir generate --configName='.ts-for-gir.all.rc.js'", + "build:types:local:gtk4": "yarn ts-for-gir generate --configName='.ts-for-gir.gtk4.rc.js'", + "build:types": "yarn build:types:local", "validate": "yarn workspaces foreach -v --all --parallel run validate", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app", - "validate:types:all": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", + "validate:types:local": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", "clear": "yarn clear:build && yarn clear:types", "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", diff --git a/ts-for-gir.code-workspace b/ts-for-gir.code-workspace index 15f260fe4..e0644cea5 100644 --- a/ts-for-gir.code-workspace +++ b/ts-for-gir.code-workspace @@ -109,7 +109,7 @@ "sourceMaps": true, }, { - "name": "build:types:all", + "name": "build:types:local", "type": "node", "request": "launch", "cwd": "${workspaceRoot}/packages/cli", From 2ede2e07894a1e927c48ecfb89298ea9f62d0b81 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sun, 25 Feb 2024 02:17:20 +0100 Subject: [PATCH 24/53] Build full NPM package --- .../src/type-definition-generator.ts | 2 +- packages/generator-typescript/templates/README.md | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 5cd082026..2e597473a 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -1702,7 +1702,7 @@ export class TypeDefinitionGenerator implements Generator { public async generate(registry: NSRegistry, module: GirModule) { this.module = new ModuleGenerator(module, this.config) - await this.module.exportModuleTS() + await this.module.exportModule(registry, module) } public async start() { diff --git a/packages/generator-typescript/templates/README.md b/packages/generator-typescript/templates/README.md index ca539fe3e..ae4d13de6 100644 --- a/packages/generator-typescript/templates/README.md +++ b/packages/generator-typescript/templates/README.md @@ -37,7 +37,7 @@ const <%- pkg.namespace %> = require('<%- pkg.importPath %>'); ### Ambient Modules You can also use [ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) to import this module like you would do this in JavaScript. -For this you need to include `<%- npmScope %>/<%- importName %>` or `<%- npmScope %>/<%- importName %>/<%= environment === 'gjs' ? "ambient" : "import" %>` in your `tsconfig` or entry point Typescript file: +For this you need to include `<%- npmScope %>/<%- importName %>` or `<%- npmScope %>/<%- importName %>/ambient` in your `tsconfig` or entry point Typescript file: `index.ts`: ```ts @@ -57,18 +57,10 @@ import '<%- npmScope %>/<%- importName %>' Now you can import the ambient module with TypeScript support: -<%_ if(environment === 'gjs'){ _%> ```ts import <%= pkg.namespace %> from 'gi://<%= pkg.namespace %>?version=<%= pkg.version %>'; ``` -<%_ } else { _%> -```ts -const gi = require('node-gtk') -const <%= pkg.namespace %> = gi.require('<%= pkg.namespace %>', '<%= pkg.version %>') -``` -<%_ } _%> -<%_ if(environment === 'gjs'){ _%> ### Global import You can also import the module with Typescript support using the global `imports.gi` object of GJS. @@ -95,7 +87,6 @@ Now you have also type support for this, too: ```ts const <%= pkg.namespace %> = imports.gi.<%= pkg.namespace %>; ``` -<%_ } _%> ### ESM vs. CommonJS From 1a6938e56092c2756642d5b1d46b46d0b1d4d128 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sun, 25 Feb 2024 02:17:36 +0100 Subject: [PATCH 25/53] Fix type validation script --- package.json | 8 ++++---- tsconfig.json | 4 ++-- tsconfig.node.json | 8 -------- 3 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 tsconfig.node.json diff --git a/package.json b/package.json index 56235a24f..76d20afeb 100644 --- a/package.json +++ b/package.json @@ -33,19 +33,19 @@ "build:all": "yarn build && yarn build:examples", "start:cli-examples:all": "yarn start:cli-examples:gjs", "start:cli-examples:gjs": "yarn workspace ts-for-gir-glib-2-spawn-command-example run start && yarn workspace ts-for-gir-gio-2-cat-promisify-packages run start", - "build:types:packages": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-all.rc.js' && yarn install", - "build:types:packages:gtk4": "NODE_OPTIONS=--max-old-space-size=25600 yarn ts-for-gir generate --configName='.ts-for-gir.packages-gtk4.rc.js' && yarn install", + "build:types:packages": "yarn ts-for-gir generate --configName='.ts-for-gir.packages-all.rc.js' && yarn install", + "build:types:packages:gtk4": "yarn ts-for-gir generate --configName='.ts-for-gir.packages-gtk4.rc.js' && yarn install", "build:types:local": "yarn ts-for-gir generate --configName='.ts-for-gir.all.rc.js'", "build:types:local:gtk4": "yarn ts-for-gir generate --configName='.ts-for-gir.gtk4.rc.js'", "build:types": "yarn build:types:local", "validate": "yarn workspaces foreach -v --all --parallel run validate", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app", - "validate:types:local": "NODE_OPTIONS=--max_old_space_size=9216 tsc --project tsconfig.json", + "validate:types:local": "tsc --project tsconfig.json", "clear": "yarn clear:build && yarn clear:types", "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", - "clear:types:gjs": "rimraf ./@types", + "clear:types:local": "rimraf ./@types", "clear:examples": "yarn workspaces foreach -v --all --exclude @ts-for-gir/cli,@ts-for-gir/lib,@ts-for-gir/generator-base,@ts-for-gir/generator-typescript,@ts-for-gir/generator-html-doc --parallel run clear", "clear:all": "yarn build && yarn clear:examples", "watch": "concurrently 'yarn:watch:*'", diff --git a/tsconfig.json b/tsconfig.json index 82a7417d7..365d95db7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,6 @@ "noImplicitThis": true, "alwaysStrict": true }, - "include": ["@types/*.ts"], - "exclude": ["@types/node-*.ts"] + "include": ["@types/**/*.ts"], + "exclude": [] } diff --git a/tsconfig.node.json b/tsconfig.node.json deleted file mode 100644 index 131a6cb98..000000000 --- a/tsconfig.node.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "types": ["node"], - }, - "include": ["@types/node-*.ts"], - "exclude": [] -} From 6901fe12a50cb6ac379b0973b535bfce818c3cce Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sun, 25 Feb 2024 02:27:00 +0100 Subject: [PATCH 26/53] fix(github): Do not run node cli examples --- .github/workflows/ci.yml | 3 +-- package.json | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ee6d1079..64966011b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,7 @@ jobs: - run: yarn run build - run: yarn run build:examples - run: yarn run validate:examples - - run: yarn run start:cli-examples:gjs - - run: yarn run start:cli-examples:node + - run: yarn run start:cli-examples gjs-types-all: diff --git a/package.json b/package.json index 76d20afeb..3478b6fc8 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "publish:app:latest": "yarn workspaces foreach -v --all --parallel --no-private --include '@ts-for-gir/*' npm publish --tolerate-republish --tag latest --access public", "publish:types:next": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag next --access public", "publish:types:latest": "yarn workspaces foreach -v --all --parallel --no-private --include '@girs/*' npm publish --tolerate-republish --tag latest --access public", - "test": "yarn build:all && yarn test:girs:local && yarn validate:examples && yarn start:cli-examples:all", + "test": "yarn build:all && yarn test:girs:local && yarn validate:examples && yarn start:cli-examples", "test:girs:local": "yarn clear:types && yarn build:types:local && yarn validate:types:local", "test:girs:local:gtk4": "yarn clear:types && yarn build:types:local:gtk4 && yarn validate:types:local", "build": "yarn build:parser && yarn build:lib && yarn build:generators && yarn build:cli", @@ -31,8 +31,7 @@ "build:generator-html-doc": "yarn workspace @ts-for-gir/generator-html-doc run build", "build:examples": "yarn workspaces foreach -v --all --exclude '@ts-for-gir/*' --parallel run build", "build:all": "yarn build && yarn build:examples", - "start:cli-examples:all": "yarn start:cli-examples:gjs", - "start:cli-examples:gjs": "yarn workspace ts-for-gir-glib-2-spawn-command-example run start && yarn workspace ts-for-gir-gio-2-cat-promisify-packages run start", + "start:cli-examples": "yarn workspace ts-for-gir-glib-2-spawn-command-example run start && yarn workspace ts-for-gir-gio-2-cat-promisify-packages run start", "build:types:packages": "yarn ts-for-gir generate --configName='.ts-for-gir.packages-all.rc.js' && yarn install", "build:types:packages:gtk4": "yarn ts-for-gir generate --configName='.ts-for-gir.packages-gtk4.rc.js' && yarn install", "build:types:local": "yarn ts-for-gir generate --configName='.ts-for-gir.all.rc.js'", From 9f39e23e97da0f54a0b0f92a015038f681afb8e3 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sun, 25 Feb 2024 09:17:19 +0100 Subject: [PATCH 27/53] Upgrade dependencies --- examples/gjs/adw-1-hello/package.json | 6 +- examples/gjs/gio-2-cat-alias/package.json | 4 +- examples/gjs/gio-2-cat-packages/package.json | 4 +- examples/gjs/gio-2-cat-promisify/package.json | 4 +- .../gjs/gio-2-cat-types-only/package.json | 4 +- examples/gjs/gio-2-cat/package.json | 4 +- examples/gjs/gio-2-dbus/package.json | 4 +- examples/gjs/gio-2-list-model/package.json | 4 +- .../gjs/glib-2-spawn-command/package.json | 4 +- examples/gjs/glib-2-variant/package.json | 4 +- examples/gjs/gtk-3-browser/package.json | 4 +- examples/gjs/gtk-3-builder/package.json | 4 +- examples/gjs/gtk-3-calc/package.json | 4 +- examples/gjs/gtk-3-editor/package.json | 4 +- examples/gjs/gtk-3-gettext/package.json | 4 +- examples/gjs/gtk-3-hello-2/package.json | 4 +- examples/gjs/gtk-3-hello/package.json | 4 +- examples/gjs/gtk-3-template/package.json | 4 +- examples/gjs/gtk-3-webkit/package.json | 4 +- examples/gjs/gtk-4-application/package.json | 4 +- examples/gjs/gtk-4-custom-widget/package.json | 4 +- examples/gjs/gtk-4-list-store/package.json | 4 +- examples/gjs/gtk-4-template/package.json | 4 +- examples/gjs/run-async/package.json | 4 +- examples/gjs/soup-3-http/package.json | 4 +- examples/gjs/soup-3-websocket/package.json | 4 +- examples/gjs/timers/package.json | 4 +- package.json | 8 +- packages/cli/package.json | 12 +- packages/generator-base/package.json | 10 +- packages/generator-html-doc/package.json | 10 +- packages/generator-typescript/package.json | 14 +- packages/lib/package.json | 1 - packages/lib/src/gir-module.ts | 1 + packages/parser/package.json | 16 +- packages/parser/src/parser.ts | 82 +- yarn.lock | 878 ++++++++++++------ 37 files changed, 747 insertions(+), 395 deletions(-) diff --git a/examples/gjs/adw-1-hello/package.json b/examples/gjs/adw-1-hello/package.json index a2770dfe3..b038c8b87 100644 --- a/examples/gjs/adw-1-hello/package.json +++ b/examples/gjs/adw-1-hello/package.json @@ -24,8 +24,8 @@ "@babel/core": "^7.23.9", "@rollup/plugin-babel": "^6.0.4", "@ts-for-gir/cli": "workspace:^", - "rollup": "^4.11.0", - "typescript": "5.2.2", - "vite": "^5.1.3" + "rollup": "^4.12.0", + "typescript": "^5.2.2", + "vite": "^5.1.4" } } diff --git a/examples/gjs/gio-2-cat-alias/package.json b/examples/gjs/gio-2-cat-alias/package.json index f7e38a754..b90facbca 100644 --- a/examples/gjs/gio-2-cat-alias/package.json +++ b/examples/gjs/gio-2-cat-alias/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gio-2-cat-packages/package.json b/examples/gjs/gio-2-cat-packages/package.json index 6f1537820..d9cf0679b 100644 --- a/examples/gjs/gio-2-cat-packages/package.json +++ b/examples/gjs/gio-2-cat-packages/package.json @@ -19,7 +19,7 @@ "author": "Pascal Garber ", "license": "MIT", "devDependencies": { - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gio-2-cat-promisify/package.json b/examples/gjs/gio-2-cat-promisify/package.json index 7a75e6bc2..f5ea8451d 100644 --- a/examples/gjs/gio-2-cat-promisify/package.json +++ b/examples/gjs/gio-2-cat-promisify/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gio-2-cat-types-only/package.json b/examples/gjs/gio-2-cat-types-only/package.json index d9b03c141..5b57953c3 100644 --- a/examples/gjs/gio-2-cat-types-only/package.json +++ b/examples/gjs/gio-2-cat-types-only/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gio-2-cat/package.json b/examples/gjs/gio-2-cat/package.json index 72fdc048d..243e02634 100644 --- a/examples/gjs/gio-2-cat/package.json +++ b/examples/gjs/gio-2-cat/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gio-2-dbus/package.json b/examples/gjs/gio-2-dbus/package.json index af22d7100..681ba56c8 100644 --- a/examples/gjs/gio-2-dbus/package.json +++ b/examples/gjs/gio-2-dbus/package.json @@ -25,7 +25,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gio-2-list-model/package.json b/examples/gjs/gio-2-list-model/package.json index 17de96e8f..74286fed3 100644 --- a/examples/gjs/gio-2-list-model/package.json +++ b/examples/gjs/gio-2-list-model/package.json @@ -21,7 +21,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/glib-2-spawn-command/package.json b/examples/gjs/glib-2-spawn-command/package.json index fbe1ec326..8d879b84b 100644 --- a/examples/gjs/glib-2-spawn-command/package.json +++ b/examples/gjs/glib-2-spawn-command/package.json @@ -25,8 +25,8 @@ "@ts-for-gir/cli": "workspace:^", "fork-ts-checker-webpack-plugin": "^9.0.2", "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", + "typescript": "^5.2.2", + "webpack": "^5.90.3", "webpack-cli": "^5.1.4" } } diff --git a/examples/gjs/glib-2-variant/package.json b/examples/gjs/glib-2-variant/package.json index 6f311353e..27ebddab0 100644 --- a/examples/gjs/glib-2-variant/package.json +++ b/examples/gjs/glib-2-variant/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-3-browser/package.json b/examples/gjs/gtk-3-browser/package.json index dcb09ed6f..2f60c6835 100644 --- a/examples/gjs/gtk-3-browser/package.json +++ b/examples/gjs/gtk-3-browser/package.json @@ -26,8 +26,8 @@ "@ts-for-gir/cli": "workspace:^", "fork-ts-checker-webpack-plugin": "^9.0.2", "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", + "typescript": "^5.2.2", + "webpack": "^5.90.3", "webpack-cli": "^5.1.4" } } diff --git a/examples/gjs/gtk-3-builder/package.json b/examples/gjs/gtk-3-builder/package.json index 6881b5d70..ff8a8cd99 100644 --- a/examples/gjs/gtk-3-builder/package.json +++ b/examples/gjs/gtk-3-builder/package.json @@ -26,8 +26,8 @@ "fork-ts-checker-webpack-plugin": "^9.0.2", "raw-loader": "^4.0.2", "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", + "typescript": "^5.2.2", + "webpack": "^5.90.3", "webpack-cli": "^5.1.4" } } diff --git a/examples/gjs/gtk-3-calc/package.json b/examples/gjs/gtk-3-calc/package.json index 62f79e1a8..2e481988c 100644 --- a/examples/gjs/gtk-3-calc/package.json +++ b/examples/gjs/gtk-3-calc/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-3-editor/package.json b/examples/gjs/gtk-3-editor/package.json index d35f56bd7..2031a3005 100644 --- a/examples/gjs/gtk-3-editor/package.json +++ b/examples/gjs/gtk-3-editor/package.json @@ -25,8 +25,8 @@ "@ts-for-gir/cli": "workspace:^", "fork-ts-checker-webpack-plugin": "^9.0.2", "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", + "typescript": "^5.2.2", + "webpack": "^5.90.3", "webpack-cli": "^5.1.4" } } diff --git a/examples/gjs/gtk-3-gettext/package.json b/examples/gjs/gtk-3-gettext/package.json index cc171e95d..4047fb97e 100644 --- a/examples/gjs/gtk-3-gettext/package.json +++ b/examples/gjs/gtk-3-gettext/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-3-hello-2/package.json b/examples/gjs/gtk-3-hello-2/package.json index bec814137..6bc8eb193 100644 --- a/examples/gjs/gtk-3-hello-2/package.json +++ b/examples/gjs/gtk-3-hello-2/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-3-hello/package.json b/examples/gjs/gtk-3-hello/package.json index fb92365e6..cca15c9dc 100644 --- a/examples/gjs/gtk-3-hello/package.json +++ b/examples/gjs/gtk-3-hello/package.json @@ -25,8 +25,8 @@ "@ts-for-gir/cli": "workspace:^", "fork-ts-checker-webpack-plugin": "^9.0.2", "ts-loader": "^9.5.1", - "typescript": "5.2.2", - "webpack": "^5.90.2", + "typescript": "^5.2.2", + "webpack": "^5.90.3", "webpack-cli": "^5.1.4" } } diff --git a/examples/gjs/gtk-3-template/package.json b/examples/gjs/gtk-3-template/package.json index e6eb6365a..037c24fda 100644 --- a/examples/gjs/gtk-3-template/package.json +++ b/examples/gjs/gtk-3-template/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-3-webkit/package.json b/examples/gjs/gtk-3-webkit/package.json index 0cfe131c9..d9009f8a4 100644 --- a/examples/gjs/gtk-3-webkit/package.json +++ b/examples/gjs/gtk-3-webkit/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-4-application/package.json b/examples/gjs/gtk-4-application/package.json index 56997dcf4..7a61ef3d2 100644 --- a/examples/gjs/gtk-4-application/package.json +++ b/examples/gjs/gtk-4-application/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-4-custom-widget/package.json b/examples/gjs/gtk-4-custom-widget/package.json index 14e239fbc..01777cc62 100644 --- a/examples/gjs/gtk-4-custom-widget/package.json +++ b/examples/gjs/gtk-4-custom-widget/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-4-list-store/package.json b/examples/gjs/gtk-4-list-store/package.json index 72b8b92a1..5e9e59260 100644 --- a/examples/gjs/gtk-4-list-store/package.json +++ b/examples/gjs/gtk-4-list-store/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/gtk-4-template/package.json b/examples/gjs/gtk-4-template/package.json index 3e1e3775f..89ea3d24d 100644 --- a/examples/gjs/gtk-4-template/package.json +++ b/examples/gjs/gtk-4-template/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/run-async/package.json b/examples/gjs/run-async/package.json index ea6e95185..58836dffc 100644 --- a/examples/gjs/run-async/package.json +++ b/examples/gjs/run-async/package.json @@ -19,7 +19,7 @@ "author": "Pascal Garber ", "license": "MIT", "devDependencies": { - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/soup-3-http/package.json b/examples/gjs/soup-3-http/package.json index c71dd412d..02f1e7772 100644 --- a/examples/gjs/soup-3-http/package.json +++ b/examples/gjs/soup-3-http/package.json @@ -24,7 +24,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/soup-3-websocket/package.json b/examples/gjs/soup-3-websocket/package.json index e2f978597..a62e942ee 100644 --- a/examples/gjs/soup-3-websocket/package.json +++ b/examples/gjs/soup-3-websocket/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/examples/gjs/timers/package.json b/examples/gjs/timers/package.json index c27ad41f5..777a4d6e8 100644 --- a/examples/gjs/timers/package.json +++ b/examples/gjs/timers/package.json @@ -22,7 +22,7 @@ "license": "MIT", "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" + "esbuild": "^0.20.1", + "typescript": "^5.2.2" } } diff --git a/package.json b/package.json index 3478b6fc8..1051c57b0 100644 --- a/package.json +++ b/package.json @@ -79,15 +79,15 @@ ], "devDependencies": { "@ts-for-gir/cli": "workspace:^", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", "concurrently": "^8.2.2", - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "typescript": "5.2.2" + "typescript": "^5.2.2" }, "workspaces": [ "examples/*/*", diff --git a/packages/cli/package.json b/packages/cli/package.json index 821e9fe63..640613dad 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -54,17 +54,17 @@ ], "devDependencies": { "@types/inquirer": "^9.0.7", - "@types/node": "^20.11.18", + "@types/node": "^20.11.20", "@types/yargs": "^17.0.32", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", "ts-node": "^10.9.2", - "typescript": "5.2.2" + "typescript": "^5.2.2" }, "dependencies": { "@gi.ts/parser": "workspace:^", @@ -74,7 +74,7 @@ "@ts-for-gir/lib": "workspace:^", "colorette": "^2.0.20", "cosmiconfig": "^9.0.0", - "inquirer": "^9.2.14", + "inquirer": "^9.2.15", "tiny-glob": "^0.2.9", "yargs": "^17.7.2" } diff --git a/packages/generator-base/package.json b/packages/generator-base/package.json index aef892d07..173cd2c06 100644 --- a/packages/generator-base/package.json +++ b/packages/generator-base/package.json @@ -34,15 +34,15 @@ "generator" ], "devDependencies": { - "@types/node": "^20.11.18", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", + "@types/node": "^20.11.20", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "typescript": "5.2.2" + "typescript": "^5.2.2" }, "dependencies": { "@ts-for-gir/lib": "workspace:^" diff --git a/packages/generator-html-doc/package.json b/packages/generator-html-doc/package.json index 784fe5f04..dbe941a18 100644 --- a/packages/generator-html-doc/package.json +++ b/packages/generator-html-doc/package.json @@ -34,15 +34,15 @@ "generator" ], "devDependencies": { - "@types/node": "^20.11.18", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", + "@types/node": "^20.11.20", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "typescript": "5.2.2" + "typescript": "^5.2.2" }, "dependencies": { "@ts-for-gir/generator-base": "workspace:^", diff --git a/packages/generator-typescript/package.json b/packages/generator-typescript/package.json index 6be21a5bb..61ec01b51 100644 --- a/packages/generator-typescript/package.json +++ b/packages/generator-typescript/package.json @@ -41,17 +41,17 @@ "generator" ], "devDependencies": { - "@types/ejs": "^3.1.4", - "@types/node": "^20.11.18", - "@types/xml2js": "^0", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", + "@types/ejs": "^3.1.5", + "@types/node": "^20.11.20", + "@types/xml2js": "^0.4.14", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "typescript": "5.2.2" + "typescript": "^5.2.2" }, "dependencies": { "@ts-for-gir/generator-base": "workspace:^", diff --git a/packages/lib/package.json b/packages/lib/package.json index e8f22e4df..507397d0f 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -54,7 +54,6 @@ "@types/eslint": "8.56.2", "@types/lodash": "^4.14.202", "@types/node": "^20.11.18", - "@types/xml2js": "^0.4.14", "@typescript-eslint/eslint-plugin": "^7.0.1", "@typescript-eslint/parser": "^7.0.1", "eslint": "^8.56.0", diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index 7dddd8ff2..a5aeb52b2 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -824,6 +824,7 @@ export class GirModule { ?.filter(isIntrospectable) // Avoid attempting to alias non-introspectable symbols. .map((b) => { + console.debug('b', b) b.type = b.type ?.filter((t): t is NamedType => !!(t && t.$.name)) .map((t) => { diff --git a/packages/parser/package.json b/packages/parser/package.json index 240ad0401..76a3503f1 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -28,15 +28,15 @@ "prepack": "rm -rf dist && yarn build" }, "dependencies": { - "fast-xml-parser": "^3.17.5" + "fast-xml-parser": "^4.3.5" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^6.9.1", - "@typescript-eslint/parser": "^6.9.1", - "eslint": "^8.52.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.1", - "prettier": "^3.0.3", - "typescript": "5.1.3" + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "prettier": "^3.2.5", + "typescript": "^5.2.2" } } diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 5c3b97110..98d6df056 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -1,17 +1,73 @@ -import { parse } from "fast-xml-parser"; +import { XMLParser } from "fast-xml-parser"; import { GirXML } from "./xml.js"; +// TODO: Treat properties that contain only one element like `repository`, 'namespace', 'package', ... as an object instead of an array +const isArrayProperty = [ + "type", + "include", + "c:include", + "member", + "parameter", + "parameters", + "return-value", + "class", + "constructor", + "constructors", + "method", + "virtual-method", + "property", + "field", + "constant", + "enumeration", + "bitfield", + "alias", + "function", + "callback", + "record", + "union", + "interface", + "namespace", + "repository", + "package", + "glib:boxed", + "implements", + "prerequisite", + "doc", + "doc-deprecated", + "signal", + "glib:signal", + "annotation", + "stability", + "doc-version", + "doc-stability", + "source-position", + "column", + "array", + "moved-to", + "varargs", + "instance-parameter", +]; + +const parser = new XMLParser({ + attributeNamePrefix: "", + attributesGroupName: "$", // default is 'false', + textNodeName: "_", + ignoreAttributes: false, + removeNSPrefix: false, + allowBooleanAttributes: true, + parseTagValue: true, + parseAttributeValue: false, + trimValues: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + isArray: (name, _jpath, isLeafNode, _isAttribute) => { + // Restore previous behaviour... + if (isArrayProperty.includes(name)) { + return true; + } + return !isLeafNode; + }, +}); + export function parseGir(contents: string): GirXML { - return parse(contents, { - attributeNamePrefix: "", - attrNodeName: "$", // default is 'false', - textNodeName: "_", - ignoreAttributes: false, - ignoreNameSpace: false, - allowBooleanAttributes: true, - parseNodeValue: true, - parseAttributeValue: false, - trimValues: true, - arrayMode: true, - }) as GirXML; + return parser.parse(contents) as GirXML; } diff --git a/yarn.lock b/yarn.lock index 54b2ce855..e5133da88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -297,6 +297,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/aix-ppc64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/aix-ppc64@npm:0.20.1" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + "@esbuild/android-arm64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/android-arm64@npm:0.19.8" @@ -311,6 +318,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-arm64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/android-arm64@npm:0.20.1" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/android-arm@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/android-arm@npm:0.19.8" @@ -325,6 +339,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-arm@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/android-arm@npm:0.20.1" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + "@esbuild/android-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/android-x64@npm:0.19.8" @@ -339,6 +360,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/android-x64@npm:0.20.1" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + "@esbuild/darwin-arm64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/darwin-arm64@npm:0.19.8" @@ -353,6 +381,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/darwin-arm64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/darwin-arm64@npm:0.20.1" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/darwin-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/darwin-x64@npm:0.19.8" @@ -367,6 +402,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/darwin-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/darwin-x64@npm:0.20.1" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + "@esbuild/freebsd-arm64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/freebsd-arm64@npm:0.19.8" @@ -381,6 +423,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/freebsd-arm64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/freebsd-arm64@npm:0.20.1" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/freebsd-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/freebsd-x64@npm:0.19.8" @@ -395,6 +444,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/freebsd-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/freebsd-x64@npm:0.20.1" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + "@esbuild/linux-arm64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-arm64@npm:0.19.8" @@ -409,6 +465,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-arm64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-arm64@npm:0.20.1" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/linux-arm@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-arm@npm:0.19.8" @@ -423,6 +486,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-arm@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-arm@npm:0.20.1" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + "@esbuild/linux-ia32@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-ia32@npm:0.19.8" @@ -437,6 +507,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-ia32@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-ia32@npm:0.20.1" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + "@esbuild/linux-loong64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-loong64@npm:0.19.8" @@ -451,6 +528,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-loong64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-loong64@npm:0.20.1" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + "@esbuild/linux-mips64el@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-mips64el@npm:0.19.8" @@ -465,6 +549,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-mips64el@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-mips64el@npm:0.20.1" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + "@esbuild/linux-ppc64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-ppc64@npm:0.19.8" @@ -479,6 +570,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-ppc64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-ppc64@npm:0.20.1" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + "@esbuild/linux-riscv64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-riscv64@npm:0.19.8" @@ -493,6 +591,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-riscv64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-riscv64@npm:0.20.1" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + "@esbuild/linux-s390x@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-s390x@npm:0.19.8" @@ -507,6 +612,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-s390x@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-s390x@npm:0.20.1" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + "@esbuild/linux-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/linux-x64@npm:0.19.8" @@ -521,6 +633,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/linux-x64@npm:0.20.1" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + "@esbuild/netbsd-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/netbsd-x64@npm:0.19.8" @@ -535,6 +654,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/netbsd-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/netbsd-x64@npm:0.20.1" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + "@esbuild/openbsd-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/openbsd-x64@npm:0.19.8" @@ -549,6 +675,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/openbsd-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/openbsd-x64@npm:0.20.1" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + "@esbuild/sunos-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/sunos-x64@npm:0.19.8" @@ -563,6 +696,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/sunos-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/sunos-x64@npm:0.20.1" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + "@esbuild/win32-arm64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/win32-arm64@npm:0.19.8" @@ -577,6 +717,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/win32-arm64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/win32-arm64@npm:0.20.1" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/win32-ia32@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/win32-ia32@npm:0.19.8" @@ -591,6 +738,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/win32-ia32@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/win32-ia32@npm:0.20.1" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + "@esbuild/win32-x64@npm:0.19.8": version: 0.19.8 resolution: "@esbuild/win32-x64@npm:0.19.8" @@ -605,6 +759,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/win32-x64@npm:0.20.1": + version: 0.20.1 + resolution: "@esbuild/win32-x64@npm:0.20.1" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -647,18 +808,25 @@ __metadata: languageName: node linkType: hard +"@eslint/js@npm:8.57.0": + version: 8.57.0 + resolution: "@eslint/js@npm:8.57.0" + checksum: 10/3c501ce8a997cf6cbbaf4ed358af5492875e3550c19b9621413b82caa9ae5382c584b0efa79835639e6e0ddaa568caf3499318e5bdab68643ef4199dce5eb0a0 + languageName: node + linkType: hard + "@gi.ts/parser@workspace:^, @gi.ts/parser@workspace:packages/parser": version: 0.0.0-use.local resolution: "@gi.ts/parser@workspace:packages/parser" dependencies: - "@typescript-eslint/eslint-plugin": "npm:^6.9.1" - "@typescript-eslint/parser": "npm:^6.9.1" - eslint: "npm:^8.52.0" - eslint-config-prettier: "npm:^9.0.0" - eslint-plugin-prettier: "npm:^5.0.1" - fast-xml-parser: "npm:^3.17.5" - prettier: "npm:^3.0.3" - typescript: "npm:5.1.3" + "@typescript-eslint/eslint-plugin": "npm:^7.0.2" + "@typescript-eslint/parser": "npm:^7.0.2" + eslint: "npm:^8.57.0" + eslint-config-prettier: "npm:^9.1.0" + eslint-plugin-prettier: "npm:^5.1.3" + fast-xml-parser: "npm:^4.3.5" + prettier: "npm:^3.2.5" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -673,6 +841,17 @@ __metadata: languageName: node linkType: hard +"@humanwhocodes/config-array@npm:^0.11.14": + version: 0.11.14 + resolution: "@humanwhocodes/config-array@npm:0.11.14" + dependencies: + "@humanwhocodes/object-schema": "npm:^2.0.2" + debug: "npm:^4.3.1" + minimatch: "npm:^3.0.5" + checksum: 10/3ffb24ecdfab64014a230e127118d50a1a04d11080cbb748bc21629393d100850496456bbcb4e8c438957fe0934430d731042f1264d6a167b62d32fc2863580a + languageName: node + linkType: hard + "@humanwhocodes/module-importer@npm:^1.0.1": version: 1.0.1 resolution: "@humanwhocodes/module-importer@npm:1.0.1" @@ -687,6 +866,13 @@ __metadata: languageName: node linkType: hard +"@humanwhocodes/object-schema@npm:^2.0.2": + version: 2.0.2 + resolution: "@humanwhocodes/object-schema@npm:2.0.2" + checksum: 10/ef915e3e2f34652f3d383b28a9a99cfea476fa991482370889ab14aac8ecd2b38d47cc21932526c6d949da0daf4a4a6bf629d30f41b0caca25e146819cbfa70e + languageName: node + linkType: hard + "@isaacs/cliui@npm:^8.0.2": version: 8.0.2 resolution: "@isaacs/cliui@npm:8.0.2" @@ -880,9 +1066,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.11.0" +"@rollup/rollup-android-arm-eabi@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.12.0" conditions: os=android & cpu=arm languageName: node linkType: hard @@ -894,9 +1080,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-android-arm64@npm:4.11.0" +"@rollup/rollup-android-arm64@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-android-arm64@npm:4.12.0" conditions: os=android & cpu=arm64 languageName: node linkType: hard @@ -908,9 +1094,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-darwin-arm64@npm:4.11.0" +"@rollup/rollup-darwin-arm64@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-darwin-arm64@npm:4.12.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard @@ -922,9 +1108,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-darwin-x64@npm:4.11.0" +"@rollup/rollup-darwin-x64@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-darwin-x64@npm:4.12.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard @@ -936,9 +1122,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.11.0" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.12.0" conditions: os=linux & cpu=arm languageName: node linkType: hard @@ -950,9 +1136,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.11.0" +"@rollup/rollup-linux-arm64-gnu@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.12.0" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard @@ -964,9 +1150,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.11.0" +"@rollup/rollup-linux-arm64-musl@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.12.0" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard @@ -978,16 +1164,16 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-linux-riscv64-gnu@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.11.0" +"@rollup/rollup-linux-riscv64-gnu@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.12.0" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.11.0" +"@rollup/rollup-linux-x64-gnu@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.12.0" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard @@ -999,9 +1185,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.11.0" +"@rollup/rollup-linux-x64-musl@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.12.0" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard @@ -1013,9 +1199,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.11.0" +"@rollup/rollup-win32-arm64-msvc@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.12.0" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard @@ -1027,9 +1213,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.11.0" +"@rollup/rollup-win32-ia32-msvc@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.12.0" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard @@ -1041,9 +1227,9 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.11.0": - version: 4.11.0 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.11.0" +"@rollup/rollup-win32-x64-msvc@npm:4.12.0": + version: 4.12.0 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.12.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -1065,21 +1251,21 @@ __metadata: "@ts-for-gir/generator-typescript": "workspace:^" "@ts-for-gir/lib": "workspace:^" "@types/inquirer": "npm:^9.0.7" - "@types/node": "npm:^20.11.18" + "@types/node": "npm:^20.11.20" "@types/yargs": "npm:^17.0.32" - "@typescript-eslint/eslint-plugin": "npm:^7.0.1" - "@typescript-eslint/parser": "npm:^7.0.1" + "@typescript-eslint/eslint-plugin": "npm:^7.0.2" + "@typescript-eslint/parser": "npm:^7.0.2" colorette: "npm:^2.0.20" cosmiconfig: "npm:^9.0.0" - eslint: "npm:^8.56.0" + eslint: "npm:^8.57.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-prettier: "npm:^5.1.3" - inquirer: "npm:^9.2.14" + inquirer: "npm:^9.2.15" prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" tiny-glob: "npm:^0.2.9" ts-node: "npm:^10.9.2" - typescript: "npm:5.2.2" + typescript: "npm:^5.2.2" yargs: "npm:^17.7.2" bin: ts-for-gir: ./lib/start.js @@ -1091,15 +1277,15 @@ __metadata: resolution: "@ts-for-gir/generator-base@workspace:packages/generator-base" dependencies: "@ts-for-gir/lib": "workspace:^" - "@types/node": "npm:^20.11.18" - "@typescript-eslint/eslint-plugin": "npm:^7.0.1" - "@typescript-eslint/parser": "npm:^7.0.1" - eslint: "npm:^8.56.0" + "@types/node": "npm:^20.11.20" + "@typescript-eslint/eslint-plugin": "npm:^7.0.2" + "@typescript-eslint/parser": "npm:^7.0.2" + eslint: "npm:^8.57.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-prettier: "npm:^5.1.3" prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" - typescript: "npm:5.2.2" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -1109,15 +1295,15 @@ __metadata: dependencies: "@ts-for-gir/generator-base": "workspace:^" "@ts-for-gir/lib": "workspace:^" - "@types/node": "npm:^20.11.18" - "@typescript-eslint/eslint-plugin": "npm:^7.0.1" - "@typescript-eslint/parser": "npm:^7.0.1" - eslint: "npm:^8.56.0" + "@types/node": "npm:^20.11.20" + "@typescript-eslint/eslint-plugin": "npm:^7.0.2" + "@typescript-eslint/parser": "npm:^7.0.2" + eslint: "npm:^8.57.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-prettier: "npm:^5.1.3" prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" - typescript: "npm:5.2.2" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -1127,18 +1313,18 @@ __metadata: dependencies: "@ts-for-gir/generator-base": "workspace:^" "@ts-for-gir/lib": "workspace:^" - "@types/ejs": "npm:^3.1.4" - "@types/node": "npm:^20.11.18" - "@types/xml2js": "npm:^0" - "@typescript-eslint/eslint-plugin": "npm:^7.0.1" - "@typescript-eslint/parser": "npm:^7.0.1" + "@types/ejs": "npm:^3.1.5" + "@types/node": "npm:^20.11.20" + "@types/xml2js": "npm:^0.4.14" + "@typescript-eslint/eslint-plugin": "npm:^7.0.2" + "@typescript-eslint/parser": "npm:^7.0.2" ejs: "npm:^3.1.9" - eslint: "npm:^8.56.0" + eslint: "npm:^8.57.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-prettier: "npm:^5.1.3" prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" - typescript: "npm:5.2.2" + typescript: "npm:^5.2.2" xml2js: "npm:^0.6.2" languageName: unknown linkType: soft @@ -1152,7 +1338,6 @@ __metadata: "@types/eslint": "npm:8.56.2" "@types/lodash": "npm:^4.14.202" "@types/node": "npm:^20.11.18" - "@types/xml2js": "npm:^0.4.14" "@typescript-eslint/eslint-plugin": "npm:^7.0.1" "@typescript-eslint/parser": "npm:^7.0.1" colorette: "npm:^2.0.20" @@ -1195,13 +1380,6 @@ __metadata: languageName: node linkType: hard -"@types/ejs@npm:^3.1.4": - version: 3.1.4 - resolution: "@types/ejs@npm:3.1.4" - checksum: 10/9efe68d251a5db17a5d2bd4214d79cae36fc4105bc6199cfcefcd513071e6c46711b6d122785e05589815b04c8e45bfb3688b07cabae64d9c583a1af3cae9696 - languageName: node - linkType: hard - "@types/ejs@npm:^3.1.5": version: 3.1.5 resolution: "@types/ejs@npm:3.1.5" @@ -1295,6 +1473,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.11.20": + version: 20.11.20 + resolution: "@types/node@npm:20.11.20" + dependencies: + undici-types: "npm:~5.26.4" + checksum: 10/ff449bdc94810dadb54e0f77dd587c6505ef79ffa5a208c16eb29b223365b188f4c935a3abaf0906a01d05257c3da1f72465594a841d35bcf7b6deac7a6938fb + languageName: node + linkType: hard + "@types/semver@npm:^7.5.0": version: 7.5.4 resolution: "@types/semver@npm:7.5.4" @@ -1311,7 +1498,7 @@ __metadata: languageName: node linkType: hard -"@types/xml2js@npm:^0, @types/xml2js@npm:^0.4.14": +"@types/xml2js@npm:^0.4.14": version: 0.4.14 resolution: "@types/xml2js@npm:0.4.14" dependencies: @@ -1336,31 +1523,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/eslint-plugin@npm:6.9.1" - dependencies: - "@eslint-community/regexpp": "npm:^4.5.1" - "@typescript-eslint/scope-manager": "npm:6.9.1" - "@typescript-eslint/type-utils": "npm:6.9.1" - "@typescript-eslint/utils": "npm:6.9.1" - "@typescript-eslint/visitor-keys": "npm:6.9.1" - debug: "npm:^4.3.4" - graphemer: "npm:^1.4.0" - ignore: "npm:^5.2.4" - natural-compare: "npm:^1.4.0" - semver: "npm:^7.5.4" - ts-api-utils: "npm:^1.0.1" - peerDependencies: - "@typescript-eslint/parser": ^6.0.0 || ^6.0.0-alpha - eslint: ^7.0.0 || ^8.0.0 - peerDependenciesMeta: - typescript: - optional: true - checksum: 10/10a75e072be6645edd6fd74b200f3a3ee23e2ebb04a93d8e9be70f0a34dd94572146433a0a0f2732e9667ab8bdb2037d6d4261c10474fd94cfa9c56d02546215 - languageName: node - linkType: hard - "@typescript-eslint/eslint-plugin@npm:^7.0.1": version: 7.0.1 resolution: "@typescript-eslint/eslint-plugin@npm:7.0.1" @@ -1386,21 +1548,28 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/parser@npm:^6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/parser@npm:6.9.1" +"@typescript-eslint/eslint-plugin@npm:^7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/eslint-plugin@npm:7.0.2" dependencies: - "@typescript-eslint/scope-manager": "npm:6.9.1" - "@typescript-eslint/types": "npm:6.9.1" - "@typescript-eslint/typescript-estree": "npm:6.9.1" - "@typescript-eslint/visitor-keys": "npm:6.9.1" + "@eslint-community/regexpp": "npm:^4.5.1" + "@typescript-eslint/scope-manager": "npm:7.0.2" + "@typescript-eslint/type-utils": "npm:7.0.2" + "@typescript-eslint/utils": "npm:7.0.2" + "@typescript-eslint/visitor-keys": "npm:7.0.2" debug: "npm:^4.3.4" + graphemer: "npm:^1.4.0" + ignore: "npm:^5.2.4" + natural-compare: "npm:^1.4.0" + semver: "npm:^7.5.4" + ts-api-utils: "npm:^1.0.1" peerDependencies: - eslint: ^7.0.0 || ^8.0.0 + "@typescript-eslint/parser": ^7.0.0 + eslint: ^8.56.0 peerDependenciesMeta: typescript: optional: true - checksum: 10/855a62180ad54f5a05ae4f15742e810b811aeceacd5be5a3498aeb11bd5c7877d25d4f7dc56d010a7b3ad2992e85f31d41340fb46a7fd68fc682ae65d82304d1 + checksum: 10/430b2f7ca36ee73dc75c1d677088709f3c9d5bbb4fffa3cfbe1b7d63979ee397f7a4a2a1386e05a04991500fa0ab0dd5272e8603a2b20f42e4bf590603500858 languageName: node linkType: hard @@ -1422,13 +1591,21 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/scope-manager@npm:6.9.1" +"@typescript-eslint/parser@npm:^7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/parser@npm:7.0.2" dependencies: - "@typescript-eslint/types": "npm:6.9.1" - "@typescript-eslint/visitor-keys": "npm:6.9.1" - checksum: 10/a9ca328e42fbadaeffaed807c141d71f01d471b1aeeb1abbb107a0fe630963a33aeb6e215cb26874a01bee9589e8d773ad7a7fea7b14b9710d30dd1e0d6f6820 + "@typescript-eslint/scope-manager": "npm:7.0.2" + "@typescript-eslint/types": "npm:7.0.2" + "@typescript-eslint/typescript-estree": "npm:7.0.2" + "@typescript-eslint/visitor-keys": "npm:7.0.2" + debug: "npm:^4.3.4" + peerDependencies: + eslint: ^8.56.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/18d6e1bda64013f7d66164164c57a10390f7979db55b265062ae9337e11e0921bffca10870e252cd0bd198f79ffa2e87a652e57110e5b1b4cc738453154c205c languageName: node linkType: hard @@ -1442,20 +1619,13 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/type-utils@npm:6.9.1" +"@typescript-eslint/scope-manager@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/scope-manager@npm:7.0.2" dependencies: - "@typescript-eslint/typescript-estree": "npm:6.9.1" - "@typescript-eslint/utils": "npm:6.9.1" - debug: "npm:^4.3.4" - ts-api-utils: "npm:^1.0.1" - peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - peerDependenciesMeta: - typescript: - optional: true - checksum: 10/cad9502565d9b0f203a4fa2a37f31cdde9734d050fa5324b7403d55d5125a891d0e8b6a8b2a1c0039b47b64f187219cc7fe37b905f48dee576b3b0e73f76a79c + "@typescript-eslint/types": "npm:7.0.2" + "@typescript-eslint/visitor-keys": "npm:7.0.2" + checksum: 10/773ea6e61f741777e69a469641f3db0d3c2301c0102667825fb235ed5a65c95f6d6b31b19e734b9a215acc0c7c576c65497635b8d5928eeddb58653ceb13d2d5 languageName: node linkType: hard @@ -1476,10 +1646,20 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/types@npm:6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/types@npm:6.9.1" - checksum: 10/28bf79fc9e30cafa1d747f20f95b2ce949816312bb9e1f4b0a4add6537fcf70a2b64c0da17b03c4cf70bf415263077de6edbd49ad08e482e9270454f2c61e1a3 +"@typescript-eslint/type-utils@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/type-utils@npm:7.0.2" + dependencies: + "@typescript-eslint/typescript-estree": "npm:7.0.2" + "@typescript-eslint/utils": "npm:7.0.2" + debug: "npm:^4.3.4" + ts-api-utils: "npm:^1.0.1" + peerDependencies: + eslint: ^8.56.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/63bf19c9f5bbcb0f3e127f509d85dc49be4e5e51781d78f58c96786089e7c909b25d35d0248a6a758e2f7d5b5223d2262c2d597ab71f226af6beb499ae950645 languageName: node linkType: hard @@ -1490,21 +1670,10 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/typescript-estree@npm:6.9.1" - dependencies: - "@typescript-eslint/types": "npm:6.9.1" - "@typescript-eslint/visitor-keys": "npm:6.9.1" - debug: "npm:^4.3.4" - globby: "npm:^11.1.0" - is-glob: "npm:^4.0.3" - semver: "npm:^7.5.4" - ts-api-utils: "npm:^1.0.1" - peerDependenciesMeta: - typescript: - optional: true - checksum: 10/40d1d654c3d7223c84e9340740bde95484ef246f5248cf9f6cd5ae308c79463b52c2b964f935ff68577fb0ea9d6862c9a8547e9430449e1f4eb3c53da2dbfc55 +"@typescript-eslint/types@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/types@npm:7.0.2" + checksum: 10/2cba8a0355cc7357db142fa597d02cf39e1d1cb0ec87c80e91daaa2b87f2a794d2649def9d7b2aa435691c3810d2cbd4cdc21668b19b991863f0d54d4a22da82 languageName: node linkType: hard @@ -1527,20 +1696,22 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/utils@npm:6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/utils@npm:6.9.1" +"@typescript-eslint/typescript-estree@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/typescript-estree@npm:7.0.2" dependencies: - "@eslint-community/eslint-utils": "npm:^4.4.0" - "@types/json-schema": "npm:^7.0.12" - "@types/semver": "npm:^7.5.0" - "@typescript-eslint/scope-manager": "npm:6.9.1" - "@typescript-eslint/types": "npm:6.9.1" - "@typescript-eslint/typescript-estree": "npm:6.9.1" + "@typescript-eslint/types": "npm:7.0.2" + "@typescript-eslint/visitor-keys": "npm:7.0.2" + debug: "npm:^4.3.4" + globby: "npm:^11.1.0" + is-glob: "npm:^4.0.3" + minimatch: "npm:9.0.3" semver: "npm:^7.5.4" - peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - checksum: 10/36432f0f170a81d5a6e6c8919b7d492e9be323310124e9a9d03aa64db7f32c381bc3e7f894cefc9c2b427b0a6df95613477c2a00808911a7b8e95a37fcce54a1 + ts-api-utils: "npm:^1.0.1" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/307080e29c22fc69f0ce7ab7101e1629e05f45a9e541c250e03d06b61336ab0ccb5f0a7354ee3da4e38d5cade4dd2fb7bb396cd7cbe74c2c4b3e29706a70abcc languageName: node linkType: hard @@ -1561,13 +1732,20 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:6.9.1": - version: 6.9.1 - resolution: "@typescript-eslint/visitor-keys@npm:6.9.1" +"@typescript-eslint/utils@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/utils@npm:7.0.2" dependencies: - "@typescript-eslint/types": "npm:6.9.1" - eslint-visitor-keys: "npm:^3.4.1" - checksum: 10/46d8a3335777798d43b9bf3393b96176881794184faf831670e4ee52493834cd6fbd3199ff387112ae795e344e3c92a8e78f79254d6c5bee012354859c8f333b + "@eslint-community/eslint-utils": "npm:^4.4.0" + "@types/json-schema": "npm:^7.0.12" + "@types/semver": "npm:^7.5.0" + "@typescript-eslint/scope-manager": "npm:7.0.2" + "@typescript-eslint/types": "npm:7.0.2" + "@typescript-eslint/typescript-estree": "npm:7.0.2" + semver: "npm:^7.5.4" + peerDependencies: + eslint: ^8.56.0 + checksum: 10/e68bac777419cd529371f7f29f534efaeca130c90ed9723bfc7aac451d61ca3fc4ebd310e2c015e29e8dc7be4734ae46258ca8755897d7f5e3bb502660d5372f languageName: node linkType: hard @@ -1581,6 +1759,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript-eslint/visitor-keys@npm:7.0.2" + dependencies: + "@typescript-eslint/types": "npm:7.0.2" + eslint-visitor-keys: "npm:^3.4.1" + checksum: 10/da6c1b0729af99216cde3a65d4e91584a81fc6c9dff7ba291089f01bf7262de375f58c4c4246e5fbc29f51258db7725d9c830f82ccbd1cda812fd13c51480cda + languageName: node + linkType: hard + "@ungap/structured-clone@npm:^1.2.0": version: 1.2.0 resolution: "@ungap/structured-clone@npm:1.2.0" @@ -2749,6 +2937,86 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:^0.20.1": + version: 0.20.1 + resolution: "esbuild@npm:0.20.1" + dependencies: + "@esbuild/aix-ppc64": "npm:0.20.1" + "@esbuild/android-arm": "npm:0.20.1" + "@esbuild/android-arm64": "npm:0.20.1" + "@esbuild/android-x64": "npm:0.20.1" + "@esbuild/darwin-arm64": "npm:0.20.1" + "@esbuild/darwin-x64": "npm:0.20.1" + "@esbuild/freebsd-arm64": "npm:0.20.1" + "@esbuild/freebsd-x64": "npm:0.20.1" + "@esbuild/linux-arm": "npm:0.20.1" + "@esbuild/linux-arm64": "npm:0.20.1" + "@esbuild/linux-ia32": "npm:0.20.1" + "@esbuild/linux-loong64": "npm:0.20.1" + "@esbuild/linux-mips64el": "npm:0.20.1" + "@esbuild/linux-ppc64": "npm:0.20.1" + "@esbuild/linux-riscv64": "npm:0.20.1" + "@esbuild/linux-s390x": "npm:0.20.1" + "@esbuild/linux-x64": "npm:0.20.1" + "@esbuild/netbsd-x64": "npm:0.20.1" + "@esbuild/openbsd-x64": "npm:0.20.1" + "@esbuild/sunos-x64": "npm:0.20.1" + "@esbuild/win32-arm64": "npm:0.20.1" + "@esbuild/win32-ia32": "npm:0.20.1" + "@esbuild/win32-x64": "npm:0.20.1" + dependenciesMeta: + "@esbuild/aix-ppc64": + optional: true + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 10/b672fd5df28ae917e2b16e77edbbf6b3099c390ab0a9d4cd331f78b4a4567cf33f506a055e1aa272ac90f7f522835b2173abea9bac6c38906acfda68e60a7ab7 + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -2770,7 +3038,7 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:^9.0.0, eslint-config-prettier@npm:^9.1.0": +"eslint-config-prettier@npm:^9.1.0": version: 9.1.0 resolution: "eslint-config-prettier@npm:9.1.0" peerDependencies: @@ -2781,7 +3049,7 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-prettier@npm:^5.0.1, eslint-plugin-prettier@npm:^5.1.3": +"eslint-plugin-prettier@npm:^5.1.3": version: 5.1.3 resolution: "eslint-plugin-prettier@npm:5.1.3" dependencies: @@ -2828,7 +3096,7 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.52.0, eslint@npm:^8.56.0": +"eslint@npm:^8.56.0": version: 8.56.0 resolution: "eslint@npm:8.56.0" dependencies: @@ -2876,6 +3144,54 @@ __metadata: languageName: node linkType: hard +"eslint@npm:^8.57.0": + version: 8.57.0 + resolution: "eslint@npm:8.57.0" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.2.0" + "@eslint-community/regexpp": "npm:^4.6.1" + "@eslint/eslintrc": "npm:^2.1.4" + "@eslint/js": "npm:8.57.0" + "@humanwhocodes/config-array": "npm:^0.11.14" + "@humanwhocodes/module-importer": "npm:^1.0.1" + "@nodelib/fs.walk": "npm:^1.2.8" + "@ungap/structured-clone": "npm:^1.2.0" + ajv: "npm:^6.12.4" + chalk: "npm:^4.0.0" + cross-spawn: "npm:^7.0.2" + debug: "npm:^4.3.2" + doctrine: "npm:^3.0.0" + escape-string-regexp: "npm:^4.0.0" + eslint-scope: "npm:^7.2.2" + eslint-visitor-keys: "npm:^3.4.3" + espree: "npm:^9.6.1" + esquery: "npm:^1.4.2" + esutils: "npm:^2.0.2" + fast-deep-equal: "npm:^3.1.3" + file-entry-cache: "npm:^6.0.1" + find-up: "npm:^5.0.0" + glob-parent: "npm:^6.0.2" + globals: "npm:^13.19.0" + graphemer: "npm:^1.4.0" + ignore: "npm:^5.2.0" + imurmurhash: "npm:^0.1.4" + is-glob: "npm:^4.0.0" + is-path-inside: "npm:^3.0.3" + js-yaml: "npm:^4.1.0" + json-stable-stringify-without-jsonify: "npm:^1.0.1" + levn: "npm:^0.4.1" + lodash.merge: "npm:^4.6.2" + minimatch: "npm:^3.1.2" + natural-compare: "npm:^1.4.0" + optionator: "npm:^0.9.3" + strip-ansi: "npm:^6.0.1" + text-table: "npm:^0.2.0" + bin: + eslint: bin/eslint.js + checksum: 10/00496e218b23747a7a9817bf58b522276d0dc1f2e546dceb4eea49f9871574088f72f1f069a6b560ef537efa3a75261b8ef70e51ef19033da1cc4c86a755ef15 + languageName: node + linkType: hard + "espree@npm:^9.6.0, espree@npm:^9.6.1": version: 9.6.1 resolution: "espree@npm:9.6.1" @@ -2999,14 +3315,14 @@ __metadata: languageName: node linkType: hard -"fast-xml-parser@npm:^3.17.5": - version: 3.21.1 - resolution: "fast-xml-parser@npm:3.21.1" +"fast-xml-parser@npm:^4.3.5": + version: 4.3.5 + resolution: "fast-xml-parser@npm:4.3.5" dependencies: - strnum: "npm:^1.0.4" + strnum: "npm:^1.0.5" bin: - xml2js: cli.js - checksum: 10/f9adbd8ae772473e7dec92bccfe93d3a752deec66c3d89479746ef01bfa12788bc4e5e611ec0250f69d85cc07a560e33a8d8c679673a8a69bb6e8da0234a9d40 + fxparser: src/cli/cli.js + checksum: 10/ccfd943e4ed400bf3acd4b6fcba9a15ec992a4a76c9a0cf825fc06f2b35a79a6d1de477b9a73c23633597c4f2a35838550ec3013a056f2591aa8cb3989d1f242 languageName: node linkType: hard @@ -3517,9 +3833,9 @@ __metadata: languageName: node linkType: hard -"inquirer@npm:^9.2.14": - version: 9.2.14 - resolution: "inquirer@npm:9.2.14" +"inquirer@npm:^9.2.15": + version: 9.2.15 + resolution: "inquirer@npm:9.2.15" dependencies: "@ljharb/through": "npm:^2.3.12" ansi-escapes: "npm:^4.3.2" @@ -3536,7 +3852,7 @@ __metadata: string-width: "npm:^4.2.3" strip-ansi: "npm:^6.0.1" wrap-ansi: "npm:^6.2.0" - checksum: 10/6a44a29a909031ef59a660425bfa8554138dae220f67c894bffaeb5f75e49100cd8dbfe25aa237397474e48211f1a4cc8f8f35062996d9153352f51ca11fa536 + checksum: 10/7bca66f54fc3ef511e4be4ed781ef975325ad3a3e5ebeb4d070af78bba37966068a21db53fadac89ba808f19fd2fd88149c80cf6bcfd7e7fbc358fd0127a74f9 languageName: node linkType: hard @@ -4422,7 +4738,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^3.0.3, prettier@npm:^3.2.5": +"prettier@npm:^3.2.5": version: 3.2.5 resolution: "prettier@npm:3.2.5" bin: @@ -4621,23 +4937,23 @@ __metadata: languageName: node linkType: hard -"rollup@npm:^4.11.0": - version: 4.11.0 - resolution: "rollup@npm:4.11.0" - dependencies: - "@rollup/rollup-android-arm-eabi": "npm:4.11.0" - "@rollup/rollup-android-arm64": "npm:4.11.0" - "@rollup/rollup-darwin-arm64": "npm:4.11.0" - "@rollup/rollup-darwin-x64": "npm:4.11.0" - "@rollup/rollup-linux-arm-gnueabihf": "npm:4.11.0" - "@rollup/rollup-linux-arm64-gnu": "npm:4.11.0" - "@rollup/rollup-linux-arm64-musl": "npm:4.11.0" - "@rollup/rollup-linux-riscv64-gnu": "npm:4.11.0" - "@rollup/rollup-linux-x64-gnu": "npm:4.11.0" - "@rollup/rollup-linux-x64-musl": "npm:4.11.0" - "@rollup/rollup-win32-arm64-msvc": "npm:4.11.0" - "@rollup/rollup-win32-ia32-msvc": "npm:4.11.0" - "@rollup/rollup-win32-x64-msvc": "npm:4.11.0" +"rollup@npm:^4.12.0": + version: 4.12.0 + resolution: "rollup@npm:4.12.0" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.12.0" + "@rollup/rollup-android-arm64": "npm:4.12.0" + "@rollup/rollup-darwin-arm64": "npm:4.12.0" + "@rollup/rollup-darwin-x64": "npm:4.12.0" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.12.0" + "@rollup/rollup-linux-arm64-gnu": "npm:4.12.0" + "@rollup/rollup-linux-arm64-musl": "npm:4.12.0" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.12.0" + "@rollup/rollup-linux-x64-gnu": "npm:4.12.0" + "@rollup/rollup-linux-x64-musl": "npm:4.12.0" + "@rollup/rollup-win32-arm64-msvc": "npm:4.12.0" + "@rollup/rollup-win32-ia32-msvc": "npm:4.12.0" + "@rollup/rollup-win32-x64-msvc": "npm:4.12.0" "@types/estree": "npm:1.0.5" fsevents: "npm:~2.3.2" dependenciesMeta: @@ -4671,7 +4987,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: 10/792f40ed1ec82315692d7dbe82b3253072082f1da0afd0bc983c1254666b9fdcad94d52e66a72339620fe09165708501472a41ba207d92f45e160b2864404ed2 + checksum: 10/098eac4dcaf051b71c4efb7e3df059f6563d030b4dfbd2622a4d70acf4d02c463885643c63a21dda45153470f9be5047acd11eab19d4b2ed1c06b8ff57997e8e languageName: node linkType: hard @@ -5009,7 +5325,7 @@ __metadata: languageName: node linkType: hard -"strnum@npm:^1.0.4": +"strnum@npm:^1.0.5": version: 1.0.5 resolution: "strnum@npm:1.0.5" checksum: 10/d3117975db8372d4d7b2c07601ed2f65bf21cc48d741f37a8617b76370d228f2ec26336e53791ebc3638264d23ca54e6c241f57f8c69bd4941c63c79440525ca @@ -5184,9 +5500,9 @@ __metadata: "@babel/core": "npm:^7.23.9" "@rollup/plugin-babel": "npm:^6.0.4" "@ts-for-gir/cli": "workspace:^" - rollup: "npm:^4.11.0" - typescript: "npm:5.2.2" - vite: "npm:^5.1.3" + rollup: "npm:^4.12.0" + typescript: "npm:^5.2.2" + vite: "npm:^5.1.4" languageName: unknown linkType: soft @@ -5195,8 +5511,8 @@ __metadata: resolution: "ts-for-gir-gio-2-cat-alias-example@workspace:examples/gjs/gio-2-cat-alias" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5205,8 +5521,8 @@ __metadata: resolution: "ts-for-gir-gio-2-cat-example@workspace:examples/gjs/gio-2-cat" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5215,8 +5531,8 @@ __metadata: resolution: "ts-for-gir-gio-2-cat-promisify-example@workspace:examples/gjs/gio-2-cat-promisify" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5224,8 +5540,8 @@ __metadata: version: 0.0.0-use.local resolution: "ts-for-gir-gio-2-cat-promisify-packages@workspace:examples/gjs/gio-2-cat-packages" dependencies: - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5234,8 +5550,8 @@ __metadata: resolution: "ts-for-gir-gio-2-cat-types-only-example@workspace:examples/gjs/gio-2-cat-types-only" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5244,8 +5560,8 @@ __metadata: resolution: "ts-for-gir-gio-2-dbus-example@workspace:examples/gjs/gio-2-dbus" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5254,8 +5570,8 @@ __metadata: resolution: "ts-for-gir-gio-2-list-model-example@workspace:examples/gjs/gio-2-list-model" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5264,8 +5580,8 @@ __metadata: resolution: "ts-for-gir-gjs-gtk-4-custom-widget-example@workspace:examples/gjs/gtk-4-custom-widget" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5276,8 +5592,8 @@ __metadata: "@ts-for-gir/cli": "workspace:^" fork-ts-checker-webpack-plugin: "npm:^9.0.2" ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" + typescript: "npm:^5.2.2" + webpack: "npm:^5.90.3" webpack-cli: "npm:^5.1.4" languageName: unknown linkType: soft @@ -5287,8 +5603,8 @@ __metadata: resolution: "ts-for-gir-glib-2-variant-example@workspace:examples/gjs/glib-2-variant" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5299,8 +5615,8 @@ __metadata: "@ts-for-gir/cli": "workspace:^" fork-ts-checker-webpack-plugin: "npm:^9.0.2" ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" + typescript: "npm:^5.2.2" + webpack: "npm:^5.90.3" webpack-cli: "npm:^5.1.4" languageName: unknown linkType: soft @@ -5313,8 +5629,8 @@ __metadata: fork-ts-checker-webpack-plugin: "npm:^9.0.2" raw-loader: "npm:^4.0.2" ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" + typescript: "npm:^5.2.2" + webpack: "npm:^5.90.3" webpack-cli: "npm:^5.1.4" languageName: unknown linkType: soft @@ -5324,8 +5640,8 @@ __metadata: resolution: "ts-for-gir-gtk-3-calc-example@workspace:examples/gjs/gtk-3-calc" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5336,8 +5652,8 @@ __metadata: "@ts-for-gir/cli": "workspace:^" fork-ts-checker-webpack-plugin: "npm:^9.0.2" ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" + typescript: "npm:^5.2.2" + webpack: "npm:^5.90.3" webpack-cli: "npm:^5.1.4" languageName: unknown linkType: soft @@ -5347,8 +5663,8 @@ __metadata: resolution: "ts-for-gir-gtk-3-gettext-example@workspace:examples/gjs/gtk-3-gettext" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5357,8 +5673,8 @@ __metadata: resolution: "ts-for-gir-gtk-3-hello-2-example@workspace:examples/gjs/gtk-3-hello-2" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5369,8 +5685,8 @@ __metadata: "@ts-for-gir/cli": "workspace:^" fork-ts-checker-webpack-plugin: "npm:^9.0.2" ts-loader: "npm:^9.5.1" - typescript: "npm:5.2.2" - webpack: "npm:^5.90.2" + typescript: "npm:^5.2.2" + webpack: "npm:^5.90.3" webpack-cli: "npm:^5.1.4" languageName: unknown linkType: soft @@ -5380,8 +5696,8 @@ __metadata: resolution: "ts-for-gir-gtk-3-template-example@workspace:examples/gjs/gtk-3-template" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5390,8 +5706,8 @@ __metadata: resolution: "ts-for-gir-gtk-3-webkit-example@workspace:examples/gjs/gtk-3-webkit" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5400,8 +5716,8 @@ __metadata: resolution: "ts-for-gir-gtk-4-application-example@workspace:examples/gjs/gtk-4-application" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5410,8 +5726,8 @@ __metadata: resolution: "ts-for-gir-gtk-4-list-store-example@workspace:examples/gjs/gtk-4-list-store" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5420,8 +5736,8 @@ __metadata: resolution: "ts-for-gir-gtk-4-template-example@workspace:examples/gjs/gtk-4-template" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5439,8 +5755,8 @@ __metadata: version: 0.0.0-use.local resolution: "ts-for-gir-run-async-example@workspace:examples/gjs/run-async" dependencies: - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5449,8 +5765,8 @@ __metadata: resolution: "ts-for-gir-soup-3-http-example@workspace:examples/gjs/soup-3-http" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5459,8 +5775,8 @@ __metadata: resolution: "ts-for-gir-soup-3-websocket-example@workspace:examples/gjs/soup-3-websocket" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5469,8 +5785,8 @@ __metadata: resolution: "ts-for-gir-timers-example@workspace:examples/gjs/timers" dependencies: "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" + esbuild: "npm:^0.20.1" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5479,15 +5795,15 @@ __metadata: resolution: "ts-for-gir@workspace:." dependencies: "@ts-for-gir/cli": "workspace:^" - "@typescript-eslint/eslint-plugin": "npm:^7.0.1" - "@typescript-eslint/parser": "npm:^7.0.1" + "@typescript-eslint/eslint-plugin": "npm:^7.0.2" + "@typescript-eslint/parser": "npm:^7.0.2" concurrently: "npm:^8.2.2" - eslint: "npm:^8.56.0" + eslint: "npm:^8.57.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-prettier: "npm:^5.1.3" prettier: "npm:^3.2.5" rimraf: "npm:^5.0.5" - typescript: "npm:5.2.2" + typescript: "npm:^5.2.2" languageName: unknown linkType: soft @@ -5575,17 +5891,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:5.1.3": - version: 5.1.3 - resolution: "typescript@npm:5.1.3" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 10/2d656e635d85a8354955d4f63e5835f5217b1d2b0cea7d82409e324bd7d24f68883e43208a9b250b764bbf2833d83878c05de55dbe4b8b73996b2025c6e50140 - languageName: node - linkType: hard - -"typescript@npm:5.2.2": +"typescript@npm:5.2.2, typescript@npm:^5.2.2": version: 5.2.2 resolution: "typescript@npm:5.2.2" bin: @@ -5595,17 +5901,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A5.1.3#optional!builtin": - version: 5.1.3 - resolution: "typescript@patch:typescript@npm%3A5.1.3#optional!builtin::version=5.1.3&hash=5da071" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 10/dade91ba4155d0e9eb58a83cfec0d8271fefedc87b106443c396f9961aa8b231f8585d283b126a8373897aff7823da7874ce5c0b3b18a548b51ffb474f01565e - languageName: node - linkType: hard - -"typescript@patch:typescript@npm%3A5.2.2#optional!builtin": +"typescript@patch:typescript@npm%3A5.2.2#optional!builtin, typescript@patch:typescript@npm%3A^5.2.2#optional!builtin": version: 5.2.2 resolution: "typescript@patch:typescript@npm%3A5.2.2#optional!builtin::version=5.2.2&hash=f3b441" bin: @@ -5684,9 +5980,9 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.1.3": - version: 5.1.3 - resolution: "vite@npm:5.1.3" +"vite@npm:^5.1.4": + version: 5.1.4 + resolution: "vite@npm:5.1.4" dependencies: esbuild: "npm:^0.19.3" fsevents: "npm:~2.3.3" @@ -5720,7 +6016,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10/6ba2223157e2cc2fa62dff9004ccba20fc409c6baf7354c64ed0f8e4bcd853092d08d06ec4dec37143e794a96e061879a870d85bad4f1eb9ee5c6d0a13cef30f + checksum: 10/e9003b853f0784260f4fe7ce0190124b347fd8fd6bf889a07080facd0d9a9667eaff4022eddb1ba3f0283ef69d15d77f84bca832082e48874a7a62e7f6d66b08 languageName: node linkType: hard @@ -5793,9 +6089,9 @@ __metadata: languageName: node linkType: hard -"webpack@npm:^5.90.2": - version: 5.90.2 - resolution: "webpack@npm:5.90.2" +"webpack@npm:^5.90.3": + version: 5.90.3 + resolution: "webpack@npm:5.90.3" dependencies: "@types/eslint-scope": "npm:^3.7.3" "@types/estree": "npm:^1.0.5" @@ -5826,7 +6122,7 @@ __metadata: optional: true bin: webpack: bin/webpack.js - checksum: 10/4eaeed1255c9c7738921c4ce4facdb3b78dbfcb3441496942f6d160a41fbcebd24fb2c6dbb64739b357c5ff78e5a298f6c82eca482438b95130a3ba4e16d084a + checksum: 10/48c9696eca950bfa7c943a24b8235fdf0575acd73a8eb1661f8189d3d1f431362f3a0e158e2941a7e4f0852ea6e32d7d4e89283149247e4389a8aad0fe6c247e languageName: node linkType: hard From 95c096f8d3c57feb9eb9f89a9c8ad2e9ac061bbf Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 26 Feb 2024 17:05:14 -0800 Subject: [PATCH 28/53] typescript: Fix invalid identifier names in functions and interfaces --- .../src/type-definition-generator.ts | 7 ++++++- packages/lib/src/gir.ts | 10 ++++++++++ packages/lib/src/gir/util.ts | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 2e597473a..347183a95 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -684,6 +684,11 @@ class ModuleGenerator extends FormatGenerator { } } + // TODO: Check if this is necessary anywhere else... + if (isInvalid(name) && !isGlobal) { + name = `["${name}"]` + } + const inParamsDef: string[] = this.generateInParameters(inParams) def.push( @@ -692,7 +697,7 @@ class ModuleGenerator extends FormatGenerator { )})${retSep} ${returnType}`, ) - // Add overloaded methods + // TODO: Add overloaded methods // if (overloads && tsFunction.overloads.length > 0) { // def.push(...this.addInfoComment(`Overloads of ${name}`, indentCount)) // for (const func of tsFunction.overloads) { diff --git a/packages/lib/src/gir.ts b/packages/lib/src/gir.ts index b1c0ef116..3ebe3d12c 100644 --- a/packages/lib/src/gir.ts +++ b/packages/lib/src/gir.ts @@ -3,6 +3,8 @@ import { IntrospectedProperty, IntrospectedField } from './gir/property.js' import { GenerationOptions } from './types.js' import { sanitizeIdentifierName } from './gir/util.js' +export { sanitizeMemberName, isInvalid } from './gir/util.js' + export { IntrospectedBase, Options as IntrospectedOptions, @@ -57,6 +59,14 @@ export class TypeIdentifier extends TypeExpression { return type } + /** + * TODO: gi.ts didn't deal with sanitizing types but probably should have to avoid + * invalid names such as "3gppProfile" + */ + sanitize() { + return new TypeIdentifier(sanitizeIdentifierName(this.namespace, this.name), this.namespace) + } + protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { const name: string = sanitizeIdentifierName(null, this.name) const ns_name = this.namespace diff --git a/packages/lib/src/gir/util.ts b/packages/lib/src/gir/util.ts index 04bcb0dee..0a399d717 100644 --- a/packages/lib/src/gir/util.ts +++ b/packages/lib/src/gir/util.ts @@ -412,14 +412,14 @@ export function parseTypeExpression(modName: string, type: string): TypeExpressi const baseType = parseTypeString(type); if (baseType.namespace) { - return new TypeIdentifier(baseType.name, baseType.namespace); + return new TypeIdentifier(baseType.name, baseType.namespace).sanitize(); } else { const primitiveType = resolvePrimitiveType(baseType.name); if (primitiveType !== null) { return primitiveType; } else { - return new TypeIdentifier(baseType.name, modName); + return new TypeIdentifier(baseType.name, modName).sanitize(); } } } From e41e9898d6d086d6518c809ac4d22e4941a0076e Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 26 Feb 2024 17:05:43 -0800 Subject: [PATCH 29/53] lib: Any-ify references to libraries that are not found --- packages/lib/src/validators/class.ts | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/validators/class.ts b/packages/lib/src/validators/class.ts index 9c735c318..6f7b49eb4 100644 --- a/packages/lib/src/validators/class.ts +++ b/packages/lib/src/validators/class.ts @@ -1,4 +1,4 @@ -import { NativeType, TypeIdentifier } from "../gir.js"; +import { AnyType, NativeType, TypeIdentifier } from "../gir.js"; import { IntrospectedBaseClass, IntrospectedClass, IntrospectedInterface, IntrospectedRecord } from "../gir/class.js"; import { IntrospectedError } from "../gir/enum.js"; import { @@ -139,6 +139,35 @@ const removeComplexFields = (node: T): T => { return node; }; +/** + * TODO: Consider making this transformation optional. + * + * If we are referencing an unknown library, any-ify the type. + * + * @param node + */ +const removeReferencesToMissingLibraries = (node: T): T => { + const { namespace } = node; + + node.fields = node.fields.map(f => { + const type = f.type.deepUnwrap(); + + if (type instanceof TypeIdentifier) { + // Find the type for the identifier + const nsNode = namespace.getInstalledImport(type.namespace); + + // Don't allow private or disguised fields + if (!nsNode) { + return f.copy({ type: AnyType }); + } + } + + return f; + }); + + return node; +}; + const removePrivateFields = (node: T): T => { node.fields = node.fields.filter(f => { return !f.isPrivate && !f.name.startsWith("_"); @@ -232,6 +261,7 @@ export class ClassVisitor extends GirVisitor { visitClass = (node: IntrospectedClass) => chainVisitors( node, + removeReferencesToMissingLibraries, fixMissingParent, fixParamSpecSubtypes, removeComplexFields, From 98c64585bc77a46c1779b61821e029b7d1ee0bdc Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 26 Feb 2024 17:06:59 -0800 Subject: [PATCH 30/53] lib: Fix parsing for GList and GList --- packages/lib/src/gir-module.ts | 1 - packages/lib/src/gir/util.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index a5aeb52b2..7dddd8ff2 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -824,7 +824,6 @@ export class GirModule { ?.filter(isIntrospectable) // Avoid attempting to alias non-introspectable symbols. .map((b) => { - console.debug('b', b) b.type = b.type ?.filter((t): t is NamedType => !!(t && t.$.name)) .map((t) => { diff --git a/packages/lib/src/gir/util.ts b/packages/lib/src/gir/util.ts index 0a399d717..b8d831051 100644 --- a/packages/lib/src/gir/util.ts +++ b/packages/lib/src/gir/util.ts @@ -249,7 +249,9 @@ export function getType( if (variableType instanceof TypeIdentifier) { if (variableType.is("GLib", "List") || variableType.is("GLib", "SList")) { - const listType = parameter?.type?.[0].type?.[0]?.$.name; + // TODO: $?.name was not necessary in gi.ts, but TelepathyLogger + // fails to generate now. + const listType = parameter?.type?.[0].type?.[0]?.$?.name; if (listType) { name = listType; From beba3b8b92d4f996580428e18637c1536f3e2803 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 23:22:54 -0800 Subject: [PATCH 31/53] Fix imports --- packages/lib/src/gir-module.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index 7dddd8ff2..9061d2582 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -27,8 +27,6 @@ import type { ParsedGir, GirInfoAttrs, GenerateConfig, - IntrospectedFunctionParameter, - IntrospectedClassFunction, PromisifyFunc, } from './types/index.js' import { @@ -52,6 +50,8 @@ import { IntrospectedFunction, IntrospectedCallback, IntrospectedClassCallback, + IntrospectedFunctionParameter, + IntrospectedClassFunction, } from './gir/function.js' import { NSRegistry } from './gir/registry.js' import { isPrimitiveType } from './gir/util.js' @@ -319,7 +319,7 @@ export class GirModule { } } } - + overloadPromisifiedFunctions(girFunctions: GirFunctionElement[]): void { if (!this.config.promisify) return @@ -632,10 +632,9 @@ export class GirModule { (m): m is IntrospectedBaseClass => m instanceof IntrospectedBaseClass, ) const res = clazzes - .map<[IntrospectedBaseClass, IntrospectedClassCallback | undefined]>((m) => [ - m, - m.callbacks.find((c) => c.name === name || c.resolve_names.includes(name)), - ]) + .map< + [IntrospectedBaseClass, IntrospectedClassCallback | undefined] + >((m) => [m, m.callbacks.find((c) => c.name === name || c.resolve_names.includes(name))]) .find((r): r is [IntrospectedBaseClass, IntrospectedClassCallback] => r[1] != null) if (res) { From 7e670a70d4b8dd440ba71bc70eb3e04838618b56 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 5 Mar 2024 23:52:04 -0800 Subject: [PATCH 32/53] temp: add sub --- types | 1 + 1 file changed, 1 insertion(+) create mode 160000 types diff --git a/types b/types new file mode 160000 index 000000000..1ab7cda8f --- /dev/null +++ b/types @@ -0,0 +1 @@ +Subproject commit 1ab7cda8f28553db0479a3206f71871da027ce4e From 5c5475cf9decb885abe263c085989809d3781b33 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Sun, 10 Mar 2024 21:54:59 -0700 Subject: [PATCH 33/53] lib: Unify dependency manager and registry and fix example builds --- .../gjs/glib-2-spawn-command/package.json | 2 +- examples/gjs/gtk-3-builder/package.json | 2 +- examples/gjs/gtk-3-editor/package.json | 2 +- examples/gjs/gtk-3-hello/package.json | 2 +- examples/gjs/timers/package.json | 2 +- package.json | 3 +-- packages/cli/src/commands/doc.ts | 2 +- packages/cli/src/commands/generate.ts | 7 +++--- packages/cli/src/module-loader.ts | 22 ++++++++++++++++--- .../src/type-definition-generator.ts | 4 ++-- .../templates/package.json | 1 + packages/lib/src/dependency-manager.ts | 5 +++-- types | 1 - 13 files changed, 36 insertions(+), 19 deletions(-) delete mode 160000 types diff --git a/examples/gjs/glib-2-spawn-command/package.json b/examples/gjs/glib-2-spawn-command/package.json index 8d879b84b..32fc938e1 100644 --- a/examples/gjs/glib-2-spawn-command/package.json +++ b/examples/gjs/glib-2-spawn-command/package.json @@ -10,7 +10,7 @@ "watch": "yarn build:app --watch", "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate GLib-2.0 --noNamespace -t cjs", + "build:types": "yarn ts-for-gir generate GLib-2.0 --noNamespace", "clear:types": "rm -rf ./@types", "clear:ts": "rm -rf ./dist", "clear": "yarn clear:ts && yarn clear:types", diff --git a/examples/gjs/gtk-3-builder/package.json b/examples/gjs/gtk-3-builder/package.json index ff8a8cd99..f0a754749 100644 --- a/examples/gjs/gtk-3-builder/package.json +++ b/examples/gjs/gtk-3-builder/package.json @@ -10,7 +10,7 @@ "watch": "yarn build:app --watch", "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 -e gjs --noNamespace -t cjs", + "build:types": "yarn ts-for-gir generate Gtk-3.0 --noNamespace", "clear:types": "rm -rf ./@types", "clear:ts": "rm -rf ./dist", "clear": "yarn clear:ts && yarn clear:types", diff --git a/examples/gjs/gtk-3-editor/package.json b/examples/gjs/gtk-3-editor/package.json index 2031a3005..2a0961211 100644 --- a/examples/gjs/gtk-3-editor/package.json +++ b/examples/gjs/gtk-3-editor/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:app && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 -e gjs --noNamespace -t cjs", + "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace", "clear:types": "rm -rf ./@types", "clear:app": "rm -rf ./dist", "clear": "yarn clear:app && yarn clear:types", diff --git a/examples/gjs/gtk-3-hello/package.json b/examples/gjs/gtk-3-hello/package.json index cca15c9dc..48e2d2a9f 100644 --- a/examples/gjs/gtk-3-hello/package.json +++ b/examples/gjs/gtk-3-hello/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:app && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 -e gjs --noNamespace -t cjs", + "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace", "clear:types": "rm -rf ./@types", "clear:app": "rm -rf ./dist", "clear": "yarn clear:app && yarn clear:types", diff --git a/examples/gjs/timers/package.json b/examples/gjs/timers/package.json index 777a4d6e8..6cc30535f 100644 --- a/examples/gjs/timers/package.json +++ b/examples/gjs/timers/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 -e gjs --noNamespace -t cjs", + "build:types": "yarn ts-for-gir generate Gtk-4.0 --noNamespace", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs dist/main.js", diff --git a/package.json b/package.json index 1051c57b0..076cb336b 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,7 @@ }, "workspaces": [ "examples/*/*", - "packages/*", - "types/*" + "packages/*" ], "packageManager": "yarn@4.1.0" } diff --git a/packages/cli/src/commands/doc.ts b/packages/cli/src/commands/doc.ts index 8e84a18bf..c8cddb38b 100644 --- a/packages/cli/src/commands/doc.ts +++ b/packages/cli/src/commands/doc.ts @@ -39,7 +39,7 @@ const handler = async (args: ConfigFlags) => { return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) } const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC) - const registry = moduleLoader.dependencyManager.registry + const registry = moduleLoader.dependencyManager await tsForGir.start( Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module), diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index 3c073c4c9..936c147c6 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -37,16 +37,17 @@ const handler = async (args: ConfigFlags) => { config.ignore || [], config.ignoreVersionConflicts, ) + if (keep.length === 0) { return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories)) } + const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES) const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module) - // const girModulesGrouped = Object.values(grouped) - moduleLoader.dependencyManager.registry.registerFormatter('dts', new TypeScriptFormatter()) - await tsForGir.start(girModules, moduleLoader.dependencyManager.registry) + moduleLoader.dependencyManager.registerFormatter('dts', new TypeScriptFormatter()) + await tsForGir.start(girModules, moduleLoader.dependencyManager) } const examples: ReadonlyArray<[string, string?]> = [ diff --git a/packages/cli/src/module-loader.ts b/packages/cli/src/module-loader.ts index c0ab1a04d..4bbfe2e8b 100644 --- a/packages/cli/src/module-loader.ts +++ b/packages/cli/src/module-loader.ts @@ -386,7 +386,7 @@ export class ModuleLoader { this.log.log(`Parsing ${dependency.path}...`) const fileContents = await readFile(dependency.path, 'utf8') const result = parser.parseGir(fileContents) - const girModule = GirModule.load(result, this.config, this.dependencyManager.registry) + const girModule = GirModule.load(result, this.config, this.dependencyManager) // Figure out transitive module dependencies this.extendDependencyMapByGirModule(girModule) return girModule @@ -548,9 +548,25 @@ export class ModuleLoader { ignore: string[] = [], doNotAskForVersionOnConflict = true, ): Promise<{ keep: GirModuleResolvedBy[]; grouped: GirModulesGroupedMap; ignore: string[]; failed: Set }> { - const foundPackageNames = await this.findPackageNames(packageNames, ignore) + const foundPackageNames = await this.findPackageNames([...packageNames], ignore) + // Always require these because GJS does... + const GLib = this.dependencyManager.get('GLib', '2.0') + const Gio = this.dependencyManager.get('Gio', '2.0') + const GObject = this.dependencyManager.get('GObject', '2.0') + const dependencies = this.packageNamesToDependencies(foundPackageNames) - const { loaded, failed } = await this.loadGirModules(dependencies, ignore) + + const { loaded, failed } = await this.loadGirModules( + [ + GLib, + Gio, + GObject, + ...dependencies.filter( + (dep) => dep.namespace !== 'GLib' && dep.namespace !== 'Gio' && dep.namespace !== 'GObject', + ), + ], + ignore, + ) let keep: GirModuleResolvedBy[] = [] if (doNotAskForVersionOnConflict) { keep = loaded diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 347183a95..f0ff356ed 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -115,7 +115,7 @@ class ModuleGenerator extends FormatGenerator { importName: girModule.importName, girModule, pkgData, - registry: this.dependencyManager.registry, + registry: this.dependencyManager, }, girModule.packageName, girModule.transitiveDependencies, @@ -1336,7 +1336,7 @@ class ModuleGenerator extends FormatGenerator { const target = `${girModule.importName}.d.ts` - const formatter = this.dependencyManager.registry.getFormatter('dts') + const formatter = this.dependencyManager.getFormatter('dts') let contents!: string try { diff --git a/packages/generator-typescript/templates/package.json b/packages/generator-typescript/templates/package.json index 2b70a7bf6..55fd1b4d8 100644 --- a/packages/generator-typescript/templates/package.json +++ b/packages/generator-typescript/templates/package.json @@ -39,6 +39,7 @@ _%> "default": "./cairo.js" }, <%_ } _%> + <%_ if (entryPointName === 'gjs') { _%> "./ambient": { "types": "./ambient.d.ts", "default": "./ambient.js" diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index d0695b395..029be6218 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -6,16 +6,17 @@ import type { Dependency, GenerateConfig, GirInclude } from './types/index.js' import type { GirModule } from './gir-module.js' import { GirNSRegistry } from './registry.js' -export class DependencyManager { +export class DependencyManager extends GirNSRegistry { protected log: Logger protected transformation: Transformation - registry = new GirNSRegistry() cache: { [packageName: string]: Dependency } = {} static instance?: DependencyManager protected constructor(protected readonly config: GenerateConfig) { + super() + this.transformation = new Transformation(config) this.log = new Logger(config.verbose, 'DependencyManager') } diff --git a/types b/types deleted file mode 160000 index 1ab7cda8f..000000000 --- a/types +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1ab7cda8f28553db0479a3206f71871da027ce4e From 6fb04f997ddfced46454614ea60d6f81b4f1437a Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Tue, 27 Feb 2024 18:18:19 +0100 Subject: [PATCH 34/53] workspace: Fix clear command --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 076cb336b..dd4bb3c70 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", "clear:types:local": "rimraf ./@types", - "clear:examples": "yarn workspaces foreach -v --all --exclude @ts-for-gir/cli,@ts-for-gir/lib,@ts-for-gir/generator-base,@ts-for-gir/generator-typescript,@ts-for-gir/generator-html-doc --parallel run clear", - "clear:all": "yarn build && yarn clear:examples", + "clear:examples": "yarn workspaces foreach -v --all --exclude @ts-for-gir/cli,@ts-for-gir/lib,@ts-for-gir/generator-base,@ts-for-gir/generator-typescript,@ts-for-gir/generator-html-doc,@gi.ts/parser --parallel run clear", + "clear:all": "yarn clear && yarn clear:examples", "watch": "concurrently 'yarn:watch:*'", "watch:cli": "yarn workspace @ts-for-gir/cli run watch", "watch:lib": "yarn workspace @ts-for-gir/lib run watch", From 1428648c36d6c970e716aeaa6e25ceb76ccf6253 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 11 Mar 2024 01:16:51 -0700 Subject: [PATCH 35/53] examples: Remove dependency on types submodule --- examples/gjs/adw-1-hello/main.ts | 10 ++--- examples/gjs/gio-2-cat-packages/.gitignore | 18 -------- examples/gjs/gio-2-cat-packages/esbuild.js | 15 ------- examples/gjs/gio-2-cat-packages/main.ts | 33 -------------- examples/gjs/gio-2-cat-packages/package.json | 25 ----------- examples/gjs/gio-2-cat-packages/tsconfig.json | 14 ------ .../gio-2-cat-packages/tsconfig.types.json | 6 --- examples/gjs/gio-2-cat/main.ts | 8 ++-- examples/gjs/run-async/.ts-for-girrc.json | 6 +++ .../gjs/run-async/@types/gio-2.0/package.json | 44 +++++++++++++++++++ .../run-async/@types/glib-2.0/package.json | 44 +++++++++++++++++++ .../run-async/@types/gobject-2.0/package.json | 44 +++++++++++++++++++ examples/gjs/run-async/main.ts | 10 ++--- examples/gjs/run-async/package.json | 4 +- examples/gjs/run-async/tsconfig.json | 10 ++++- yarn.lock | 10 +---- 16 files changed, 163 insertions(+), 138 deletions(-) delete mode 100644 examples/gjs/gio-2-cat-packages/.gitignore delete mode 100644 examples/gjs/gio-2-cat-packages/esbuild.js delete mode 100644 examples/gjs/gio-2-cat-packages/main.ts delete mode 100644 examples/gjs/gio-2-cat-packages/package.json delete mode 100644 examples/gjs/gio-2-cat-packages/tsconfig.json delete mode 100644 examples/gjs/gio-2-cat-packages/tsconfig.types.json create mode 100644 examples/gjs/run-async/.ts-for-girrc.json create mode 100644 examples/gjs/run-async/@types/gio-2.0/package.json create mode 100644 examples/gjs/run-async/@types/glib-2.0/package.json create mode 100644 examples/gjs/run-async/@types/gobject-2.0/package.json diff --git a/examples/gjs/adw-1-hello/main.ts b/examples/gjs/adw-1-hello/main.ts index e76e53433..536273f1c 100644 --- a/examples/gjs/adw-1-hello/main.ts +++ b/examples/gjs/adw-1-hello/main.ts @@ -3,11 +3,11 @@ * @see https://gitlab.gnome.org/GNOME/libadwaita/-/blob/main/examples/hello-world/hello.c */ -import imports from './@types/gjs.js' -import Gio from './@types/gio-2.0.js'; -import GLib from './@types/glib-2.0.js'; -import Gtk from './@types/gtk-4.0.js'; -import Adw from './@types/adw-1.js'; +import './@types/gjs/gjs'; +import Gio from './@types/gio-2.0/gio-2.0'; +import GLib from './@types/glib-2.0/glib-2.0'; +import Gtk from './@types/gtk-4.0/gtk-4.0'; +import Adw from './@types/adw-1/adw-1'; const loop = GLib.MainLoop.new(null, false) diff --git a/examples/gjs/gio-2-cat-packages/.gitignore b/examples/gjs/gio-2-cat-packages/.gitignore deleted file mode 100644 index 1345bf22e..000000000 --- a/examples/gjs/gio-2-cat-packages/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Yarn https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions - -!@types/ -@types/gio-2.0/* -!@types/gio-2.0/package.json -@types/gjs/* -!@types/gjs/package.json -@types/glib-2.0/* -!@types/glib-2.0/package.json -@types/gobject-2.0/* -!@types/gobject-2.0/package.json \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-packages/esbuild.js b/examples/gjs/gio-2-cat-packages/esbuild.js deleted file mode 100644 index 5d596dfe6..000000000 --- a/examples/gjs/gio-2-cat-packages/esbuild.js +++ /dev/null @@ -1,15 +0,0 @@ -import { build } from "esbuild"; - -await build({ - entryPoints: ['main.ts'], - outdir: 'dist', - bundle: true, - // target: "firefox60", // Since GJS 1.53.90 - // target: "firefox68", // Since GJS 1.63.90 - // target: "firefox78", // Since GJS 1.65.90 - target: "firefox91", // Since GJS 1.71.1 - // target: firefox102 // Since GJS 1.73.2 - format: 'esm', - // platform: 'node', - external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], -}) \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-packages/main.ts b/examples/gjs/gio-2-cat-packages/main.ts deleted file mode 100644 index 43d8d3ad2..000000000 --- a/examples/gjs/gio-2-cat-packages/main.ts +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later -// SPDX-FileCopyrightText: 2009 Red Hat, Inc. -// Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gio-cat.js - -/* - * Make sure you have a non english locale installed, for example fr_FR and run - * LANGUAGE=fr_FR gjs gettext.js - * the label should show a translation of 'Print help' - */ - -import '@girs/gjs'; -import '@girs/gjs/dom'; -import '@girs/gio-2.0'; - -import Gio from "gi://Gio?version=2.0"; - -const textDecoder = new TextDecoder() - -Gio._promisify(Gio.File.prototype, 'load_contents_async', 'load_contents_finish'); - -async function cat(filename: string) { - const file = Gio.file_new_for_path(filename); - - const [contents] = await file.load_contents_async(null); - - print(textDecoder.decode(contents)); -} - -if (ARGV.length !== 1) - printerr('Usage: gio-cat.js filename'); -else { - await cat(ARGV[0]); -} \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-packages/package.json b/examples/gjs/gio-2-cat-packages/package.json deleted file mode 100644 index d9cf0679b..000000000 --- a/examples/gjs/gio-2-cat-packages/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "ts-for-gir-gio-2-cat-promisify-packages", - "version": "3.2.8", - "description": "Simple GJS Gtk 3 example app that shows how you can translate strings with gettext", - "main": "index.js", - "type": "module", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build:app": "yarn node esbuild.js", - "build": "yarn build:app", - "start:app": "gjs -m dist/main.js main.ts", - "debug:app": "GTK_DEBUG=interactive yarn start:app", - "start": "yarn clear && yarn build && yarn start:app", - "validate": "yarn validate:app", - "validate:app": "tsc --noEmit", - "clear": "rm -rf dist @types" - }, - "author": "Pascal Garber ", - "license": "MIT", - "devDependencies": { - "esbuild": "^0.20.1", - "typescript": "^5.2.2" - } -} diff --git a/examples/gjs/gio-2-cat-packages/tsconfig.json b/examples/gjs/gio-2-cat-packages/tsconfig.json deleted file mode 100644 index 22851e93f..000000000 --- a/examples/gjs/gio-2-cat-packages/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "lib": ["ESNext"], - "types": [], - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "node" - }, - "include": ["@girs/gjs", "@girs/gjs/dom", "@girs/gjs/ambient"], - "files": [ - "main.ts", - ] -} diff --git a/examples/gjs/gio-2-cat-packages/tsconfig.types.json b/examples/gjs/gio-2-cat-packages/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/gjs/gio-2-cat-packages/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/examples/gjs/gio-2-cat/main.ts b/examples/gjs/gio-2-cat/main.ts index 55145cea8..0ae82f9ab 100644 --- a/examples/gjs/gio-2-cat/main.ts +++ b/examples/gjs/gio-2-cat/main.ts @@ -8,10 +8,10 @@ * the label should show a translation of 'Print help' */ -import './@types/gjs.js'; -import './@types/dom.js'; -import GLib from './@types/glib-2.0.js'; -import Gio from './@types/gio-2.0.js'; +import './@types/gjs/gjs'; +import './@types/gjs/dom'; +import GLib from './@types/glib-2.0/glib-2.0'; +import Gio from './@types/gio-2.0/gio-2.0'; const loop = GLib.MainLoop.new(null, false); const textDecoder = new TextDecoder() diff --git a/examples/gjs/run-async/.ts-for-girrc.json b/examples/gjs/run-async/.ts-for-girrc.json new file mode 100644 index 000000000..21688bbbd --- /dev/null +++ b/examples/gjs/run-async/.ts-for-girrc.json @@ -0,0 +1,6 @@ +{ + "modules": ["Gio-2.0"], + "noNamespace": false, + "outdir": "./@types", + "generateAlias": true +} \ No newline at end of file diff --git a/examples/gjs/run-async/@types/gio-2.0/package.json b/examples/gjs/run-async/@types/gio-2.0/package.json new file mode 100644 index 000000000..9d3829af1 --- /dev/null +++ b/examples/gjs/run-async/@types/gio-2.0/package.json @@ -0,0 +1,44 @@ +{ + "name": "@girs/gio-2.0", + "version": "2.78.0-4.0.0", + "description": "GJS TypeScript type definitions for Gio-2.0, generated from library version 2.78.0", + "type": "module", + "module": "gio-2.0.js", + "main": "gio-2.0.js", + "exports": { + "./ambient": { + "types": "./gio-2.0-ambient.d.ts", + "default": "./gio-2.0-ambient.js" + }, + "./import": { + "types": "./gio-2.0-import.d.ts", + "default": "./gio-2.0-import.js" + }, + ".": { + "types": "./gio-2.0.d.ts", + "default": "./gio-2.0.js" + } + }, + "scripts": { + "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gio-2.0.d.ts" + }, + "dependencies": { + "@girs/gjs": "4.0.0", "@girs/gobject-2.0": "*", "@girs/glib-2.0": "*" + }, + "devDependencies": { + "typescript": "*" + }, + "keywords": ["Gir", "TypeScript", "types", "GObject-Introspection", "GJS", "Gio-2.0"], + "author": "ts-for-gir", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/gjsify/ts-for-gir.git" + }, + "bugs": { + "url": "https://github.com/gjsify/ts-for-gir/issues" + }, + "homepage": "https://github.com/gjsify/types/tree/main/gio-2.0#readme" +} + + diff --git a/examples/gjs/run-async/@types/glib-2.0/package.json b/examples/gjs/run-async/@types/glib-2.0/package.json new file mode 100644 index 000000000..557547023 --- /dev/null +++ b/examples/gjs/run-async/@types/glib-2.0/package.json @@ -0,0 +1,44 @@ +{ + "name": "@girs/glib-2.0", + "version": "2.78.0-4.0.0", + "description": "GJS TypeScript type definitions for GLib-2.0, generated from library version 2.78.0", + "type": "module", + "module": "glib-2.0.js", + "main": "glib-2.0.js", + "exports": { + "./ambient": { + "types": "./glib-2.0-ambient.d.ts", + "default": "./glib-2.0-ambient.js" + }, + "./import": { + "types": "./glib-2.0-import.d.ts", + "default": "./glib-2.0-import.js" + }, + ".": { + "types": "./glib-2.0.d.ts", + "default": "./glib-2.0.js" + } + }, + "scripts": { + "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit glib-2.0.d.ts" + }, + "dependencies": { + "@girs/gjs": "4.0.0", "@girs/gobject-2.0": "*" + }, + "devDependencies": { + "typescript": "*" + }, + "keywords": ["Gir", "TypeScript", "types", "GObject-Introspection", "GJS", "GLib-2.0"], + "author": "ts-for-gir", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/gjsify/ts-for-gir.git" + }, + "bugs": { + "url": "https://github.com/gjsify/ts-for-gir/issues" + }, + "homepage": "https://github.com/gjsify/types/tree/main/glib-2.0#readme" +} + + diff --git a/examples/gjs/run-async/@types/gobject-2.0/package.json b/examples/gjs/run-async/@types/gobject-2.0/package.json new file mode 100644 index 000000000..2db9df9c1 --- /dev/null +++ b/examples/gjs/run-async/@types/gobject-2.0/package.json @@ -0,0 +1,44 @@ +{ + "name": "@girs/gobject-2.0", + "version": "2.78.0-4.0.0", + "description": "GJS TypeScript type definitions for GObject-2.0, generated from library version 2.78.0", + "type": "module", + "module": "gobject-2.0.js", + "main": "gobject-2.0.js", + "exports": { + "./ambient": { + "types": "./gobject-2.0-ambient.d.ts", + "default": "./gobject-2.0-ambient.js" + }, + "./import": { + "types": "./gobject-2.0-import.d.ts", + "default": "./gobject-2.0-import.js" + }, + ".": { + "types": "./gobject-2.0.d.ts", + "default": "./gobject-2.0.js" + } + }, + "scripts": { + "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gobject-2.0.d.ts" + }, + "dependencies": { + "@girs/gjs": "4.0.0", "@girs/glib-2.0": "*" + }, + "devDependencies": { + "typescript": "*" + }, + "keywords": ["Gir", "TypeScript", "types", "GObject-Introspection", "GJS", "GObject-2.0"], + "author": "ts-for-gir", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/gjsify/ts-for-gir.git" + }, + "bugs": { + "url": "https://github.com/gjsify/ts-for-gir/issues" + }, + "homepage": "https://github.com/gjsify/types/tree/main/gobject-2.0#readme" +} + + diff --git a/examples/gjs/run-async/main.ts b/examples/gjs/run-async/main.ts index 9c83b3512..77b1c9132 100644 --- a/examples/gjs/run-async/main.ts +++ b/examples/gjs/run-async/main.ts @@ -8,11 +8,9 @@ * the label should show a translation of 'Print help' */ -import '@girs/gjs'; -import '@girs/gjs/dom'; -import '@girs/gio-2.0'; -import '@girs/gtk-4.0'; -import '@girs/adw-1'; +import './@types/gjs/gjs'; +import './@types/gjs/dom'; +import './@types/gio-2.0'; // import Adw from "gi://Adw"; // import GLib from "gi://GLib"; @@ -29,7 +27,7 @@ import Gio from "gi://Gio"; const gioApp = new Gio.Application(); gioApp.runAsync(ARGV).then((exitStatus: number) => { log(`Exited with status: ${exitStatus}`); -}).catch((error) => { +}).catch((error: unknown) => { logError(error); }); diff --git a/examples/gjs/run-async/package.json b/examples/gjs/run-async/package.json index 58836dffc..c88375965 100644 --- a/examples/gjs/run-async/package.json +++ b/examples/gjs/run-async/package.json @@ -8,7 +8,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build:app": "yarn node esbuild.js", - "build": "yarn build:app", + "build:types": "yarn ts-for-gir generate --configName=.ts-for-girrc.json", + "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js main.ts", "debug:app": "GTK_DEBUG=interactive yarn start:app", "start": "yarn clear && yarn build && yarn start:app", @@ -19,6 +20,7 @@ "author": "Pascal Garber ", "license": "MIT", "devDependencies": { + "@ts-for-gir/cli": "workspace:^", "esbuild": "^0.20.1", "typescript": "^5.2.2" } diff --git a/examples/gjs/run-async/tsconfig.json b/examples/gjs/run-async/tsconfig.json index 5cc523f87..8c0958ff2 100644 --- a/examples/gjs/run-async/tsconfig.json +++ b/examples/gjs/run-async/tsconfig.json @@ -1,13 +1,19 @@ { + "extends": "./tsconfig.alias.json", "compilerOptions": { "baseUrl": ".", "lib": ["ESNext"], "types": [], "target": "ESNext", "module": "ESNext", - "moduleResolution": "node" + "moduleResolution": "node", + "noImplicitAny": true, + "paths": { + // Simulate the node_modules packaging... + "@girs/*": ["./@types/*"] + } }, - "include": ["@girs/gjs", "@girs/gjs/ambient"], + "include": ["./@types"], "files": [ "main.ts", ] diff --git a/yarn.lock b/yarn.lock index e5133da88..ae2f3c6d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5536,15 +5536,6 @@ __metadata: languageName: unknown linkType: soft -"ts-for-gir-gio-2-cat-promisify-packages@workspace:examples/gjs/gio-2-cat-packages": - version: 0.0.0-use.local - resolution: "ts-for-gir-gio-2-cat-promisify-packages@workspace:examples/gjs/gio-2-cat-packages" - dependencies: - esbuild: "npm:^0.20.1" - typescript: "npm:^5.2.2" - languageName: unknown - linkType: soft - "ts-for-gir-gio-2-cat-types-only-example@workspace:examples/gjs/gio-2-cat-types-only": version: 0.0.0-use.local resolution: "ts-for-gir-gio-2-cat-types-only-example@workspace:examples/gjs/gio-2-cat-types-only" @@ -5755,6 +5746,7 @@ __metadata: version: 0.0.0-use.local resolution: "ts-for-gir-run-async-example@workspace:examples/gjs/run-async" dependencies: + "@ts-for-gir/cli": "workspace:^" esbuild: "npm:^0.20.1" typescript: "npm:^5.2.2" languageName: unknown From 9036566a5ee7c811d158394834dd58a82e5ec927 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 11 Mar 2024 01:17:45 -0700 Subject: [PATCH 36/53] lib: Merge injection sources from gi.ts and ts-for-gir --- .../src/injection/callbacks/gjs/Gio-2.0.ts | 37 - .../lib/src/injection/callbacks/gjs/index.ts | 5 - packages/lib/src/injection/callbacks/index.ts | 5 - .../lib/src/injection/classes/gjs/gio-2.0.ts | 256 ------- .../lib/src/injection/classes/gjs/glib-2.0.ts | 227 ------- .../src/injection/classes/gjs/gobject-2.0.ts | 635 ------------------ .../lib/src/injection/classes/gjs/index.ts | 7 - .../lib/src/injection/classes/glib-2.0.ts | 36 - packages/lib/src/injection/classes/index.ts | 6 - packages/lib/src/injection/index.ts | 3 - packages/lib/src/injection/injector.ts | 183 ----- packages/lib/src/injections/gio.ts | 112 ++- packages/lib/src/injections/glib.ts | 15 + packages/lib/src/injections/gobject.ts | 77 ++- 14 files changed, 168 insertions(+), 1436 deletions(-) delete mode 100644 packages/lib/src/injection/callbacks/gjs/Gio-2.0.ts delete mode 100644 packages/lib/src/injection/callbacks/gjs/index.ts delete mode 100644 packages/lib/src/injection/callbacks/index.ts delete mode 100644 packages/lib/src/injection/classes/gjs/gio-2.0.ts delete mode 100644 packages/lib/src/injection/classes/gjs/glib-2.0.ts delete mode 100644 packages/lib/src/injection/classes/gjs/gobject-2.0.ts delete mode 100644 packages/lib/src/injection/classes/gjs/index.ts delete mode 100644 packages/lib/src/injection/classes/glib-2.0.ts delete mode 100644 packages/lib/src/injection/classes/index.ts delete mode 100644 packages/lib/src/injection/index.ts delete mode 100644 packages/lib/src/injection/injector.ts diff --git a/packages/lib/src/injection/callbacks/gjs/Gio-2.0.ts b/packages/lib/src/injection/callbacks/gjs/Gio-2.0.ts deleted file mode 100644 index 07c8b9682..000000000 --- a/packages/lib/src/injection/callbacks/gjs/Gio-2.0.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { InjectionCallback } from '../../../types/index.js' - -export const callbacksGio20Gjs: InjectionCallback[] = [ - { - versions: ['2.0'], - namespace: 'Gio', - name: 'AsyncReadyCallback', - // Generics for callback parameters - // TODO only use `this` if there is also a _finish method - generics: [ - { - name: 'T', - value: 'this', - }, - ], - inParams: [ - // Type changed - { - name: 'source_object', - type: [{ type: 'T' }], - }, - // Not changed - { - name: 'res', - type: [{ type: 'Gio.AsyncResult' }], - }, - ], - tsCallbackInterface: { - generics: [ - { - name: 'T', - value: 'GObject.Object', - }, - ], - }, - }, -] diff --git a/packages/lib/src/injection/callbacks/gjs/index.ts b/packages/lib/src/injection/callbacks/gjs/index.ts deleted file mode 100644 index 012fc40ca..000000000 --- a/packages/lib/src/injection/callbacks/gjs/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { InjectionCallback } from '../../../types/index.js' - -import { callbacksGio20Gjs } from './Gio-2.0.js' - -export const callbacksGjs: InjectionCallback[] = [...callbacksGio20Gjs] diff --git a/packages/lib/src/injection/callbacks/index.ts b/packages/lib/src/injection/callbacks/index.ts deleted file mode 100644 index fd22c6a75..000000000 --- a/packages/lib/src/injection/callbacks/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { InjectionCallback } from '../../types/index.js' - -export { callbacksGjs } from './gjs/index.js' - -export const callbacksAll: InjectionCallback[] = [] diff --git a/packages/lib/src/injection/classes/gjs/gio-2.0.ts b/packages/lib/src/injection/classes/gjs/gio-2.0.ts deleted file mode 100644 index 5062621f4..000000000 --- a/packages/lib/src/injection/classes/gjs/gio-2.0.ts +++ /dev/null @@ -1,256 +0,0 @@ -import type { InjectionClass, InjectionFunction } from '../../../types/index.js' - -// See https://github.com/gjsify/ts-for-gir/issues/130 -const runAsyncMethod: InjectionFunction = { - name: 'runAsync', - girTypeName: 'method', - inParams: [ - { - name: 'argv', - type: [{ type: 'string', isArray: true, optional: true }], - }, - ], - returnTypes: [ - { - type: 'Promise', - }, - ], - doc: { - text: "Similar to `Gio.Application.run` but return a Promise which resolves when the main loop ends, instead of blocking while the main loop runs.\nThis helps avoid the situation where Promises never resolved if you didn't run the application inside a callback.", - tags: [ - { - tagName: 'param', - paramName: 'argv', - text: 'Commandline arguments.', - }, - { - tagName: 'returns', - paramName: '', - text: 'The exit status of the application.', - }, - ], - }, -} - -/** - * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/overrides/Gio.js - */ -export const classesGio20Gjs: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'Gio.Application', - methods: [runAsyncMethod], - }, - { - versions: ['2.0'], - qualifiedName: 'Gio.DBusProxy', - staticFunctions: [ - { - name: 'makeProxyWrapper', - girTypeName: 'static-function', - isStatic: true, - generics: [ - { - name: 'T', - }, - ], - returnTypes: [ - { - type: '(bus: DBusConnection, name: string, object: string, asyncCallback?: (initable: (T & DBusProxy) | null, error: unknown | null) => void, cancellable?: Cancellable | null, flags?: DBusProxyFlags) => T & DBusProxy', - }, - ], - inParams: [ - { - name: 'interfaceXml', - type: [{ type: 'string' }], - }, - ], - }, - ], - methods: [ - { - name: 'connectSignal', - girTypeName: 'method', - returnTypes: [{ type: 'number' }], - generics: [ - { - name: 'T', - value: 'any[]', - }, - ], - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'callback', - type: [{ type: '(proxy: DBusProxy, name: string, args: T) => boolean | void' }], - }, - ], - }, - { - name: 'disconnectSignal', - girTypeName: 'method', - returnTypes: [{ type: 'void' }], - inParams: [ - { - name: 'id', - type: [{ type: 'number' }], - }, - ], - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'Gio.DBusConnection', - methods: [ - { - name: 'watch_name', - girTypeName: 'method', - returnTypes: [{ type: 'number' }], - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'Gio.BusNameWatcherFlags' }], - }, - { - name: 'name_appeared_closure', - type: [{ type: 'GObject.TClosure', nullable: true }], - }, - { - name: 'name_vanished_closure', - type: [{ type: 'GObject.TClosure', nullable: true }], - }, - ], - }, - { - name: 'unwatch_name', - girTypeName: 'method', - returnTypes: [{ type: 'void' }], - inParams: [ - { - name: 'id', - type: [{ type: 'number' }], - }, - ], - }, - { - name: 'own_name', - girTypeName: 'method', - returnTypes: [{ type: 'number' }], - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'Gio.BusNameOwnerFlags' }], - }, - { - name: 'name_acquired_closure', - type: [{ type: 'GObject.TClosure', nullable: true }], - }, - { - name: 'name_lost_closure', - type: [{ type: 'GObject.TClosure', nullable: true }], - }, - ], - }, - { - name: 'unown_name', - girTypeName: 'method', - returnTypes: [{ type: 'void' }], - inParams: [ - { - name: 'id', - type: [{ type: 'number' }], - }, - ], - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'Gio.ListStore', - generics: [ - { - name: 'A', - extends: 'GObject.Object', - value: 'GObject.Object', - }, - ], - methods: [ - { - name: 'insert_sorted', - girTypeName: 'method', - returnTypes: [{ type: 'number' }], - inParams: [ - { - name: 'item', - type: [{ type: 'A' }], - }, - { - name: 'compare_func', - type: [{ type: 'GLib.CompareDataFunc' }], - }, - ], - }, - { - name: 'sort', - girTypeName: 'method', - returnTypes: [{ type: 'void' }], - inParams: [ - { - name: 'compare_func', - type: [{ type: 'GLib.CompareDataFunc' }], - }, - ], - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'Gio.File', - methods: [ - { - name: 'replace_contents_async', - girTypeName: 'method', - returnTypes: [{ type: 'void' }], - // contents: Uint8Array, etag: string | null, make_backup: boolean, flags: FileCreateFlags, cancellable: Cancellable | null, callback: AsyncReadyCallback | null - inParams: [ - { - name: 'contents', - type: [{ type: 'Uint8Array' }], - }, - { - name: 'etag', - type: [{ type: 'string', nullable: true }], - }, - { - name: 'make_backup', - type: [{ type: 'boolean' }], - }, - { - name: 'flags', - type: [{ type: 'FileCreateFlags' }], - }, - { - name: 'cancellable', - type: [{ type: 'Cancellable', nullable: true }], - }, - { - name: 'callback', - type: [{ type: 'AsyncReadyCallback', nullable: true }], - }, - ], - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/gjs/glib-2.0.ts b/packages/lib/src/injection/classes/gjs/glib-2.0.ts deleted file mode 100644 index b2fb87252..000000000 --- a/packages/lib/src/injection/classes/gjs/glib-2.0.ts +++ /dev/null @@ -1,227 +0,0 @@ -import type { InjectionClass, InjectionFunction } from '../../../types/index.js' - -// See https://github.com/gjsify/ts-for-gir/issues/130 -const runAsyncMethod: InjectionFunction = { - name: 'runAsync', - girTypeName: 'method', - inParams: [], - returnTypes: [ - { - type: 'Promise', - }, - ], - doc: { - text: "Similar to `GLib.MainLoop.run` but return a Promise which resolves when the main loop ends, instead of blocking while the main loop runs.\nThis helps avoid the situation where Promises never resolved if you didn't run the main loop inside a callback.", - tags: [], - }, -} - -export const classesGLib20Gjs: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'GLib.MainLoop', - methods: [runAsyncMethod], - }, - // https://gjs.guide/guides/glib/gvariant.html#unpacking-variants - { - versions: ['2.0'], - qualifiedName: 'GLib.Variant', - methods: [ - { - name: 'constructor', - isStatic: true, - returnTypes: [{ type: 'GLib.Variant' }], - inParams: [ - { - name: 'sig', - type: [{ type: 'string' }], - }, - { - name: 'value', - type: [{ type: 'any' }], - }, - ], - girTypeName: 'constructor', - }, - { - name: 'new', - returnTypes: [{ type: 'GLib.Variant' }], - inParams: [ - { - name: 'sig', - type: [{ type: 'string' }], - }, - { - name: 'value', - type: [{ type: 'any' }], - }, - ], - girTypeName: 'constructor', - }, - { - name: 'unpack', - returnTypes: [{ type: 'T' }], - girTypeName: 'method', - generics: [ - { - name: 'T', - value: 'unknown', - }, - ], - }, - { - name: 'deepUnpack', - returnTypes: [{ type: 'T' }], - girTypeName: 'method', - generics: [ - { - name: 'T', - value: 'unknown', - }, - ], - }, - { - name: 'recursiveUnpack', - returnTypes: [{ type: 'T' }], - girTypeName: 'method', - generics: [ - { - name: 'T', - value: 'unknown', - }, - ], - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'GLib.Bytes', - methods: [ - { - name: 'toArray', - returnTypes: [{ type: 'Uint8Array' }], - girTypeName: 'method', - doc: { - text: 'Convert a [`GLib.Bytes`](https://gjs-docs.gnome.org/glib20/glib.bytes) object to a `Uint8Array` object.', - tags: [ - { - tagName: '@returns', - paramName: '', - text: 'A `Uint8Array`', - }, - ], - }, - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'GLib.Error', - properties: [ - // https://gitlab.gnome.org/GNOME/gjs/-/blob/d1cf26179322b2b87fb980e3b244b5e24dba8dd6/gi/gerror.cpp#L298-305 - { - name: 'stack', - type: [{ type: 'string' }], - girTypeName: 'property', - doc: { - text: 'The stack trace of the error.', - tags: [ - { - tagName: '@field', - paramName: '', - text: '', - }, - ], - }, - }, - { - name: 'source', - type: [{ type: 'string' }], - girTypeName: 'property', - doc: { - text: 'The name of the file where is the source of the error.', - tags: [ - { - tagName: '@field', - paramName: '', - text: '', - }, - ], - }, - }, - { - name: 'line', - type: [{ type: 'number' }], - girTypeName: 'property', - doc: { - text: 'The line number of the source of the error.', - tags: [ - { - tagName: '@field', - paramName: '', - text: '', - }, - ], - }, - }, - { - name: 'column', - type: [{ type: 'number' }], - girTypeName: 'property', - doc: { - text: 'The column number of the source of the error.', - tags: [ - { - tagName: '@field', - paramName: '', - text: '', - }, - ], - }, - }, - ], - methods: [ - // https://gitlab.gnome.org/GNOME/gjs/-/blob/33d58646d43b84d4c0ffc3681b89d125d5ccdfc6/installed-tests/js/testExceptions.js#L119-123 - // https://gjs-docs.gnome.org/glib20~2.66.1/glib.error#constructor-new_literal - { - name: 'constructor', - isStatic: true, - returnTypes: [{ type: 'GLib.Error' }], - inParams: [ - { - name: 'domain', - type: [{ type: 'GLib.Quark' }], - }, - { - name: 'code', - type: [{ type: 'number' }], - }, - { - name: 'message', - type: [{ type: 'string' }], - }, - ], - girTypeName: 'constructor', - }, - { - name: 'new', - returnTypes: [{ type: 'GLib.Error' }], - inParams: [ - { - name: 'domain', - type: [{ type: 'GLib.Quark' }], - }, - { - name: 'code', - type: [{ type: 'number' }], - }, - { - name: 'message', - type: [{ type: 'string' }], - }, - ], - girTypeName: 'constructor', - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/gjs/gobject-2.0.ts b/packages/lib/src/injection/classes/gjs/gobject-2.0.ts deleted file mode 100644 index 674eeea8b..000000000 --- a/packages/lib/src/injection/classes/gjs/gobject-2.0.ts +++ /dev/null @@ -1,635 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -export const classesGObject20Gjs: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'GObject.ParamSpec', - // Static functions injected by GJS, see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/overrides/GObject.js - staticFunctions: [ - // static char(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecChar - { - girTypeName: 'static-function', - name: 'char', - returnTypes: [{ type: 'GObject.ParamSpecChar' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static uchar(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecUChar - { - girTypeName: 'static-function', - name: 'uchar', - returnTypes: [{ type: 'GObject.ParamSpecUChar' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static int(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecInt - { - girTypeName: 'static-function', - name: 'int', - returnTypes: [{ type: 'GObject.ParamSpecInt' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static uint(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecUInt - { - girTypeName: 'static-function', - name: 'uint', - returnTypes: [{ type: 'GObject.ParamSpecUInt' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static long(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecLong - { - girTypeName: 'static-function', - name: 'long', - returnTypes: [{ type: 'GObject.ParamSpecLong' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static ulong(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecULong - { - girTypeName: 'static-function', - name: 'ulong', - returnTypes: [{ type: 'GObject.ParamSpecULong' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static int64(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecInt64 - { - girTypeName: 'static-function', - name: 'int64', - returnTypes: [{ type: 'GObject.ParamSpecInt64' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static uint64(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecUInt64 - { - girTypeName: 'static-function', - name: 'uint64', - returnTypes: [{ type: 'GObject.ParamSpecUInt64' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static float(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecFloat - { - girTypeName: 'static-function', - name: 'float', - returnTypes: [{ type: 'GObject.ParamSpecFloat' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static boolean(name: string, nick: string, blurb: string, flags: ParamFlags, defaultValue: boolean): ParamSpecBoolean - { - girTypeName: 'static-function', - name: 'boolean', - returnTypes: [{ type: 'GObject.ParamSpecBoolean' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'defaultValue', - type: [{ type: 'boolean' }], - }, - ], - }, - // TODO add generic - // static flags(name: string, nick: string, blurb: string, flags: ParamFlags, flagsType: GType, defaultValue: number): ParamSpecFlags - { - girTypeName: 'static-function', - name: 'flags', - returnTypes: [{ type: 'GObject.ParamSpecFlags' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'flagsType', - type: [{ type: 'GObject.GType' }], - }, - { - name: 'defaultValue', - type: [{ type: 'boolean' }], - }, - ], - }, - // static enum(name: string, nick: string, blurb: string, flags: ParamFlags, enumType: GType, defaultValue: number): ParamSpecEnum - { - girTypeName: 'static-function', - name: 'enum', - returnTypes: [{ type: 'GObject.ParamSpecEnum' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'enumType', - type: [{ type: 'GObject.GType' }], - }, - { - name: 'defaultValue', - type: [{ type: 'boolean' }], - }, - ], - }, - // static double(name: string, nick: string, blurb: string, flags: ParamFlags, minimum: number, maximum: number, defaultValue: number): ParamSpecDouble - { - girTypeName: 'static-function', - name: 'double', - returnTypes: [{ type: 'GObject.ParamSpecDouble' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'minimum', - type: [{ type: 'number' }], - }, - { - name: 'maximum', - type: [{ type: 'number' }], - }, - { - name: 'defaultValue', - type: [{ type: 'number' }], - }, - ], - }, - // static string(name: string, nick: string, blurb: string, flags: ParamFlags, defaultValue: string | null): ParamSpecString - { - girTypeName: 'static-function', - name: 'string', - returnTypes: [{ type: 'GObject.ParamSpecString' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'defaultValue', - type: [{ type: 'string | null' }], - }, - ], - }, - // static boxed(name: string, nick: string, blurb: string, flags: ParamFlags, boxedType: GType): ParamSpecBoxed - { - girTypeName: 'static-function', - name: 'boxed', - returnTypes: [{ type: 'GObject.ParamSpecBoxed' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'boxedType', - type: [{ type: 'GObject.GType' }], - }, - ], - }, - // static object(name: string, nick: string, blurb: string, flags: ParamFlags, objectType: GType): ParamSpecObject - { - girTypeName: 'static-function', - name: 'object', - returnTypes: [{ type: 'GObject.ParamSpecObject' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'objectType', - type: [{ type: 'GObject.GType' }], - }, - ], - }, - // static jsobject(name: string, nick: string, blurb: string, flags: ParamFlags): ParamSpecBoxed - { - girTypeName: 'static-function', - name: 'jsobject', - returnTypes: [{ type: 'GObject.ParamSpecBoxed' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - ], - }, - // static param(name: string, nick: string, blurb: string, flags: ParamFlags, paramType: GType): ParamSpecParam - { - girTypeName: 'static-function', - name: 'param', - returnTypes: [{ type: 'GObject.ParamSpecParam' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'nick', - type: [{ type: 'string' }], - }, - { - name: 'blurb', - type: [{ type: 'string' }], - }, - { - name: 'flags', - type: [{ type: 'GObject.ParamFlags' }], - }, - { - name: 'paramType', - type: [{ type: 'GObject.GType' }], - }, - ], - }, - // static override(name: string, oclass: GObject.Object | Function | GObject.GType): void - { - girTypeName: 'static-function', - name: 'override', - returnTypes: [{ type: 'void' }], - isStatic: true, - inParams: [ - { - name: 'name', - type: [{ type: 'string' }], - }, - { - name: 'oclass', - type: [{ type: 'GObject.Object' }, { type: 'Function' }, { type: 'GObject.GType' }], - }, - ], - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/gjs/index.ts b/packages/lib/src/injection/classes/gjs/index.ts deleted file mode 100644 index 5a1e7f40d..000000000 --- a/packages/lib/src/injection/classes/gjs/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { InjectionClass } from '../../../types/index.js' - -import { classesGio20Gjs } from './gio-2.0.js' -import { classesGObject20Gjs } from './gobject-2.0.js' -import { classesGLib20Gjs } from './glib-2.0.js' - -export const classesGjs: InjectionClass[] = [...classesGio20Gjs, ...classesGObject20Gjs, ...classesGLib20Gjs] diff --git a/packages/lib/src/injection/classes/glib-2.0.ts b/packages/lib/src/injection/classes/glib-2.0.ts deleted file mode 100644 index 3882fe2c4..000000000 --- a/packages/lib/src/injection/classes/glib-2.0.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { InjectionClass } from '../../types/index.js' - -export const classesGLib20All: InjectionClass[] = [ - { - versions: ['2.0'], - qualifiedName: 'GLib.List', - generics: [ - { - name: 'A', - value: 'any', - }, - ], - }, - { - versions: ['2.0'], - qualifiedName: 'GLib.HashTable', - // TODO - // [key: A]: B; - // properties: [ - // { - // name: '[key: A]' - // type: 'B' - // } - // ], - generics: [ - { - name: 'A', - value: 'symbol | string | number', - }, - { - name: 'B', - value: 'string | number | boolean', - }, - ], - }, -] diff --git a/packages/lib/src/injection/classes/index.ts b/packages/lib/src/injection/classes/index.ts deleted file mode 100644 index 4a8836354..000000000 --- a/packages/lib/src/injection/classes/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { InjectionClass } from '../../types/index.js' - -import { classesGLib20All } from './glib-2.0.js' - -export { classesGjs } from './gjs/index.js' -export const classesAll: InjectionClass[] = [...classesGLib20All] diff --git a/packages/lib/src/injection/index.ts b/packages/lib/src/injection/index.ts deleted file mode 100644 index 84f29fd23..000000000 --- a/packages/lib/src/injection/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './classes/index.js' -export * from './callbacks/index.js' -export * from './injector.js' diff --git a/packages/lib/src/injection/injector.ts b/packages/lib/src/injection/injector.ts deleted file mode 100644 index 4716ee54f..000000000 --- a/packages/lib/src/injection/injector.ts +++ /dev/null @@ -1,183 +0,0 @@ -import type { - GirClassElement, - GirRecordElement, - GirUnionElement, - GirInterfaceElement, - GirCallbackElement, - GirCallableParamElement, -} from '../types/index.js' -import { Logger } from '../logger.js' - -import { classesAll, classesGjs, callbacksGjs, callbacksAll } from './index.js' -import { GirFactory } from '../gir-factory.js' - -/** - * Inject additional methods, properties, etc - */ -export class Injector { - girFactory = new GirFactory() - log: Logger - - constructor() { - this.log = new Logger(true, 'ConflictResolver') - } - - /** Inject additional generics, methods, properties, etc to a existing class */ - toClass(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement) { - if (!girClass._tsData) { - return - } - - const classes = [...classesAll, ...classesGjs] - - const toClass = classes.find((cls) => { - return ( - girClass._tsData && - cls.qualifiedName === girClass._tsData.qualifiedName && - cls.versions.includes(girClass._tsData.version) - ) - }) - - if (!toClass) { - return girClass - } - - if (toClass.staticFunctions) { - girClass._tsData.staticFunctions.push( - ...this.girFactory.newGirFunctions(toClass.staticFunctions, girClass._tsData, { isInjected: true }), - ) - } - if (toClass.properties) { - girClass._tsData.properties.push( - ...this.girFactory.newGirProperties(toClass.properties, { isInjected: true }), - ) - } - if (toClass.constructors) { - girClass._tsData.constructors.push( - ...this.girFactory.newGirFunctions(toClass.constructors, girClass._tsData, { isInjected: true }), - ) - } - if (toClass.methods) { - girClass._tsData.methods.push( - ...this.girFactory.newGirFunctions(toClass.methods, girClass._tsData, { isInjected: true }), - ) - } - if (toClass.virtualMethods) { - girClass._tsData.virtualMethods.push( - ...this.girFactory.newGirFunctions(toClass.virtualMethods, girClass._tsData, { isInjected: true }), - ) - } - if (toClass.propertySignalMethods) { - for (const propertySignalMethod of toClass.propertySignalMethods) { - propertySignalMethod.isInjected = true - girClass._tsData.propertySignalMethods.push(propertySignalMethod) - } - } - - if (toClass.generics) { - girClass._tsData.generics.push(...this.girFactory.newGenerics(toClass.generics)) - } - - return girClass - } - - /** Inject additional generics to existing callback interfaces */ - toCallback(girCallback: GirCallbackElement) { - const callbacks = [...callbacksAll, ...callbacksGjs] - - if (!girCallback._module || !girCallback._tsData) { - return girCallback - } - - const toCallback = callbacks.find((injectCallback) => { - return ( - girCallback._module && - girCallback._tsData && - injectCallback.name === girCallback._tsData.name && - girCallback._module.namespace === injectCallback.namespace && - injectCallback.versions.includes(girCallback._module.version) - ) - }) - - // if (toCallback?.generics) { - // girCallback._tsData.generics.push(...this.girFactory.newGenerics(toCallback.generics)) - // } - - // NOTICE: We merge the in parameters here - // TODO: Unify injections, merges and overrides - if (toCallback?.inParams) { - for (let i = 0; i < girCallback._tsData.inParams.length; i++) { - const newInParam = toCallback.inParams[i] - const oldInParam = girCallback._tsData.inParams[i] - if (newInParam && oldInParam && oldInParam._tsData?.name === newInParam.name) { - oldInParam._tsData.type = this.girFactory.newTsTypes(newInParam.type) - } - } - } - - if (toCallback?.tsCallbackInterface) { - if (toCallback?.tsCallbackInterface.generics) { - girCallback._tsData.tsCallbackInterface?.generics.push( - ...this.girFactory.newGenerics(toCallback.tsCallbackInterface.generics), - ) - } - } - - return girCallback - } - - toParameterType(girParam: GirCallableParamElement) { - const tsTypes = girParam._tsData?.type - - const callbacks = [...callbacksAll, ...callbacksGjs] - - if (!girParam._module || !girParam._tsData) { - return girParam - } - - // Use the the callback generic injections also for the type of the callback parameters - if (tsTypes) { - for (const tsType of tsTypes) { - const toCallback = callbacks.find((injectCallback) => { - return ( - girParam._module && - girParam._tsData && - // TODO: compare versions - `${injectCallback.namespace}.${injectCallback.name}` === tsType.type - ) - }) - - if (toCallback?.generics) { - const tsFunc = girParam._tsData.parent - const tsClass = tsFunc.parent - for (const generic of toCallback.generics) { - // Currently only used for `Gio.AsyncReadyCallback` - if (generic.value === 'this') { - if (tsFunc.isStatic && tsClass) { - tsType.generics.push({ - ...generic, - value: `${tsClass.namespace}.${tsClass.name}`, - }) - } else if (tsFunc.isGlobal) { - // Add generic parameter to global function - tsFunc.generics.push({ - name: 'Z', - value: 'unknown', - }) - tsType.generics.push({ - value: 'Z', - }) - } else { - tsType.generics.push(generic) - } - } else { - tsType.generics.push(generic) - } - } - } - } - } - - return girParam - } -} diff --git a/packages/lib/src/injections/gio.ts b/packages/lib/src/injections/gio.ts index 1530d8bc8..c16115fe5 100644 --- a/packages/lib/src/injections/gio.ts +++ b/packages/lib/src/injections/gio.ts @@ -17,7 +17,10 @@ import { AnyType, VoidType, GenerifiedTypeIdentifier, - Generic + Generic, + Uint8ArrayType, + BooleanType, + TypeIdentifier } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedField, JSField } from "../gir/property.js"; @@ -128,20 +131,26 @@ export default { // This is not ideal, but DBusProxy's define functions and properties on the prototype. DBusProxy.indexSignature = "[key: string]: any;"; + const makeProxyWrapper = new IntrospectedStaticClassFunction({ + name: "makeProxyWrapper", + parent: DBusProxy, + parameters: [ + new IntrospectedFunctionParameter({ + name: "args", + type: new ArrayType(AnyType), + isVarArgs: true, + direction: GirDirection.In + }) + ], + return_type: new NativeType( + "(bus: DBusConnection, name: string, object: string, asyncCallback?: (initable: (T & DBusProxy) | null, error: unknown | null) => void, cancellable?: Cancellable | null, flags?: DBusProxyFlags) => T & DBusProxy" + ) + }); + + makeProxyWrapper.generics.push(new Generic(new GenericType("T"))); + DBusProxy.members.push( - new IntrospectedStaticClassFunction({ - name: "makeProxyWrapper", - parent: DBusProxy, - parameters: [ - new IntrospectedFunctionParameter({ - name: "args", - type: new ArrayType(AnyType), - isVarArgs: true, - direction: GirDirection.In - }) - ], - return_type: AnyType - }), + makeProxyWrapper, new IntrospectedClassFunction({ name: "connectSignal", parent: DBusProxy, @@ -446,5 +455,80 @@ export default { namespace.members.set("DBusExportedObject", DBusExportedObject); } + + { + // See https://github.com/gjsify/ts-for-gir/issues/130 + const Application = namespace.assertClass("Application"); + + Application.members.push( + new IntrospectedClassFunction({ + parent: Application, + name: "runAsync", + parameters: [ + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "argv", + isOptional: true, + type: new ArrayType(StringType), + doc: "Commandline arguments" + }) + ], + return_type: new NativeType("Promise"), + doc: "Similar to `Gio.Application.run` but return a Promise which resolves when the main loop ends, instead of blocking while the main loop runs.\nThis helps avoid the situation where Promises never resolved if you didn't run the application inside a callback." + }) + ); + } + + { + const File = namespace.assertClass("File"); + + const Flags = namespace.getEnum("FileCreateFlags"); + + if (!Flags) throw new Error("Missing FileCreateFlags"); + + File.members.push( + new IntrospectedClassFunction({ + parent: File, + name: "replace_contents_async", + return_type: VoidType, + // contents: Uint8Array, etag: string | null, make_backup: boolean, flags: FileCreateFlags, cancellable: Cancellable | null, callback: AsyncReadyCallback | null + parameters: [ + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "contents", + type: Uint8ArrayType + }), + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "etag", + isNullable: true, + type: StringType + }), + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "make_backup", + type: BooleanType + }), + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "flags", + type: Flags.getType() + }), + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "cancellable", + isNullable: true, + type: namespace.assertClass("Cancellable").getType() + }), + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "callback", + isNullable: true, + type: new TypeIdentifier("AsyncReadyCallback", "Gio") + }) + ] + }) + ); + } } }; diff --git a/packages/lib/src/injections/glib.ts b/packages/lib/src/injections/glib.ts index 4d0c2bc1d..86abf6511 100644 --- a/packages/lib/src/injections/glib.ts +++ b/packages/lib/src/injections/glib.ts @@ -237,5 +237,20 @@ export default { }) ); } + + { + // See https://github.com/gjsify/ts-for-gir/issues/130 + const MainLoop = namespace.assertClass("MainLoop"); + + MainLoop.members.push( + new IntrospectedClassFunction({ + parent: MainLoop, + name: "runAsync", + parameters: [], + return_type: new NativeType("Promise"), + doc: "Similar to `GLib.MainLoop.run` but return a Promise which resolves when the main loop ends, instead of blocking while the main loop runs.\nThis helps avoid the situation where Promises never resolved if you didn't run the main loop inside a callback." + }) + ); + } } }; diff --git a/packages/lib/src/injections/gobject.ts b/packages/lib/src/injections/gobject.ts index 0e29e0b1e..711427e1b 100644 --- a/packages/lib/src/injections/gobject.ts +++ b/packages/lib/src/injections/gobject.ts @@ -22,7 +22,8 @@ import { GenericType, TypeExpression, BooleanType, - GenerifiedTypeIdentifier + GenerifiedTypeIdentifier, + OrType } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedField } from "../gir/property.js"; @@ -41,6 +42,10 @@ function anyParam(name: string) { return typeParam(name, AnyType); } +function stringParam(name: string) { + return typeParam(name, StringType); +} + export default { namespace: "GObject", version: "2.0", @@ -76,17 +81,20 @@ export default { namespace.members.set("SignalMatch", SignalMatch); - const GType = new IntrospectedAlias({ - name: "GType", - namespace, - type: new NativeType("any") - }); - namespace.members.set("GType", GType); + // TODO: gi.ts stopped typing GType because + // it isn't necessary in modern GJS... + + // const GType = new IntrospectedAlias({ + // name: "GType", + // namespace, + // type: new NativeType("any") + // }); + // namespace.members.set("GType", GType); // We don't want to emit TypeScript-specific GType // hacks, but we still need the alias so the type // can resolve. - GType.noEmit(); + // GType.noEmit(); const ParamSpec = namespace.assertClass("ParamSpec"); const ParamFlags = namespace.getEnum("ParamFlags"); @@ -132,15 +140,6 @@ export default { return fn; } - ParamSpec.fields.push( - new IntrospectedField({ - name: "override", - isStatic: true, - type: AnyType, - writable: true - }) - ); - // Get rid of the ParamSpec subtypes. namespace.assertClass("ParamSpecBoolean").noEmit(); namespace.assertClass("ParamSpecBoxed").noEmit(); @@ -174,10 +173,10 @@ export default { const object = new IntrospectedStaticClassFunction({ name: "object", parameters: [ - anyParam("name"), - anyParam("nick"), - anyParam("blurb"), - anyParam("flags"), + stringParam("name"), + stringParam("nick"), + stringParam("blurb"), + stringParam("flags"), new IntrospectedFunctionParameter({ name: "objectType", direction: GirDirection.In, @@ -190,6 +189,38 @@ export default { object.generics.push(new Generic(new GenericType("T"))); + // static jsobject(name: string, nick: string, blurb: string, flags: ParamFlags): ParamSpecBoxed + const jsobject = new IntrospectedStaticClassFunction({ + name: "jsobject", + parameters: [stringParam("name"), stringParam("nick"), stringParam("blurb"), anyParam("flags")], + parent: ParamSpec, + return_type: new NativeType("ParamSpec") + }); + + jsobject.generics.push(new Generic(new GenericType("T"))); + + const override = new IntrospectedClassFunction({ + parent: ParamSpec, + name: "override", + return_type: VoidType, + parameters: [ + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "name", + type: StringType + }), + new IntrospectedFunctionParameter({ + direction: GirDirection.In, + name: "oclass", + type: new OrType( + namespace.assertClass("Object").getType(), + new NativeType("Function"), + new TypeIdentifier("GType", "GObject") + ) + }) + ] + }); + function ParamSpecWithGenerics(type: TypeExpression) { return new GenerifiedTypeIdentifier("ParamSpec", "GObject", [type]); } @@ -244,7 +275,9 @@ export default { // "object": "static object(name: any, nick: any, blurb: any, flags: any, objectType: any): ParamSpec;", object, // "param": "static param(name: any, nick: any, blurb: any, flags: any, paramType: any): ParamSpec;", - generateParamSpec("param", ParamSpec.getType(), false, "param", false) + generateParamSpec("param", ParamSpec.getType(), false, "param", false), + jsobject, + override ); } From b351d72c99cdee873eca045f72c1ba41c307a7fb Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 11 Mar 2024 01:18:51 -0700 Subject: [PATCH 37/53] lib: Fix support for constructor properties and add interface namespaces --- .../src/type-definition-generator.ts | 235 +++++++++++------- .../templates/gjs/gio-2.0.d.ts | 65 ----- packages/lib/src/generics/visitor.ts | 17 +- packages/lib/src/gir-module.ts | 4 - packages/lib/src/gir.ts | 1 + packages/lib/src/gir/class.ts | 1 + packages/lib/src/gir/function.ts | 105 ++++++-- packages/lib/src/index.ts | 1 - packages/lib/src/visitor.ts | 6 +- 9 files changed, 253 insertions(+), 182 deletions(-) diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index f0ff356ed..ed6f2d92f 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -22,6 +22,7 @@ import { TsDoc, TsDocTag, upperCamelCase, + filterFunctionConflict, } from '@ts-for-gir/lib' import { TemplateProcessor } from './template-processor.js' import { PackageDataParser } from './package-data-parser.js' @@ -52,6 +53,7 @@ import { Generic, NativeType, isInvalid, + filterConflicts, } from '@ts-for-gir/lib' function printGirDocComment(tsDoc: TsDoc, config: GenerateConfig) { @@ -170,7 +172,52 @@ class ModuleGenerator extends FormatGenerator { return this.generateClass(node) } generateInterface(node: IntrospectedInterface): string[] { - return this.generateImplementationInterface(node) + const isGObject = node.someParent((p) => p.namespace.name === 'GObject' && p.name === 'Object') + const functions = filterFunctionConflict(node.namespace, node, node.members, []) + const hasStaticFunctions = functions.some((f) => f instanceof IntrospectedStaticClassFunction) + + const hasNamespace = isGObject || hasStaticFunctions || node.callbacks.length > 0 + + return [ + ...(hasNamespace ? this.generateInterfaceNamespace(node) : []), + ...this.generateImplementationInterface(node), + ...(hasNamespace ? this.generateInterfaceDeclaration(node) : []), + ] + } + generateInterfaceNamespace(node: IntrospectedInterface): string[] { + const isGObject = node.someParent((p) => p.namespace.name === 'GObject' && p.name === 'Object') + const namespace = node.namespace + const functions = filterFunctionConflict(node.namespace, node, node.members, []) + const staticFunctions = functions.filter( + (f): f is IntrospectedStaticClassFunction => f instanceof IntrospectedStaticClassFunction, + ) + const staticFields = node.fields + .filter((f) => f.isStatic) + .map((f) => + f.copy({ + isStatic: false, + }), + ) + return [ + `export interface ${node.name}Namespace { + ${isGObject ? `$gtype: ${namespace.name !== 'GObject' ? 'GObject.' : ''}GType<${node.name}>;` : ''} + prototype: ${node.name}; + ${staticFields.length > 0 ? staticFields.flatMap((sf) => sf.asString(this)).join('\n') : ''} + ${ + staticFunctions.length > 0 + ? staticFunctions + .flatMap((sf) => { + // TODO: We're passing "node" as the parent, even though that isn't technically accurate. + return sf.asClassFunction(node).asString(this) + }) + .join('\n') + : '' + } + }`, + ] + } + generateInterfaceDeclaration(node: IntrospectedInterface): string[] { + return [`\n\nexport const ${node.name}: ${node.name}Namespace;\n`] } generateError(node: IntrospectedError): string[] { const { namespace } = this @@ -831,13 +878,29 @@ class ModuleGenerator extends FormatGenerator { } generateAlias(girAlias: IntrospectedAlias, indentCount = 0) { + const { namespace, options } = this + const desc: string[] = [] const indent = generateIndent(indentCount) + const genericList = girAlias.generics + .map((g) => { + if (g.type) { + return `${g.name} = ${g.type.resolve(namespace, options).rootPrint(namespace, options)}` + } + + return `${g.name}` + }) + .join(', ') + + const generics = genericList ? `<${genericList}>` : '' + const exp = !this.config.noNamespace ? '' : 'export ' - desc.push(`${indent}${exp}type ${girAlias.name} = ${girAlias.type.print(this.namespace, this.config)}`) + desc.push( + `${indent}${exp}type ${girAlias.name}${generics} = ${girAlias.type.print(this.namespace, this.config)}`, + ) return desc } @@ -855,34 +918,31 @@ class ModuleGenerator extends FormatGenerator { const exp = !this.config.noNamespace ? '' : 'export ' let ext = '' const resolution = girClass.resolveParents() - const superType = resolution.node - const iSuperTypes = 'implements' in resolution ? resolution.implements() : [] - - if (superType || iSuperTypes.length > 0) { - ext = `extends ${[ - superType.getType().print(this.namespace, this.config), - ...iSuperTypes.map((i) => i.node.getType().print(this.namespace, this.config)), - ].join(', ')} ` - } + const superType = resolution.extends() // Remove namespace and class module name - const constructPropInterfaceName = removeClassModule( - removeNamespace(`${girClass.name}ConstructorProps`, girClass.namespace.name), - girClass.name, - ) + const constructPropInterfaceName = `ConstructorProps` + + // Only add the "extends" if the parent type will be generated (it has props)... + if (superType && superType.node.props.length > 0) { + ext = `extends ${superType.node.getType().print(this.namespace, this.config)}.${constructPropInterfaceName}` + } def.push(...this.addInfoComment('Constructor properties interface', indentCount)) // START BODY - if (girClass.mainConstructor) { - def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext}{`) - def.push( - ...this.generateFields( - girClass.mainConstructor.parameters.map((param) => param.asField()), - `Own constructor properties of ${girClass.namespace.packageName}.${girClass.name}`, - indentCount + 1, - ), + if (!girClass.mainConstructor) { + const ConstructorProps = filterConflicts( + girClass.namespace, + girClass, + // TODO: Include properties from interface parents too. + girClass.props, ) + .flatMap((v) => v.asString(this, true)) + .join('\n ') + + def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext} {`) + def.push(ConstructorProps) def.push(`${indent}}`, '') } // END BODY @@ -896,7 +956,7 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateFields( girClass.fields, - `Own fields of ${girClass.namespace.packageName}.${girClass.name}`, + `Own fields of ${girClass.namespace.namespace}.${girClass.name}`, indentCount, ), ) @@ -910,7 +970,7 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateProperties( girClass.props, - `Own properties of ${girClass.namespace.packageName}.${girClass.name}`, + `Own properties of ${girClass.namespace.namespace}.${girClass.name}`, indentCount, ), ) @@ -925,9 +985,14 @@ class ModuleGenerator extends FormatGenerator { const def: string[] = [] def.push( ...this.generateFunctions( - [...girClass.members].filter((member) => member instanceof IntrospectedStaticClassFunction), + filterFunctionConflict( + girClass.parent, + girClass, + [...girClass.members].filter((member) => member instanceof IntrospectedStaticClassFunction), + [], + ), indentCount, - `Owm methods of ${girClass.namespace.packageName}.${girClass.name}`, + `Owm methods of ${girClass.namespace.namespace}.${girClass.name}`, ), ) @@ -939,13 +1004,18 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateFunctions( - [...girClass.members].filter( - (member) => - !(member instanceof IntrospectedStaticClassFunction) && - !(member instanceof IntrospectedVirtualClassFunction), + filterFunctionConflict( + girClass.parent, + girClass, + [...girClass.members].filter( + (member) => + !(member instanceof IntrospectedStaticClassFunction) && + !(member instanceof IntrospectedVirtualClassFunction), + ), + [], ), indentCount, - `Owm methods of ${girClass.namespace.packageName}.${girClass.name}`, + `Owm methods of ${girClass.namespace.namespace}.${girClass.name}`, ), ) @@ -957,36 +1027,29 @@ class ModuleGenerator extends FormatGenerator { indentCount = 1, ) { const def: string[] = [] - // if (!girClass || !girClass.name || !girClass._module) { - // throw new Error(NO_TSDATA('generateClassConstructors')) - // } // Constructors if (girClass.mainConstructor instanceof IntrospectedDirectAllocationConstructor) def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor)) else if (girClass.mainConstructor instanceof IntrospectedConstructor) def.push(...this.generateConstructor(girClass.mainConstructor)) + else if ( + girClass.someParent((p: IntrospectedBaseClass) => p.namespace.name === 'GObject' && p.name === 'Object') + ) + def.push(`\nconstructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: any[]);\n`) // _init method - def.push(...girClass.constructors.flatMap((constructor) => this.generateConstructorFunction(constructor))) - // // Pseudo constructors - // def.push( - // ...this.generateFunctions( - // girClass.staticFunctions - // .map((girFunc) => girFunc) - // .filter((tsFunc) => !!tsFunc) as IntrospectedFunction[], - // true, - // namespace, - // indentCount, - // ), - // ) + def.push('_init(...args: any[]): void;\n') + + def.push( + ...filterFunctionConflict(girClass.parent, girClass, girClass.constructors, []).flatMap((constructor) => + this.generateConstructorFunction(constructor), + ), + ) if (def.length) { def.unshift( - ...this.addInfoComment( - `Constructors of ${girClass.namespace.packageName}.${girClass.name}`, - indentCount, - ), + ...this.addInfoComment(`Constructors of ${girClass.namespace.namespace}.${girClass.name}`, indentCount), ) } @@ -1005,9 +1068,14 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateFunctions( - [...girClass.members.values()].filter((fn) => fn instanceof IntrospectedVirtualClassFunction), + filterFunctionConflict( + girClass.parent, + girClass, + [...girClass.members.values()].filter((fn) => fn instanceof IntrospectedVirtualClassFunction), + [], + ), indentCount, - `Own virtual methods of ${girClass.namespace.packageName}.${girClass.name}`, + `Own virtual methods of ${girClass.namespace.namespace}.${girClass.name}`, ), ) @@ -1050,7 +1118,7 @@ class ModuleGenerator extends FormatGenerator { // const signalDescs = this.generateSignals(girClass, girClass, 0) // def.push( - // ...this.mergeDescs(signalDescs, `Own signals of ${girClass.namespace.packageName}.${girClass.name}`, 1), + // ...this.mergeDescs(signalDescs, `Own signals of ${girClass.namespace.namespace}.${girClass.name}`, 1), // ) // return def @@ -1175,6 +1243,7 @@ class ModuleGenerator extends FormatGenerator { def.push(...this.generateClassModules(girClass)) + // TODO: Should implementation interfaces be supported? // def.push(...this.generateImplementationInterface(girClass)) def.push(...this.addGirDocComment(girClass.doc, [], 0)) @@ -1367,18 +1436,6 @@ class ModuleGenerator extends FormatGenerator { const def: string[] = [] const dep = this.dependencyManager.get(packageName) - // if (this.config.package) { - // if (this.config.buildType === 'types') { - // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html - // def.push(`/// `) - // } - // } else { - // if (this.config.buildType === 'types') { - // // See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html - // def.push(`/// `) - // } - // } - def.push(dep.importDef) return def @@ -1592,27 +1649,7 @@ class ModuleGenerator extends FormatGenerator { } } - async exportModule(registry: NSRegistry, girModule: GirModule) { - // let pkgData: PackageData | undefined - // if (this.packageData) { - // pkgData = this.packageData.get(girModule.packageName) - // } - // const moduleTemplateProcessor = new TemplateProcessor( - // { - // name: girModule.namespace, - // namespace: girModule.namespace, - // version: girModule.version, - // importName: girModule.importName, - // girModule, - // girModules, - // girModulesGrouped, - // pkgData, - // }, - // girModule.packageName, - // girModule.transitiveDependencies, - // this.config, - // ) - + async exportModule(_registry: NSRegistry, girModule: GirModule) { await this.exportModuleTS() await this.exportModuleJS(girModule) @@ -1673,7 +1710,14 @@ export class TypeDefinitionGenerator implements Generator { if (!this.config.outdir) return const packageName = 'Gjs' - const templateProcessor = new TemplateProcessor(registry, packageName, dependencies, this.config) + const templateProcessor = new TemplateProcessor( + { + registry, + }, + packageName, + dependencies, + this.config, + ) await templateProcessor.create('gjs.d.ts', this.config.outdir, 'gjs.d.ts') await templateProcessor.create('gjs.js', this.config.outdir, 'gjs.js') @@ -1697,8 +1741,19 @@ export class TypeDefinitionGenerator implements Generator { // Import ambient path alias if (this.config.generateAlias) { + const templateProcessor = new TemplateProcessor( + { + registry, + }, + // TODO: We have to mock an empty package name to avoid + // outputting this in the wrong directoy... + '', + dependencies, + this.config, + ) + // Write tsconfig.alias.json to the root of the package - await templateProcessor.create('tsconfig.alias.json', this.config.outdir, 'tsconfig.alias.json', true) + await templateProcessor.create('tsconfig.alias.json', this.config.root, 'tsconfig.alias.json', true) } // Package @@ -1711,8 +1766,6 @@ export class TypeDefinitionGenerator implements Generator { } public async start() { - // this.dependencyManager.addAll(girModules) - if (this.packageData) { await this.packageData.start() } diff --git a/packages/generator-typescript/templates/gjs/gio-2.0.d.ts b/packages/generator-typescript/templates/gjs/gio-2.0.d.ts index 47a3163cb..1c7fe5c18 100644 --- a/packages/generator-typescript/templates/gjs/gio-2.0.d.ts +++ b/packages/generator-typescript/templates/gjs/gio-2.0.d.ts @@ -1,68 +1,3 @@ -// See https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/overrides/Gio.js -export const DBus: { - readonly session: DBusConnection; - readonly system: DBusConnection; - get(bus_type: BusType, cancellable?: Cancellable | null, callback?: AsyncReadyCallback | null): void; - get_finish(res: AsyncResult): DBusConnection; - get_sync(bus_type: BusType, cancellable?: Cancellable | null): DBusConnection; - own_name( - bus_type: BusType, - name: string, - flags: BusNameOwnerFlags, - bus_acquired_closure?: GObject.Closure | null, - name_acquired_closure?: GObject.Closure | null, - name_lost_closure?: GObject.Closure | null - ): number; - own_name_on_connection( - connection: DBusConnection, - name: string, - flags: BusNameOwnerFlags, - name_acquired_closure?: GObject.Closure | null, - name_lost_closure?: GObject.Closure | null - ): number; - unown_name(owner_id: number): void; - watch_name( - bus_type: BusType, - name: string, - flags: BusNameWatcherFlags, - name_appeared_closure?: GObject.Closure | null, - name_vanished_closure?: GObject.Closure | null - ): number; - unwatch_name(watcher_id: number): void; - watch_name_on_connection( - connection: DBusConnection, - name: string, - flags: BusNameWatcherFlags, - name_appeared_closure?: GObject.Closure | null, - name_vanished_closure?: GObject.Closure | null - ): number; -} - -export module DBusExportedObject { - export interface ConstructorProperties { - [key: string]: any; - } -} - -// See https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/overrides/Gio.js -export class DBusExportedObject { - static $gtype: GObject.GType; - - constructor(properties?: Partial, ...args: any[]); - _init(properties?: Partial, ...args: any[]): void; - - static wrapJSObject(info: string, obj: any): DBusExportedObject; - get_info(): DBusInterfaceInfo; - get_connection(): DBusConnection; - get_object_path(): string; - unexport_from_connection(connection: DBusConnection): void; - ["export"](busConnection: DBusConnection, objectPath: string): void; - unexport(): void; - flush(): void; - emit_signal(name: string, variant: GLib.Variant): void; - emit_property_changed(name: string, variant: GLib.Variant): void; -} - /** * A convenient helper to create Promise wrappers for asynchronous functions in GJS. * diff --git a/packages/lib/src/generics/visitor.ts b/packages/lib/src/generics/visitor.ts index 9b59b4a2f..3c59d6967 100644 --- a/packages/lib/src/generics/visitor.ts +++ b/packages/lib/src/generics/visitor.ts @@ -1,4 +1,12 @@ -import { ClosureType, GenericType, Generic, TypeIdentifier, GenerifiedTypeIdentifier, ThisType } from "../gir.js"; +import { + ClosureType, + GenericType, + Generic, + TypeIdentifier, + GenerifiedTypeIdentifier, + ThisType, + IntrospectedEnum +} from "../gir.js"; import { IntrospectedClass, IntrospectedBaseClass, IntrospectedInterface } from "../gir/class.js"; import { IntrospectedCallback, @@ -278,7 +286,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - private generifyStandaloneClassFunction = (node: IntrospectedClassFunction) => { + private generifyStandaloneClassFunction = (node: T): T => { const unwrapped = node.return().unwrap(); if (node.parent.getType().is("GObject", "Object")) { @@ -294,7 +302,8 @@ export class GenericVisitor extends GirVisitor { copied.generics.push(new Generic(genericReturnType, unwrapped, unwrapped)); - return copied; + // TODO: .copy() isn't generic. + return copied as T; } return node; @@ -308,7 +317,7 @@ export class GenericVisitor extends GirVisitor { return node; }; - visitClassFunction = (node: IntrospectedClassFunction) => { + visitClassFunction = (node: IntrospectedClassFunction) => { if (node.parent instanceof IntrospectedBaseClass) { const clazz = node.parent; diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index 9061d2582..c43c3bcb4 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -2,7 +2,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { Transformation, IGNORE_GIR_TYPE_TS_DOC_TYPES } from './transformation.js' import { Logger } from './logger.js' -import { Injector } from './injection/injector.js' import { GirFactory } from './gir-factory.js' import { ConflictResolver } from './conflict-resolver.js' import { DependencyManager } from './dependency-manager.js' @@ -115,8 +114,6 @@ export class GirModule { log!: Logger - inject!: Injector - extends?: string /** @@ -853,7 +850,6 @@ export class GirModule { building.log = new Logger(config.verbose, building.packageName || 'GirModule') building.conflictResolver = new ConflictResolver(config.verbose) - building.inject = new Injector() building.importNamespace = building.transformation.transformModuleNamespaceName(building.packageName) building.importName = building.transformation.transformImportName(building.packageName) building.symTable = new SymTable(building.config, building.packageName, building.namespace) diff --git a/packages/lib/src/gir.ts b/packages/lib/src/gir.ts index 3ebe3d12c..8ccde58b7 100644 --- a/packages/lib/src/gir.ts +++ b/packages/lib/src/gir.ts @@ -12,6 +12,7 @@ export { IntrospectedNamespaceMember, IntrospectedClassMember, } from './gir/base.js' +export { filterConflicts, filterFunctionConflict, FilterBehavior } from './gir/class.js' export * from './gir/nodes.js' export abstract class TypeExpression { diff --git a/packages/lib/src/gir/class.ts b/packages/lib/src/gir/class.ts index 1c4692f9e..01d7b7678 100644 --- a/packages/lib/src/gir/class.ts +++ b/packages/lib/src/gir/class.ts @@ -226,6 +226,7 @@ export function filterFunctionConflict< let never: | IntrospectedConstructor | IntrospectedFunction + | IntrospectedClassFunction | IntrospectedStaticClassFunction | IntrospectedVirtualClassFunction; diff --git a/packages/lib/src/gir/function.ts b/packages/lib/src/gir/function.ts index 53a9e4d0f..c1cb665fd 100644 --- a/packages/lib/src/gir/function.ts +++ b/packages/lib/src/gir/function.ts @@ -624,7 +624,9 @@ export class IntrospectedFunctionParameter extends IntrospectedBase< } } -export class IntrospectedClassFunction extends IntrospectedBase { +export class IntrospectedClassFunction< + Parent extends IntrospectedBaseClass | IntrospectedEnum = IntrospectedBaseClass | IntrospectedEnum +> extends IntrospectedBase { readonly parameters: IntrospectedFunctionParameter[]; protected readonly return_type: TypeExpression; readonly output_parameters: IntrospectedFunctionParameter[]; @@ -648,7 +650,7 @@ export class IntrospectedClassFunction extends IntrospectedBase) { super(name, parent, { ...args }); @@ -714,21 +716,13 @@ export class IntrospectedClassFunction extends IntrospectedBase { + const fn = new IntrospectedClassFunction({ name: this.name, parent, output_parameters: outputParameters ?? this.output_parameters, @@ -746,7 +740,7 @@ export class IntrospectedClassFunction extends IntrospectedBase { const node = this.copy({ parameters: this.parameters.map(p => { return p.accept(visitor); @@ -791,7 +785,7 @@ export class IntrospectedClassFunction extends IntrospectedBase { constructor({ name, parameters = [], @@ -819,6 +813,37 @@ export class IntrospectedVirtualClassFunction extends IntrospectedClassFunction }); } + copy({ + parent = this.parent, + interfaceParent, + parameters, + outputParameters, + returnType + }: { + parent?: IntrospectedBaseClass; + interfaceParent?: IntrospectedBaseClass | IntrospectedEnum | undefined; + parameters?: IntrospectedFunctionParameter[] | undefined; + outputParameters?: IntrospectedFunctionParameter[] | undefined; + returnType?: TypeExpression | undefined; + }): IntrospectedVirtualClassFunction { + const fn = new IntrospectedVirtualClassFunction({ + name: this.name, + parent, + output_parameters: outputParameters ?? this.output_parameters, + parameters: parameters ?? this.parameters, + return_type: returnType ?? this.return_type + }); + + fn.generics = [...this.generics]; + fn.returnTypeDoc = this.returnTypeDoc; + + if (interfaceParent) { + fn.interfaceParent = interfaceParent; + } + + return fn._copyBaseProperties(this); + } + return(): TypeExpression { return this.return_type; } @@ -856,8 +881,40 @@ export class IntrospectedStaticClassFunction extends IntrospectedClassFunction { return generator.generateStaticClassFunction(this) as ReturnType; } + copy({ + parent = this.parent, + interfaceParent, + parameters, + outputParameters, + returnType + }: { + parent?: IntrospectedBaseClass | IntrospectedEnum; + interfaceParent?: IntrospectedBaseClass | IntrospectedEnum | undefined; + parameters?: IntrospectedFunctionParameter[] | undefined; + outputParameters?: IntrospectedFunctionParameter[] | undefined; + returnType?: TypeExpression | undefined; + } = {}): IntrospectedStaticClassFunction { + const fn = new IntrospectedStaticClassFunction({ + name: this.name, + parent, + output_parameters: outputParameters ?? this.output_parameters, + parameters: parameters ?? this.parameters, + return_type: returnType ?? this.return_type + }); + + fn.generics = [...this.generics]; + fn.returnTypeDoc = this.returnTypeDoc; + + if (interfaceParent) { + fn.interfaceParent = interfaceParent; + } + + return fn._copyBaseProperties(this); + } + accept(visitor: GirVisitor): IntrospectedStaticClassFunction { const node = this.copy({ + parent: this.parent, parameters: this.parameters.map(p => { return p.accept(visitor); }), @@ -870,6 +927,24 @@ export class IntrospectedStaticClassFunction extends IntrospectedClassFunction { return visitor.visitStaticClassFunction?.(node) ?? node; } + asClassFunction(parent: IntrospectedBaseClass): IntrospectedClassFunction { + const { name, output_parameters, parameters, return_type, doc, isIntrospectable } = this; + + const fn = new IntrospectedClassFunction({ + parent, + name, + output_parameters, + parameters, + return_type, + doc, + isIntrospectable + }); + + fn.returnTypeDoc = this.returnTypeDoc; + + return fn; + } + static fromXML( m: GirFunctionElement, parent: IntrospectedBaseClass | IntrospectedEnum, diff --git a/packages/lib/src/index.ts b/packages/lib/src/index.ts index 5012cbfde..2be88f800 100644 --- a/packages/lib/src/index.ts +++ b/packages/lib/src/index.ts @@ -1,4 +1,3 @@ -export * from './injection/index.js' export * from './types/index.js' export * from './conflict-resolver.js' export * from './constants.js' diff --git a/packages/lib/src/visitor.ts b/packages/lib/src/visitor.ts index d32fe92f3..3f03bfbf4 100644 --- a/packages/lib/src/visitor.ts +++ b/packages/lib/src/visitor.ts @@ -1,6 +1,6 @@ import { TypeExpression } from './gir.js' import { IntrospectedAlias } from './gir/alias.js' -import { IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from './gir/class.js' +import { IntrospectedRecord, IntrospectedInterface, IntrospectedClass, IntrospectedBaseClass } from './gir/class.js' import { IntrospectedConstant } from './gir/const.js' import { GirEnumMember, IntrospectedError, IntrospectedEnum } from './gir/enum.js' import { @@ -40,7 +40,9 @@ export abstract class GirVisitor { visitField?: (node: IntrospectedField) => IntrospectedField visitSignal?: (node: IntrospectedSignal, type?: IntrospectedSignalType) => IntrospectedSignal visitFunction?: (node: IntrospectedFunction) => IntrospectedFunction - visitClassFunction?: (node: IntrospectedClassFunction) => IntrospectedClassFunction + visitClassFunction?: ( + node: IntrospectedClassFunction, + ) => IntrospectedClassFunction visitStaticClassFunction?: (node: IntrospectedStaticClassFunction) => IntrospectedStaticClassFunction visitVirtualClassFunction?: (node: IntrospectedVirtualClassFunction) => IntrospectedVirtualClassFunction visitNamespace?: (node: IntrospectedNamespace) => IntrospectedNamespace From 27a576ed8490ec8c41d6faab6c3b658626d33d80 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 11 Mar 2024 01:19:14 -0700 Subject: [PATCH 38/53] typescript: Update template for new variables --- .../generator-typescript/templates/gjs/tsconfig.alias.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/tsconfig.alias.json b/packages/generator-typescript/templates/gjs/tsconfig.alias.json index f39254460..59f065c6d 100644 --- a/packages/generator-typescript/templates/gjs/tsconfig.alias.json +++ b/packages/generator-typescript/templates/gjs/tsconfig.alias.json @@ -2,10 +2,10 @@ { "compilerOptions": { "baseUrl": ".", - "paths": { <% girModules.forEach(function(module, idx) { %> + "paths": { <% registry.all().forEach(function(module, idx, arr) { %> <%_ const pkg = dep.get(module.namespace, module.version) _%> - <%_ const path = package ? join(typeDir, pkg.importName, pkg.importName) : join(typeDir, pkg.importName) _%> - "gi://<%= module.namespace %>?version=<%= module.version %>": ["<%= path %>.d.ts"]<% if (idx < girModules.length - 1) { %>,<% } %><% }); %> + <%_ const path = pkg ? join(typeDir, pkg.importName, pkg.importName) : join(typeDir, pkg.importName) _%> + "gi://<%= module.namespace %>?version=<%= module.version %>": ["<%= path %>.d.ts"]<% if (idx < arr.length - 1) { %>,<% } %><% }); %> } }, "include": ["<%= typeDir %>/*.ts"] From d0231e1117754445eac1b4f1a93cc87863bf4207 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 12 Mar 2024 02:24:06 -0700 Subject: [PATCH 39/53] typescript: Generate class signals and correct GType annotations - Fix generation of the 'Gjs' types package - Don't generate ambient imports for noNamespace (breaks typeRoots handling) --- .../src/type-definition-generator.ts | 597 +++++++++++++----- .../templates/gjs/module-noNamespace.d.ts | 7 + .../templates/package.json | 30 +- packages/lib/src/gir.ts | 1 + packages/lib/src/injections/gobject.ts | 16 +- 5 files changed, 460 insertions(+), 191 deletions(-) create mode 100644 packages/generator-typescript/templates/gjs/module-noNamespace.d.ts diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index ed6f2d92f..0874cac3f 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -23,6 +23,17 @@ import { TsDocTag, upperCamelCase, filterFunctionConflict, + resolveDirectedType, + TypeConflict, + ConflictType, + BinaryType, + AnyType, + StringType, + AnyFunctionType, + NumberType, + ArrayType, + FilterBehavior, + VoidType, } from '@ts-for-gir/lib' import { TemplateProcessor } from './template-processor.js' import { PackageDataParser } from './package-data-parser.js' @@ -277,33 +288,83 @@ class ModuleGenerator extends FormatGenerator { generateProperty(tsProp: IntrospectedProperty, construct?: boolean, indentCount = 0) { const desc: string[] = [] - const isStatic = false //tsProp.isStatic - - // if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { - // return desc - // } + const isStatic = false // TODO: tsProp.isStatic desc.push(...this.addGirDocComment(tsProp.doc, [], indentCount)) const indent = generateIndent(indentCount) - const varDesc = this.generateVariable(tsProp) + const name = this.generateMemberName(tsProp) const staticStr = isStatic ? 'static ' : '' - const readonly = !tsProp.writable ? 'readonly ' : '' - // temporary solution, will be solved differently later - const commentOut = '' + const { readable, writable, constructOnly } = tsProp + + const hasGetter = readable + const hasSetter = writable && !constructOnly + const readonly = !hasSetter && hasGetter ? 'readonly ' : '' + + let type = tsProp.type + let getterAnnotation = '' + let setterAnnotation = '' + let getterSetterAnnotation = '' + + if (type instanceof TypeConflict) { + switch (type.conflictType) { + case ConflictType.FUNCTION_NAME_CONFLICT: + case ConflictType.FIELD_NAME_CONFLICT: + getterSetterAnnotation = + setterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + // @ts-expect-error\n` + case ConflictType.ACCESSOR_PROPERTY_CONFLICT: + getterSetterAnnotation = + getterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. + // @ts-expect-error\n` + type = type.unwrap() + break + case ConflictType.PROPERTY_ACCESSOR_CONFLICT: + type = new BinaryType(type.unwrap(), AnyType) + break + case ConflictType.PROPERTY_NAME_CONFLICT: + getterSetterAnnotation = + setterAnnotation = + getterAnnotation = + "// This accessor conflicts with another accessor's type in a parent class or interface.\n" + type = new BinaryType(type.unwrap(), AnyType) + break + } + + if (construct && !(type instanceof BinaryType)) { + // For constructor properties we just convert to any. + type = new BinaryType(type, AnyType) + } + } + + const Type = type.resolve(this.namespace, this.options).rootPrint(this.namespace, this.options) || 'any' + + if (construct) { + return [`${name}: ${Type};`] + } + + if (tsProp.parent instanceof IntrospectedInterface) { + return [`${staticStr}${readonly}${name}: ${Type};`] + } + + if (hasGetter && hasSetter) { + desc.push( + `${getterAnnotation}${indent}get ${name}(): ${Type};`, + `${setterAnnotation}${indent}set ${name}(val: ${Type});`, + ) + } else if (hasGetter) { + desc.push(`${getterSetterAnnotation}${indent}get ${name}(): ${Type};`) + } else { + desc.push(`${getterSetterAnnotation}${indent}set ${name}(val: ${Type});`) + } - desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`) return desc } generateField(tsProp: IntrospectedField, indentCount = 0) { const desc: string[] = [] - const isStatic = false //tsProp.isStatic - - // if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { - // return desc - // } + const isStatic = tsProp.isStatic desc.push(...this.addGirDocComment(tsProp.doc, [], indentCount)) @@ -313,7 +374,16 @@ class ModuleGenerator extends FormatGenerator { const readonly = !tsProp.writable ? 'readonly ' : '' // temporary solution, will be solved differently later - const commentOut = '' + let commentOut = '' + let type = tsProp.type + + if (type instanceof TypeConflict) { + if (type.conflictType === ConflictType.PROPERTY_ACCESSOR_CONFLICT) { + commentOut = `// This accessor conflicts with a property, field, or function name in a parent class or interface.\n// @ts-expect-error\n` + } + + type = new BinaryType(type.unwrap(), AnyType) + } desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`) return desc @@ -376,11 +446,8 @@ class ModuleGenerator extends FormatGenerator { // return typeStr // } - generateVariable(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField, indentCount = 0) { - const indent = generateIndent(indentCount) + generateMemberName(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField) { const name = tsVar.name - // Constants are not optional - const optional = false const invalid = isInvalid(name) const Name = invalid && (tsVar instanceof IntrospectedProperty || tsVar instanceof IntrospectedField) @@ -393,6 +460,16 @@ class ModuleGenerator extends FormatGenerator { const ComputedName = 'computed' in tsVar && tsVar.computed ? `[${name}]` : Name + return `${ComputedName}` + } + + generateVariable(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField, indentCount = 0) { + const indent = generateIndent(indentCount) + // Constants are not optional + const optional = false + + const ComputedName = this.generateMemberName(tsVar) + const affix = optional ? '?' : '' const typeStr = this.generateTypes(tsVar.type) @@ -643,6 +720,7 @@ class ModuleGenerator extends FormatGenerator { return '' } + // TODO: // generateOutParameterReturn(girParam: GirCallableParamElement, namespace: string) { // const desc: string[] = [] @@ -667,6 +745,29 @@ class ModuleGenerator extends FormatGenerator { const typeStr = this.generateType(tsFunction.return()) + const outputParameters = tsFunction.output_parameters + + if (outputParameters.length > 0) { + const excludeActualReturnValueFromArray = typeStr === 'void' || typeStr === '' + const returns = [ + ...(excludeActualReturnValueFromArray ? [] : [`${typeStr}`]), + ...outputParameters + .map((op) => { + return ( + resolveDirectedType(op.type, GirDirection.Out)?.resolve(this.namespace, this.options) ?? + op.type.resolve(this.namespace, this.options) + ) + }) + .map((p) => p.rootPrint(this.namespace, this.options)), + ] + + if (returns.length > 1) { + return `[${returns.join(', ')}]` + } else { + return `${returns[0]}` + } + } + return typeStr } @@ -950,12 +1051,32 @@ class ModuleGenerator extends FormatGenerator { return def } - generateClassFields(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1) { + generateClassStaticFields( + girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, + indentCount = 1, + ) { + const def: string[] = [] + + def.push( + ...this.generateFields( + girClass.fields.filter((field) => field.isStatic), + `Static fields of ${girClass.namespace.namespace}.${girClass.name}`, + indentCount, + ), + ) + + return def + } + + generateClassMemberFields( + girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, + indentCount = 1, + ) { const def: string[] = [] def.push( ...this.generateFields( - girClass.fields, + girClass.fields.filter((field) => !field.isStatic), `Own fields of ${girClass.namespace.namespace}.${girClass.name}`, indentCount, ), @@ -964,6 +1085,17 @@ class ModuleGenerator extends FormatGenerator { return def } + generateClassFields(girClass: IntrospectedClass | IntrospectedRecord, indentCount = 1) { + const def: string[] = [] + + def.push( + ...this.generateClassStaticFields(girClass, indentCount), + ...this.generateClassMemberFields(girClass, indentCount), + ) + + return def + } + generateClassProperties(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 1) { const def: string[] = [] @@ -1109,20 +1241,118 @@ class ModuleGenerator extends FormatGenerator { return def } - // generateClassSignals(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface) { - // const def: string[] = [] - // if (!girClass || !girClass.name || !girClass._module) { - // throw new Error(NO_TSDATA('generateClassSignals')) - // } + generateSignals(girClass: IntrospectedClass) { + const namespace = girClass.namespace + // TODO Move these to a cleaner place. + + const Connect = new IntrospectedClassFunction({ + name: 'connect', + parent: girClass, + parameters: [ + new IntrospectedFunctionParameter({ + name: 'id', + type: StringType, + direction: GirDirection.In, + }), + new IntrospectedFunctionParameter({ + name: 'callback', + type: AnyFunctionType, + direction: GirDirection.In, + }), + ], + return_type: NumberType, + }) - // const signalDescs = this.generateSignals(girClass, girClass, 0) + const ConnectAfter = new IntrospectedClassFunction({ + name: 'connect_after', + parent: girClass, + parameters: [ + new IntrospectedFunctionParameter({ + name: 'id', + type: StringType, + direction: GirDirection.In, + }), + new IntrospectedFunctionParameter({ + name: 'callback', + type: AnyFunctionType, + direction: GirDirection.In, + }), + ], + return_type: NumberType, + }) - // def.push( - // ...this.mergeDescs(signalDescs, `Own signals of ${girClass.namespace.namespace}.${girClass.name}`, 1), - // ) + const Emit = new IntrospectedClassFunction({ + name: 'emit', + parent: girClass, + parameters: [ + new IntrospectedFunctionParameter({ + name: 'id', + type: StringType, + direction: GirDirection.In, + }), + new IntrospectedFunctionParameter({ + name: 'args', + isVarArgs: true, + type: new ArrayType(AnyType), + direction: GirDirection.In, + }), + ], + return_type: VoidType, + }) - // return def - // } + let defaultSignals = [] as IntrospectedClassFunction[] + let hasConnect, hasConnectAfter, hasEmit + + if (girClass.signals.length > 0) { + hasConnect = girClass.members.some((m) => m.name === 'connect') + hasConnectAfter = girClass.members.some((m) => m.name === 'connect_after') + hasEmit = girClass.members.some((m) => m.name === 'emit') + + if (!hasConnect) { + defaultSignals.push(Connect) + } + if (!hasConnectAfter) { + defaultSignals.push(ConnectAfter) + } + if (!hasEmit) { + defaultSignals.push(Emit) + } + + defaultSignals = filterConflicts(namespace, girClass, defaultSignals, FilterBehavior.DELETE) + + hasConnect = !defaultSignals.some((s) => s.name === 'connect') + hasConnectAfter = !defaultSignals.some((s) => s.name === 'connect_after') + hasEmit = !defaultSignals.some((s) => s.name === 'emit') + } + + const SignalsList = [ + // TODO Relocate these. + ...defaultSignals.flatMap((s) => s.asString(this)), + ...girClass.signals + .map((s) => { + const methods = [] as string[] + + if (!hasConnect) methods.push(...s.asString(this, IntrospectedSignalType.CONNECT)) + if (!hasConnectAfter) methods.push(...s.asString(this, IntrospectedSignalType.CONNECT_AFTER)) + if (!hasEmit) methods.push(...s.asString(this, IntrospectedSignalType.EMIT)) + + return methods + }) + .flat(), + ] + + return SignalsList + } + + generateClassSignals(girClass: IntrospectedClass) { + const def: string[] = [] + + const signalDescs = this.generateSignals(girClass) + + def.push(...this.mergeDescs(signalDescs, `Own signals of ${girClass.namespace.namespace}.${girClass.name}`, 1)) + + return def + } generateClassModules(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount = 0) { const def: string[] = [] @@ -1188,7 +1418,7 @@ class ModuleGenerator extends FormatGenerator { def.push(...this.generateClassProperties(girClass)) // Fields - def.push(...this.generateClassFields(girClass)) + def.push(...this.generateClassMemberFields(girClass)) // Methods // TODO def.push(...this.generateClassStaticMethods(girClass)) @@ -1199,9 +1429,6 @@ class ModuleGenerator extends FormatGenerator { // Virtual methods def.push(...this.generateClassVirtualMethods(girClass)) - // Signals - // TODO: def.push(...this.generateClassSignals(girClass)) - // TODO: Generate `GirSignalElement`s instead of generate the signal definition strings directly // TODO: def.push(...this.generateClassPropertySignals(girClass)) } @@ -1238,7 +1465,7 @@ class ModuleGenerator extends FormatGenerator { * @param girClass * @param namespace */ - generateClass(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface) { + generateClass(girClass: IntrospectedClass | IntrospectedRecord) { const def: string[] = [] def.push(...this.generateClassModules(girClass)) @@ -1271,6 +1498,11 @@ class ModuleGenerator extends FormatGenerator { // Constructors def.push(...this.generateClassConstructors(girClass)) + if (girClass instanceof IntrospectedClass) { + // Signals + def.push(...this.generateClassSignals(girClass)) + } + // Methods def.push(...this.generateClassStaticMethods(girClass)) @@ -1443,19 +1675,14 @@ class ModuleGenerator extends FormatGenerator { async generateNamespace(girModule: GirModule): Promise { const moduleTemplateProcessor = this.moduleTemplateProcessor - const template = 'module.d.ts' + const template = this.config.noNamespace ? 'module-noNamespace.d.ts' : 'module.d.ts' const explicitTemplate = `${girModule.importName}.d.ts` - // let target = `${girModule.importName}.d.ts` - - // target = `${girModule.importName}.d.mts` - const out: string[] = [] out.push(...this.addTSDocCommentLines([girModule.packageName])) out.push('') - // out.push(...this.generateModuleDependenciesImport('Gjs') // Module dependencies as type references or imports // TODO: Move to template @@ -1482,12 +1709,14 @@ class ModuleGenerator extends FormatGenerator { out.push('') if (girModule.members) - for (const m of girModule.members.values()) + for (const m of girModule.members.values()) { out.push( - ...(Array.isArray(m) ? m : [m]).flatMap( - (m) => (m as IntrospectedNamespaceMember).asString(this as FormatGenerator) ?? [], - ), + ...(Array.isArray(m) ? m : [m]) + .flatMap((m) => (m as IntrospectedNamespaceMember) ?? []) + .filter((m) => m.emit) + .flatMap((m) => m.asString(this as FormatGenerator) ?? ''), ) + } // Extra interfaces if a template with the module name (e.g. '../templates/gobject-2-0.d.ts') is found // E.g. used for GObject-2.0 to help define GObject classes in js; @@ -1563,92 +1792,6 @@ class ModuleGenerator extends FormatGenerator { return [prepend, ...out, append] } - async exportNPMPackage(girModuleImportName: string) { - await this.exportNPMPackageJson() - await this.exportNPMReadme(girModuleImportName) - await this.exportTSConfig() - await this.exportTypeDoc() - } - - async exportNPMPackageJson() { - const template = 'package.json' - if (this.config.outdir) { - await this.moduleTemplateProcessor.create( - template, - this.config.outdir, - template, // output filename - undefined, - undefined, - {}, - this.config, - ) - } else { - const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) - this.log.log(append + prepend) - } - } - - async exportNPMReadme(girModuleImportName: string) { - // E.g. `README-GJS.md` or `README-GTK-4.0.md` - let template = girModuleImportName ? `README-${girModuleImportName.toUpperCase()}.md` : 'README.md' - const outputFilename = 'README.md' - - if (!this.moduleTemplateProcessor.exists(template)) { - template = 'README.md' - } - - if (this.config.outdir) { - await this.moduleTemplateProcessor.create( - template, - this.config.outdir, - outputFilename, - undefined, - undefined, - {}, - this.config, - ) - } else { - const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) - this.log.log(append + prepend) - } - } - - async exportTSConfig() { - const template = 'tsconfig.json' - if (this.config.outdir) { - await this.moduleTemplateProcessor.create( - template, - this.config.outdir, - template, // output filename - undefined, - undefined, - {}, - this.config, - ) - } else { - const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) - this.log.log(append + prepend) - } - } - - async exportTypeDoc() { - const template = 'typedoc.json' - if (this.config.outdir) { - await this.moduleTemplateProcessor.create( - template, - this.config.outdir, - template, // output filename - undefined, - undefined, - {}, - this.config, - ) - } else { - const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) - this.log.log(append + prepend) - } - } - async exportModule(_registry: NSRegistry, girModule: GirModule) { await this.exportModuleTS() await this.exportModuleJS(girModule) @@ -1659,7 +1802,9 @@ class ModuleGenerator extends FormatGenerator { await this.exportModuleImportTS(girModule) await this.exportModuleImportJS(girModule) - await this.exportNPMPackage(girModule.importName) + const pkg = new NpmPackage(this.config, this.dependencyManager, girModule) + + await pkg.exportNPMPackage() } } @@ -1706,63 +1851,68 @@ export class TypeDefinitionGenerator implements Generator { return def } - async exportGjs(dependencies: Dependency[], registry: NSRegistry) { - if (!this.config.outdir) return - const packageName = 'Gjs' + async exportGjs() { + const { config, dependencyManager } = this + + if (!config.outdir) return + + const gjs = dependencyManager.getGjs() const templateProcessor = new TemplateProcessor( { - registry, + registry: dependencyManager, }, - packageName, - dependencies, - this.config, + gjs.packageName, + dependencyManager.core(), + config, ) - await templateProcessor.create('gjs.d.ts', this.config.outdir, 'gjs.d.ts') - await templateProcessor.create('gjs.js', this.config.outdir, 'gjs.js') + await templateProcessor.create('gjs.d.ts', config.outdir, 'gjs.d.ts') + await templateProcessor.create('gjs.js', config.outdir, 'gjs.js') - await templateProcessor.create('gettext.d.ts', this.config.outdir, 'gettext.d.ts') - await templateProcessor.create('gettext.js', this.config.outdir, 'gettext.js') + await templateProcessor.create('gettext.d.ts', config.outdir, 'gettext.d.ts') + await templateProcessor.create('gettext.js', config.outdir, 'gettext.js') - await templateProcessor.create('system.d.ts', this.config.outdir, 'system.d.ts') - await templateProcessor.create('system.js', this.config.outdir, 'system.js') + await templateProcessor.create('system.d.ts', config.outdir, 'system.d.ts') + await templateProcessor.create('system.js', config.outdir, 'system.js') - await templateProcessor.create('cairo.d.ts', this.config.outdir, 'cairo.d.ts') - await templateProcessor.create('cairo.js', this.config.outdir, 'cairo.js') + await templateProcessor.create('cairo.d.ts', config.outdir, 'cairo.d.ts') + await templateProcessor.create('cairo.js', config.outdir, 'cairo.js') // Import ambient types - await templateProcessor.create('ambient.d.ts', this.config.outdir, 'ambient.d.ts') - await templateProcessor.create('ambient.js', this.config.outdir, 'ambient.js') + await templateProcessor.create('ambient.d.ts', config.outdir, 'ambient.d.ts') + await templateProcessor.create('ambient.js', config.outdir, 'ambient.js') // DOM types - await templateProcessor.create('dom.d.ts', this.config.outdir, 'dom.d.ts') - await templateProcessor.create('dom.js', this.config.outdir, 'dom.js') + await templateProcessor.create('dom.d.ts', config.outdir, 'dom.d.ts') + await templateProcessor.create('dom.js', config.outdir, 'dom.js') // Import ambient path alias - if (this.config.generateAlias) { + if (config.generateAlias) { const templateProcessor = new TemplateProcessor( { - registry, + registry: dependencyManager, }, // TODO: We have to mock an empty package name to avoid // outputting this in the wrong directoy... '', - dependencies, - this.config, + dependencyManager.core(), + config, ) // Write tsconfig.alias.json to the root of the package - await templateProcessor.create('tsconfig.alias.json', this.config.root, 'tsconfig.alias.json', true) + await templateProcessor.create('tsconfig.alias.json', config.root, 'tsconfig.alias.json', true) } + const pkg = new NpmPackage(config, dependencyManager, gjs) + // Package - await this.module.exportNPMPackage('Gjs') + await pkg.exportNPMPackage() } public async generate(registry: NSRegistry, module: GirModule) { - this.module = new ModuleGenerator(module, this.config) - await this.module.exportModule(registry, module) + const moduleGenerator = new ModuleGenerator(module, this.config) + await moduleGenerator.exportModule(registry, module) } public async start() { @@ -1771,8 +1921,127 @@ export class TypeDefinitionGenerator implements Generator { } } - public async finish(registry: NSRegistry) { + public async finish() { // GJS internal stuff - await this.exportGjs(this.dependencyManager.core(), registry) + await this.exportGjs() + } +} + +class NpmPackage { + config: GenerateConfig + moduleTemplateProcessor: TemplateProcessor + dependencyManager: DependencyManager + log: Logger + packageName: string + + constructor(config: GenerateConfig, dependencyManager: DependencyManager, dependencyOrModule: Wrapped) { + this.config = config + + this.packageName = dependencyOrModule.packageName + + this.log = new Logger(this.config.verbose, TypeDefinitionGenerator.name) + + this.dependencyManager = dependencyManager + + this.moduleTemplateProcessor = new TemplateProcessor( + { + name: dependencyOrModule.namespace, + namespace: dependencyOrModule.namespace, + version: dependencyOrModule.version, + importName: dependencyOrModule.importName, + registry: this.dependencyManager, + girModule: dependencyOrModule instanceof GirModule ? dependencyOrModule : undefined, + }, + dependencyOrModule.packageName, + [], + this.config, + ) + } + + async exportNPMPackage() { + await this.exportNPMPackageJson() + await this.exportNPMReadme() + await this.exportTSConfig() + await this.exportTypeDoc() + } + + async exportNPMPackageJson() { + const template = 'package.json' + if (this.config.outdir) { + await this.moduleTemplateProcessor.create( + template, + this.config.outdir, + template, // output filename + undefined, + undefined, + {}, + this.config, + ) + } else { + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) + this.log.log(append + prepend) + } + } + + async exportNPMReadme() { + const girModuleImportName = this.packageName.toUpperCase() + // E.g. `README-GJS.md` or `README-GTK-4.0.md` + let template = girModuleImportName ? `README-${girModuleImportName}.md` : 'README.md' + const outputFilename = 'README.md' + + if (!this.moduleTemplateProcessor.exists(template)) { + template = 'README.md' + } + + if (this.config.outdir) { + await this.moduleTemplateProcessor.create( + template, + this.config.outdir, + outputFilename, + undefined, + undefined, + {}, + this.config, + ) + } else { + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) + this.log.log(append + prepend) + } + } + + async exportTSConfig() { + const template = 'tsconfig.json' + if (this.config.outdir) { + await this.moduleTemplateProcessor.create( + template, + this.config.outdir, + template, // output filename + undefined, + undefined, + {}, + this.config, + ) + } else { + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) + this.log.log(append + prepend) + } + } + + async exportTypeDoc() { + const template = 'typedoc.json' + if (this.config.outdir) { + await this.moduleTemplateProcessor.create( + template, + this.config.outdir, + template, // output filename + undefined, + undefined, + {}, + this.config, + ) + } else { + const { append, prepend } = await this.moduleTemplateProcessor.load(template, {}, this.config) + this.log.log(append + prepend) + } } } diff --git a/packages/generator-typescript/templates/gjs/module-noNamespace.d.ts b/packages/generator-typescript/templates/gjs/module-noNamespace.d.ts new file mode 100644 index 000000000..f241b6cad --- /dev/null +++ b/packages/generator-typescript/templates/gjs/module-noNamespace.d.ts @@ -0,0 +1,7 @@ +<%# This EJS template is used for the generated .d.ts file of each GIR module like Gtk-4.0, GObject-2.0, ... %> +/* + * Type Definitions for Gjs (https://gjs.guide/) + * + * These type definitions are automatically generated, do not edit them by hand. + * If you found a bug fix it in `<%= APP_NAME %>` or create a bug report on <%= APP_SOURCE %> + */ diff --git a/packages/generator-typescript/templates/package.json b/packages/generator-typescript/templates/package.json index 55fd1b4d8..4b6ddbcf9 100644 --- a/packages/generator-typescript/templates/package.json +++ b/packages/generator-typescript/templates/package.json @@ -20,24 +20,6 @@ _%> "exports": { <%_ if (packageName === 'Gjs' && generateAlias) { _%> "./tsconfig.alias.json": "./tsconfig.alias.json", - <%_ } _%> - <%_ if (packageName === 'Gjs') { _%> - "./ambient": { - "types": "./ambient.d.ts", - "default": "./ambient.js" - }, - "./gettext": { - "types": "./gettext.d.ts", - "default": "./gettext.js" - }, - "./system": { - "types": "./system.d.ts", - "default": "./system.js" - }, - "./cairo": { - "types": "./cairo.d.ts", - "default": "./cairo.js" - }, <%_ } _%> <%_ if (entryPointName === 'gjs') { _%> "./ambient": { @@ -48,6 +30,18 @@ _%> "types": "./dom.d.ts", "default": "./dom.js" }, + "./gettext": { + "types": "./gettext.d.ts", + "default": "./gettext.js" + }, + "./system": { + "types": "./system.d.ts", + "default": "./system.js" + }, + "./cairo": { + "types": "./cairo.d.ts", + "default": "./cairo.js" + }, <%_ } else {_%> "./ambient": { "types": "./<%- entryPointName %>-ambient.d.ts", diff --git a/packages/lib/src/gir.ts b/packages/lib/src/gir.ts index 8ccde58b7..fedff37f1 100644 --- a/packages/lib/src/gir.ts +++ b/packages/lib/src/gir.ts @@ -13,6 +13,7 @@ export { IntrospectedClassMember, } from './gir/base.js' export { filterConflicts, filterFunctionConflict, FilterBehavior } from './gir/class.js' +export { resolveDirectedType, resolvePrimitiveType } from './gir/util.js' export * from './gir/nodes.js' export abstract class TypeExpression { diff --git a/packages/lib/src/injections/gobject.ts b/packages/lib/src/injections/gobject.ts index 711427e1b..eebe69a74 100644 --- a/packages/lib/src/injections/gobject.ts +++ b/packages/lib/src/injections/gobject.ts @@ -81,20 +81,18 @@ export default { namespace.members.set("SignalMatch", SignalMatch); - // TODO: gi.ts stopped typing GType because - // it isn't necessary in modern GJS... + const GType = new IntrospectedAlias({ + name: "GType", + namespace, + type: new NativeType("any") + }); - // const GType = new IntrospectedAlias({ - // name: "GType", - // namespace, - // type: new NativeType("any") - // }); - // namespace.members.set("GType", GType); + namespace.members.set("GType", GType); // We don't want to emit TypeScript-specific GType // hacks, but we still need the alias so the type // can resolve. - // GType.noEmit(); + GType.noEmit(); const ParamSpec = namespace.assertClass("ParamSpec"); const ParamFlags = namespace.getEnum("ParamFlags"); From 33b017e206b053ac95c9282f1944f7f627bc6df3 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 12 Mar 2024 03:02:51 -0700 Subject: [PATCH 40/53] lib: Unify dependency resolution with ts-for-gir transitive dependencies --- packages/lib/src/generators/dts-inline.ts | 13 +---- packages/lib/src/generators/dts-modules.ts | 27 +-------- packages/lib/src/generators/json.ts | 2 +- packages/lib/src/gir-module.ts | 68 ++++------------------ packages/lib/src/gir/class.ts | 6 -- packages/lib/src/gir/util.ts | 2 +- packages/lib/src/registry.ts | 66 --------------------- 7 files changed, 17 insertions(+), 167 deletions(-) diff --git a/packages/lib/src/generators/dts-inline.ts b/packages/lib/src/generators/dts-inline.ts index 84c650662..cb66c52eb 100644 --- a/packages/lib/src/generators/dts-inline.ts +++ b/packages/lib/src/generators/dts-inline.ts @@ -56,18 +56,7 @@ export class DtsInlineGenerator extends DtsGenerator { }) .join("\n"); - const versionedImports = true; // TODO: options.versionedImports - // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. - const imports = Array.from(node.getImports()) - .map( - ([i, version]) => - `import * as ${i} from "${options.npmScope}${i.toLowerCase()}${ - versionedImports ? version.toLowerCase().split(".")[0] : "" - }";` - ) - .join(`${"\n"}`); - - const output = [header, imports, base, content, suffix].join("\n\n"); + const output = [header, base, content, suffix].join("\n\n"); if (options.verbose) { console.debug(`Printing ${namespace.name}...`); diff --git a/packages/lib/src/generators/dts-modules.ts b/packages/lib/src/generators/dts-modules.ts index 82af35027..81cfa4b52 100644 --- a/packages/lib/src/generators/dts-modules.ts +++ b/packages/lib/src/generators/dts-modules.ts @@ -5,7 +5,7 @@ import { GenerationOptions } from "../types.js"; import { override as overrideGLib } from "./dts/glib.js"; import { override as overrideGObject } from "./dts/gobject.js"; import { override as overrideGio } from "./dts/gio.js"; -import { DtsGenerator, versionImportFormat } from "./dts.js"; +import { DtsGenerator } from "./dts.js"; import { IntrospectedNamespaceMember } from "../gir/base.js"; export class DtsModuleGenerator extends DtsGenerator { @@ -60,30 +60,8 @@ export class DtsModuleGenerator extends DtsGenerator { }) .join("\n"); - const versionedImports = true; // TODO options.versionedImports - const pathSuffix = "/index.d.ts"; - const referenceType = "path"; - const references = [ - ...(node.__dts__references ?? []), - ...Array.from(node.getImports()).map( - ([i, version]) => - `/// ` - ) - ].join("\n"); - // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. - const imports = Array.from(node.getImports()) - .map(([i, version]) => `import ${i} from 'gi://${i}${versionedImports ? `?version=${version}` : ""}';`) - .join("\n"); + const imports = []; const metadata = ` /** @@ -115,7 +93,6 @@ export const __version__: string; }`; const output = [ - references, header, versionedModuleHeader, imports, diff --git a/packages/lib/src/generators/json.ts b/packages/lib/src/generators/json.ts index c4b70949b..29d9eb9fc 100644 --- a/packages/lib/src/generators/json.ts +++ b/packages/lib/src/generators/json.ts @@ -1281,7 +1281,7 @@ export class JsonGenerator extends FormatGenerator { .map(m => m.asString(this)); // Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import. - const imports = node.getImports(); + const imports = []; return Promise.resolve({ kind: NodeKind.namespace, diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index c43c3bcb4..b5558fe9c 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -125,9 +125,6 @@ export class GirModule { readonly name: string readonly c_prefixes: string[] - private imports: Map = new Map() - default_imports: Map = new Map() - private _members?: Map private _enum_constants?: Map private _resolve_names: Map = new Map() @@ -454,51 +451,38 @@ export class GirModule { return this.parent.namespacesForPrefix(c_prefix) } + // TODO: Move this into the generator hasImport(name: string): boolean { - return this.default_imports.has(name) || this.imports.has(name) + return this.dependencies.some((dep) => dep.importName === name) } private _getImport(name: string): GirModule | null { - let version = this.default_imports.get(name) ?? this.imports.get(name) - if (name === this.name) { return this } - // TODO: Clean this up, but essentially try to resolve import versions - // using transitive imports (e.g. use GtkSource to find the version of Gtk) - if (!version) { - const entries = [...this.default_imports.entries()].flatMap(([_name]) => { - const namespace = this._getImport(_name) - - return [...(namespace?.default_imports.entries() ?? [])] - }) - - version = Object.fromEntries(entries)[name] - } + const dep = + this.dependencies.find((dep) => dep.namespace === name) ?? + this.transitiveDependencies.find((dep) => dep.namespace === name) + let version = dep?.version if (!version) { version = this.parent.assertDefaultVersionOf(name) } - const namespace = this.parent.namespace(name, version) - - if (namespace) { - if (!this.imports.has(namespace.name)) { - this.imports.set(namespace.name, namespace.version) - } - } - - return namespace + return this.parent.namespace(name, version) } getInstalledImport(name: string): GirModule | null { - let version = this.default_imports.get(name) ?? this.imports.get(name) - if (name === this.name) { return this } + const dep = + this.dependencies.find((dep) => dep.namespace === name) ?? + this.transitiveDependencies.find((dep) => dep.namespace === name) + let version = dep?.version + if (!version) { version = this.parent.defaultVersionOf(name) ?? undefined } @@ -509,12 +493,6 @@ export class GirModule { const namespace = this.parent.namespace(name, version) - if (namespace) { - if (!this.imports.has(namespace.name)) { - this.imports.set(namespace.name, namespace.version) - } - } - return namespace } @@ -528,14 +506,6 @@ export class GirModule { return namespace } - getImports(): [string, string][] { - return [...this.imports.entries()].sort(([[a], [b]]) => a.localeCompare(b)) - } - - addImport(ns_name: string) { - this._getImport(ns_name) - } - getMembers(name: string): IntrospectedNamespaceMember[] { const members = this.members.get(name) @@ -692,20 +662,6 @@ export class GirModule { // another namespace imports it. registry.mapping.set(modName, version, building) - const includes = repo.repository[0].include || [] - - includes - .map((i) => [i.$.name, i.$.version] as const) - .forEach(([name, version]) => { - if (version) { - if (options.verbose) { - console.debug(`Adding dependency ${name} ${version}...`) - } - - building.default_imports.set(name, version) - } - }) - const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { return !building.hasImport(el.name) } diff --git a/packages/lib/src/gir/class.ts b/packages/lib/src/gir/class.ts index 01d7b7678..dcf24622b 100644 --- a/packages/lib/src/gir/class.ts +++ b/packages/lib/src/gir/class.ts @@ -940,12 +940,6 @@ export class IntrospectedClass extends IntrospectedBaseClass { const name = implementee.$.name; const type = parseTypeIdentifier(ns.name, name); - // Sometimes namespaces will implicitly import - // other namespaces like Atk via interface implements. - if (type && type.namespace && type.namespace !== ns.name && !ns.hasImport(type.namespace)) { - ns.addImport(type.namespace); - } - if (type) { clazz.interfaces.push(type); } diff --git a/packages/lib/src/gir/util.ts b/packages/lib/src/gir/util.ts index b8d831051..f5ba7d2a9 100644 --- a/packages/lib/src/gir/util.ts +++ b/packages/lib/src/gir/util.ts @@ -202,7 +202,7 @@ export function getType( name = "unknown"; console.log( `Failed to find type in ${modName}: `, - JSON.stringify(parameter.$, null, 4), + JSON.stringify(parameter.type[0].$, null, 4), "\nMarking as unknown!" ); } diff --git a/packages/lib/src/registry.ts b/packages/lib/src/registry.ts index 04805fff4..936a4efb0 100644 --- a/packages/lib/src/registry.ts +++ b/packages/lib/src/registry.ts @@ -1,9 +1,6 @@ -import { NSRegistry } from './gir/registry.js' import { SanitizedIdentifiers } from './gir/util.js' export { FormatGenerator } from './generators/generator.js' -import { GenerationOptions, Metadata } from './types.js' - export * as dts from './generators/dts-modules.js' export * as json from './generators/json.js' @@ -20,66 +17,3 @@ export { Formatter } from './formatters/formatter.js' export function getSanitizedIdentifiers(): ReadonlyMap { return SanitizedIdentifiers } - -export function createRegistry(): NSRegistry { - return new NSRegistry() -} - -export interface GeneratedModule { - meta: Metadata - formattedOutput: string -} - -export async function generateModule( - options: GenerationOptions, - registry: NSRegistry, - name: string, - version: string, -): Promise { - const ns = registry.namespace(name, version) - - const format = 'dts' // TODO: options.format; - - if (ns) { - const Generator = await registry.getGenerator(format) - - if (!Generator) { - throw new Error(`Invalid output format selected: ${format}.`) - } - - const generator = new Generator(ns, options) - - let generated: string | null = null - - try { - generated = await generator.stringifyNamespace(ns) - } catch (error) { - console.error(`Failed to generate ${ns.name} ${ns.version}...`) - - if (options.verbose) { - console.error(error) - } - } - - if (!generated) { - return null - } - - const meta: Metadata = { - name: ns.name, - api_version: ns.version, - package_version: ns.package_version.join('.'), - imports: Object.fromEntries(ns.getImports()), - } - - const formatter = registry.getFormatter(format) - const formatted = !options.noPrettyPrint ? await formatter.format(generated) : generated - - return { - formattedOutput: formatted, - meta, - } - } - - return null -} From 941dc81db408ea8c328a66df9e5f07f3afc98f11 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 12 Mar 2024 04:29:46 -0700 Subject: [PATCH 41/53] examples: Rework sources and configurations for updated generation --- examples/gjs/adw-1-hello/main.ts | 9 ++- examples/gjs/adw-1-hello/package.json | 2 +- .../gjs/gio-2-cat-alias/.ts-for-girrc.json | 2 +- examples/gjs/gio-2-cat-alias/tsconfig.json | 4 +- .../gjs/gio-2-cat-promisify/tsconfig.json | 4 +- .../gjs/gio-2-cat-types-only/tsconfig.json | 4 +- examples/gjs/gio-2-cat/main.ts | 5 +- examples/gjs/gio-2-cat/package.json | 2 +- examples/gjs/gio-2-dbus/package.json | 2 +- examples/gjs/gio-2-dbus/tsconfig.json | 4 +- examples/gjs/gio-2-list-model/package.json | 2 +- examples/gjs/gio-2-list-model/tsconfig.json | 4 +- examples/gjs/glib-2-spawn-command/main.ts | 2 +- .../gjs/glib-2-spawn-command/package.json | 2 +- .../gjs/glib-2-spawn-command/tsconfig.json | 30 ++++---- examples/gjs/glib-2-variant/package.json | 2 +- examples/gjs/glib-2-variant/tsconfig.json | 4 +- examples/gjs/gtk-3-browser/package.json | 2 +- examples/gjs/gtk-3-browser/tsconfig.json | 4 +- examples/gjs/gtk-3-builder/main.ts | 3 +- examples/gjs/gtk-3-builder/package.json | 2 +- examples/gjs/gtk-3-builder/tsconfig.json | 6 +- examples/gjs/gtk-3-calc/package.json | 2 +- examples/gjs/gtk-3-calc/tsconfig.json | 4 +- examples/gjs/gtk-3-editor/main.ts | 7 +- examples/gjs/gtk-3-editor/package.json | 2 +- examples/gjs/gtk-3-editor/tsconfig.json | 2 +- examples/gjs/gtk-3-gettext/package.json | 2 +- examples/gjs/gtk-3-gettext/tsconfig.json | 4 +- examples/gjs/gtk-3-hello-2/main.ts | 2 - examples/gjs/gtk-3-hello-2/package.json | 2 +- examples/gjs/gtk-3-hello-2/tsconfig.json | 4 +- examples/gjs/gtk-3-hello/main.ts | 3 +- examples/gjs/gtk-3-hello/package.json | 3 +- examples/gjs/gtk-3-hello/tsconfig.json | 4 +- .../{webpack.config.js => webpack.config.cjs} | 0 examples/gjs/gtk-3-template/package.json | 2 +- examples/gjs/gtk-3-template/tsconfig.json | 4 +- examples/gjs/gtk-3-webkit/main.ts | 1 - examples/gjs/gtk-3-webkit/package.json | 2 +- examples/gjs/gtk-3-webkit/tsconfig.json | 4 +- examples/gjs/gtk-4-application/package.json | 2 +- examples/gjs/gtk-4-application/tsconfig.json | 4 +- examples/gjs/gtk-4-custom-widget/package.json | 2 +- .../gjs/gtk-4-custom-widget/tsconfig.json | 4 +- examples/gjs/gtk-4-list-store/main.ts | 1 - examples/gjs/gtk-4-list-store/package.json | 2 +- examples/gjs/gtk-4-list-store/tsconfig.json | 4 +- examples/gjs/gtk-4-template/package.json | 2 +- examples/gjs/gtk-4-template/tsconfig.json | 4 +- examples/gjs/run-async/.gitignore | 18 ----- examples/gjs/run-async/.ts-for-girrc.json | 2 +- .../gjs/run-async/@types/gio-2.0/package.json | 2 +- .../run-async/@types/glib-2.0/package.json | 2 +- .../run-async/@types/gobject-2.0/package.json | 2 +- examples/gjs/run-async/main.ts | 4 -- examples/gjs/run-async/tsconfig.json | 10 ++- examples/gjs/soup-3-http/package.json | 2 +- examples/gjs/soup-3-http/tsconfig.json | 4 +- examples/gjs/soup-3-websocket/client.ts | 1 - examples/gjs/soup-3-websocket/package.json | 2 +- examples/gjs/soup-3-websocket/tsconfig.json | 4 +- examples/gjs/timers/package.json | 2 +- examples/gjs/timers/tsconfig.json | 4 +- .../node-gtk/gtk-4-application/esbuild.mjs | 14 ---- examples/node-gtk/gtk-4-application/main.ts | 71 ------------------- .../node-gtk/gtk-4-application/package.json | 27 ------- .../node-gtk/gtk-4-application/tsconfig.json | 22 ------ .../gtk-4-application/tsconfig.types.json | 6 -- packages/lib/src/dependency-manager.ts | 5 +- 70 files changed, 111 insertions(+), 273 deletions(-) rename examples/gjs/gtk-3-hello/{webpack.config.js => webpack.config.cjs} (100%) delete mode 100644 examples/gjs/run-async/.gitignore delete mode 100644 examples/node-gtk/gtk-4-application/esbuild.mjs delete mode 100644 examples/node-gtk/gtk-4-application/main.ts delete mode 100644 examples/node-gtk/gtk-4-application/package.json delete mode 100644 examples/node-gtk/gtk-4-application/tsconfig.json delete mode 100644 examples/node-gtk/gtk-4-application/tsconfig.types.json diff --git a/examples/gjs/adw-1-hello/main.ts b/examples/gjs/adw-1-hello/main.ts index 536273f1c..dfb78ceb6 100644 --- a/examples/gjs/adw-1-hello/main.ts +++ b/examples/gjs/adw-1-hello/main.ts @@ -3,11 +3,10 @@ * @see https://gitlab.gnome.org/GNOME/libadwaita/-/blob/main/examples/hello-world/hello.c */ -import './@types/gjs/gjs'; -import Gio from './@types/gio-2.0/gio-2.0'; -import GLib from './@types/glib-2.0/glib-2.0'; -import Gtk from './@types/gtk-4.0/gtk-4.0'; -import Adw from './@types/adw-1/adw-1'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Gtk from 'gi://Gtk'; +import Adw from 'gi://Adw'; const loop = GLib.MainLoop.new(null, false) diff --git a/examples/gjs/adw-1-hello/package.json b/examples/gjs/adw-1-hello/package.json index b038c8b87..f73109de4 100644 --- a/examples/gjs/adw-1-hello/package.json +++ b/examples/gjs/adw-1-hello/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Adw-1", + "build:types": "yarn ts-for-gir generate Adw-1 --outdir @types/@girs", "build:app": "vite build", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json b/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json index 21688bbbd..2e9ed5ccb 100644 --- a/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json +++ b/examples/gjs/gio-2-cat-alias/.ts-for-girrc.json @@ -1,6 +1,6 @@ { "modules": ["Gio-2.0"], "noNamespace": false, - "outdir": "./@types", + "outdir": "./@types/@girs", "generateAlias": true } \ No newline at end of file diff --git a/examples/gjs/gio-2-cat-alias/tsconfig.json b/examples/gjs/gio-2-cat-alias/tsconfig.json index 89d0f11a2..0ce4e49a9 100644 --- a/examples/gjs/gio-2-cat-alias/tsconfig.json +++ b/examples/gjs/gio-2-cat-alias/tsconfig.json @@ -2,12 +2,12 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "moduleResolution": "node", }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gio-2-cat-promisify/tsconfig.json b/examples/gjs/gio-2-cat-promisify/tsconfig.json index 1d5d30cd2..846178966 100644 --- a/examples/gjs/gio-2-cat-promisify/tsconfig.json +++ b/examples/gjs/gio-2-cat-promisify/tsconfig.json @@ -2,11 +2,11 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext" }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gio-2-cat-types-only/tsconfig.json b/examples/gjs/gio-2-cat-types-only/tsconfig.json index dc12aae7e..759877532 100644 --- a/examples/gjs/gio-2-cat-types-only/tsconfig.json +++ b/examples/gjs/gio-2-cat-types-only/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/glib-2.0", "@girs/gio-2.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -10,7 +11,6 @@ "noImplicitThis": true, "alwaysStrict": true }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts", "@types/gio-2.0.d.ts", "@types/glib-2.0.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gio-2-cat/main.ts b/examples/gjs/gio-2-cat/main.ts index 0ae82f9ab..fb6ccac86 100644 --- a/examples/gjs/gio-2-cat/main.ts +++ b/examples/gjs/gio-2-cat/main.ts @@ -1,3 +1,6 @@ +/// +/// + // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later // SPDX-FileCopyrightText: 2009 Red Hat, Inc. // Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gio-cat.js @@ -8,8 +11,6 @@ * the label should show a translation of 'Print help' */ -import './@types/gjs/gjs'; -import './@types/gjs/dom'; import GLib from './@types/glib-2.0/glib-2.0'; import Gio from './@types/gio-2.0/gio-2.0'; diff --git a/examples/gjs/gio-2-cat/package.json b/examples/gjs/gio-2-cat/package.json index 243e02634..e2c00d05b 100644 --- a/examples/gjs/gio-2-cat/package.json +++ b/examples/gjs/gio-2-cat/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gio-2.0", + "build:types": "yarn ts-for-gir generate Gio-2.0 --outdir @types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js main.ts", diff --git a/examples/gjs/gio-2-dbus/package.json b/examples/gjs/gio-2-dbus/package.json index 681ba56c8..0963846de 100644 --- a/examples/gjs/gio-2-dbus/package.json +++ b/examples/gjs/gio-2-dbus/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gio-2.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gio-2.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start": "yarn build && yarn start:server", diff --git a/examples/gjs/gio-2-dbus/tsconfig.json b/examples/gjs/gio-2-dbus/tsconfig.json index 33bae9338..c1a56714f 100644 --- a/examples/gjs/gio-2-dbus/tsconfig.json +++ b/examples/gjs/gio-2-dbus/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "dbus-client.ts", "dbus-server.ts", diff --git a/examples/gjs/gio-2-list-model/package.json b/examples/gjs/gio-2-list-model/package.json index 74286fed3..fbc9052e2 100644 --- a/examples/gjs/gio-2-list-model/package.json +++ b/examples/gjs/gio-2-list-model/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gio-2-list-model/tsconfig.json b/examples/gjs/gio-2-list-model/tsconfig.json index 27740af42..b83468bb1 100644 --- a/examples/gjs/gio-2-list-model/tsconfig.json +++ b/examples/gjs/gio-2-list-model/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/glib-2-spawn-command/main.ts b/examples/gjs/glib-2-spawn-command/main.ts index 6b9683d03..d375abddc 100644 --- a/examples/gjs/glib-2-spawn-command/main.ts +++ b/examples/gjs/glib-2-spawn-command/main.ts @@ -1,5 +1,5 @@ // Example based on https://gist.github.com/buzztaiki/1487781/74ea93d3a30f20c7f094327db9cb263a6286f6d6 -import * as GLib from './@types/glib-2.0.js'; +import GLib from 'gi://GLib'; const textDecoder = new TextDecoder(); let [res, out, err, status] = GLib.spawn_command_line_sync('ls -la'); diff --git a/examples/gjs/glib-2-spawn-command/package.json b/examples/gjs/glib-2-spawn-command/package.json index 32fc938e1..2da915696 100644 --- a/examples/gjs/glib-2-spawn-command/package.json +++ b/examples/gjs/glib-2-spawn-command/package.json @@ -10,7 +10,7 @@ "watch": "yarn build:app --watch", "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate GLib-2.0 --noNamespace", + "build:types": "yarn ts-for-gir generate GLib-2.0 --outdir @types/@girs", "clear:types": "rm -rf ./@types", "clear:ts": "rm -rf ./dist", "clear": "yarn clear:ts && yarn clear:types", diff --git a/examples/gjs/glib-2-spawn-command/tsconfig.json b/examples/gjs/glib-2-spawn-command/tsconfig.json index 9da618f9d..233ab4be1 100644 --- a/examples/gjs/glib-2-spawn-command/tsconfig.json +++ b/examples/gjs/glib-2-spawn-command/tsconfig.json @@ -1,17 +1,17 @@ { - "compilerOptions": { - "lib": ["ESNext"], - "types": [], - "target": "ESNext", - "module": "ESNext", - "strict": true, - "noImplicitAny": false, - "strictNullChecks": true, - "noImplicitThis": true, - "alwaysStrict": true, - }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts", "@types/ambient.d.ts"], - "files": [ - "main.ts" - ] + "compilerOptions": { + "lib": ["ESNext"], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/glib-2.0", "@girs/gobject-2.0"], + "typeRoots": ["./@types"], + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "Bundler", + "strict": true, + "noImplicitAny": false, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "skipLibCheck": false + }, + "files": ["main.ts"] } diff --git a/examples/gjs/glib-2-variant/package.json b/examples/gjs/glib-2-variant/package.json index 27ebddab0..5b5730a00 100644 --- a/examples/gjs/glib-2-variant/package.json +++ b/examples/gjs/glib-2-variant/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate GLib-2.0 Gio-2.0 --generateAlias", + "build:types": "yarn ts-for-gir generate GLib-2.0 Gio-2.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/index.js", diff --git a/examples/gjs/glib-2-variant/tsconfig.json b/examples/gjs/glib-2-variant/tsconfig.json index 2af89788e..092b96ad2 100644 --- a/examples/gjs/glib-2-variant/tsconfig.json +++ b/examples/gjs/glib-2-variant/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/glib-2.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "index.ts" ] diff --git a/examples/gjs/gtk-3-browser/package.json b/examples/gjs/gtk-3-browser/package.json index 2f60c6835..dd70e3aa8 100644 --- a/examples/gjs/gtk-3-browser/package.json +++ b/examples/gjs/gtk-3-browser/package.json @@ -11,7 +11,7 @@ "watch": "yarn build:app --watch", "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:ts && webpack --config webpack.config.cjs --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0 --generateAlias --outdir=@types/@girs", "clear:types": "rm -rf ./@types", "clear:ts": "rm -rf ./dist", "clear": "yarn clear:ts && yarn clear:types", diff --git a/examples/gjs/gtk-3-browser/tsconfig.json b/examples/gjs/gtk-3-browser/tsconfig.json index f47168300..9d679eeea 100644 --- a/examples/gjs/gtk-3-browser/tsconfig.json +++ b/examples/gjs/gtk-3-browser/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/pango-1.0", "@girs/gtk-3.0", "@girs/webkit2-4.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -10,7 +11,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/ambient.d.ts", "@types/pango-1.0-ambient.d.ts", "@types/gtk-3.0-ambient.d.ts", "@types/webkit2-4.0-ambient.d.ts"], "files": [ "main.ts" ] diff --git a/examples/gjs/gtk-3-builder/main.ts b/examples/gjs/gtk-3-builder/main.ts index dfe505582..9a37ae499 100644 --- a/examples/gjs/gtk-3-builder/main.ts +++ b/examples/gjs/gtk-3-builder/main.ts @@ -1,6 +1,5 @@ -import './@types/gjs.js' import gladeFile from './builderExample.glade' -import * as Gtk from './@types/gtk-3.0' +import Gtk from './@types/gtk-3.0/gtk-3.0' Gtk.init(null) diff --git a/examples/gjs/gtk-3-builder/package.json b/examples/gjs/gtk-3-builder/package.json index f0a754749..00f995be1 100644 --- a/examples/gjs/gtk-3-builder/package.json +++ b/examples/gjs/gtk-3-builder/package.json @@ -10,7 +10,7 @@ "watch": "yarn build:app --watch", "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:ts && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 --noNamespace", + "build:types": "yarn ts-for-gir generate Gtk-3.0 --noNamespace --outdir=@types", "clear:types": "rm -rf ./@types", "clear:ts": "rm -rf ./dist", "clear": "yarn clear:ts && yarn clear:types", diff --git a/examples/gjs/gtk-3-builder/tsconfig.json b/examples/gjs/gtk-3-builder/tsconfig.json index ae1ae2e0a..ec08a4c94 100644 --- a/examples/gjs/gtk-3-builder/tsconfig.json +++ b/examples/gjs/gtk-3-builder/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": [], + "typeRoots": ["./@types"], + "types": ["@girs/gjs"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -9,8 +10,9 @@ "strictNullChecks": true, "noImplicitThis": true, "alwaysStrict": true, + "allowSyntheticDefaultImports": true, }, - "include": ["global.d.ts", "@types/gjs.d.ts", "@types/ambient.d.ts"], + "include": ["global.d.ts"], "files": [ "main.ts" ] diff --git a/examples/gjs/gtk-3-calc/package.json b/examples/gjs/gtk-3-calc/package.json index 2e481988c..a4dd059f7 100644 --- a/examples/gjs/gtk-3-calc/package.json +++ b/examples/gjs/gtk-3-calc/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-3-calc/tsconfig.json b/examples/gjs/gtk-3-calc/tsconfig.json index de82d12da..d2a598249 100644 --- a/examples/gjs/gtk-3-calc/tsconfig.json +++ b/examples/gjs/gtk-3-calc/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gtk-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-3-editor/main.ts b/examples/gjs/gtk-3-editor/main.ts index db7b92248..524528ddb 100644 --- a/examples/gjs/gtk-3-editor/main.ts +++ b/examples/gjs/gtk-3-editor/main.ts @@ -1,6 +1,7 @@ -import imports from './@types/gjs.js' -import * as Gtk from './@types/gtk-3.0' -import * as GtkSource from './@types/gtksource-3.0' +/// + +import Gtk from './@types/gtk-3.0/gtk-3.0' +import GtkSource from './@types/gtksource-3.0/gtksource-3.0' const { gettext } = imports; Gtk.init(null) diff --git a/examples/gjs/gtk-3-editor/package.json b/examples/gjs/gtk-3-editor/package.json index 2a0961211..f7f53f159 100644 --- a/examples/gjs/gtk-3-editor/package.json +++ b/examples/gjs/gtk-3-editor/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:app && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace", + "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace --outdir=@types", "clear:types": "rm -rf ./@types", "clear:app": "rm -rf ./dist", "clear": "yarn clear:app && yarn clear:types", diff --git a/examples/gjs/gtk-3-editor/tsconfig.json b/examples/gjs/gtk-3-editor/tsconfig.json index 172ffaef9..7d9647262 100644 --- a/examples/gjs/gtk-3-editor/tsconfig.json +++ b/examples/gjs/gtk-3-editor/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": [], "target": "ESNext", "module": "ESNext", "strict": true, @@ -9,6 +8,7 @@ "strictNullChecks": true, "noImplicitThis": true, "alwaysStrict": true, + "allowSyntheticDefaultImports": true, }, "files": [ "main.ts" diff --git a/examples/gjs/gtk-3-gettext/package.json b/examples/gjs/gtk-3-gettext/package.json index 4047fb97e..8efacb297 100644 --- a/examples/gjs/gtk-3-gettext/package.json +++ b/examples/gjs/gtk-3-gettext/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-3-gettext/tsconfig.json b/examples/gjs/gtk-3-gettext/tsconfig.json index de82d12da..b0ee3495b 100644 --- a/examples/gjs/gtk-3-gettext/tsconfig.json +++ b/examples/gjs/gtk-3-gettext/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gtk-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-3-hello-2/main.ts b/examples/gjs/gtk-3-hello-2/main.ts index 9ffe02213..28b151039 100644 --- a/examples/gjs/gtk-3-hello-2/main.ts +++ b/examples/gjs/gtk-3-hello-2/main.ts @@ -3,8 +3,6 @@ // SPDX-FileCopyrightText: 2008 litl, LLC // Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gtk.js -import imports from './@types/gjs.js'; - // Include this in case both GTK3 and GTK4 installed, otherwise an exception // will be thrown imports.gi.versions.Gtk = '3.0'; diff --git a/examples/gjs/gtk-3-hello-2/package.json b/examples/gjs/gtk-3-hello-2/package.json index 6bc8eb193..12279b5ca 100644 --- a/examples/gjs/gtk-3-hello-2/package.json +++ b/examples/gjs/gtk-3-hello-2/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-3-hello-2/tsconfig.json b/examples/gjs/gtk-3-hello-2/tsconfig.json index 15a01fef0..b0ee3495b 100644 --- a/examples/gjs/gtk-3-hello-2/tsconfig.json +++ b/examples/gjs/gtk-3-hello-2/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gtk-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts", "@types/gtk-3.0.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-3-hello/main.ts b/examples/gjs/gtk-3-hello/main.ts index c30421a12..d14071cc1 100644 --- a/examples/gjs/gtk-3-hello/main.ts +++ b/examples/gjs/gtk-3-hello/main.ts @@ -1,5 +1,4 @@ -import './@types/gjs.js' -import * as Gtk from './@types/gtk-3.0.js' +import Gtk from './@types/gtk-3.0/gtk-3.0' Gtk.init(null) diff --git a/examples/gjs/gtk-3-hello/package.json b/examples/gjs/gtk-3-hello/package.json index 48e2d2a9f..ccb84a5be 100644 --- a/examples/gjs/gtk-3-hello/package.json +++ b/examples/gjs/gtk-3-hello/package.json @@ -4,10 +4,11 @@ "description": "", "main": "main.ts", "private": true, + "type": "module", "scripts": { "build": "yarn build:types && yarn build:app", "build:app": "yarn clear:app && webpack --env production", - "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace", + "build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace --outdir=@types", "clear:types": "rm -rf ./@types", "clear:app": "rm -rf ./dist", "clear": "yarn clear:app && yarn clear:types", diff --git a/examples/gjs/gtk-3-hello/tsconfig.json b/examples/gjs/gtk-3-hello/tsconfig.json index 172ffaef9..a675b7a7d 100644 --- a/examples/gjs/gtk-3-hello/tsconfig.json +++ b/examples/gjs/gtk-3-hello/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -9,6 +10,7 @@ "strictNullChecks": true, "noImplicitThis": true, "alwaysStrict": true, + "allowSyntheticDefaultImports": true, }, "files": [ "main.ts" diff --git a/examples/gjs/gtk-3-hello/webpack.config.js b/examples/gjs/gtk-3-hello/webpack.config.cjs similarity index 100% rename from examples/gjs/gtk-3-hello/webpack.config.js rename to examples/gjs/gtk-3-hello/webpack.config.cjs diff --git a/examples/gjs/gtk-3-template/package.json b/examples/gjs/gtk-3-template/package.json index 037c24fda..71d422de0 100644 --- a/examples/gjs/gtk-3-template/package.json +++ b/examples/gjs/gtk-3-template/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-3-template/tsconfig.json b/examples/gjs/gtk-3-template/tsconfig.json index de82d12da..b0ee3495b 100644 --- a/examples/gjs/gtk-3-template/tsconfig.json +++ b/examples/gjs/gtk-3-template/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gtk-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-3-webkit/main.ts b/examples/gjs/gtk-3-webkit/main.ts index 1c1df2d93..7cbf19e91 100644 --- a/examples/gjs/gtk-3-webkit/main.ts +++ b/examples/gjs/gtk-3-webkit/main.ts @@ -3,7 +3,6 @@ // SPDX-FileCopyrightText: 2008 litl, LLC // Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/webkit.js -import './@types/gjs.js'; import Gtk from 'gi://Gtk?version=3.0'; import WebKit from 'gi://WebKit2?version=4.0'; diff --git a/examples/gjs/gtk-3-webkit/package.json b/examples/gjs/gtk-3-webkit/package.json index d9009f8a4..23ed89d54 100644 --- a/examples/gjs/gtk-3-webkit/package.json +++ b/examples/gjs/gtk-3-webkit/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate WebKit2-4.0 --generateAlias", + "build:types": "yarn ts-for-gir generate WebKit2-4.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-3-webkit/tsconfig.json b/examples/gjs/gtk-3-webkit/tsconfig.json index de82d12da..b0ee3495b 100644 --- a/examples/gjs/gtk-3-webkit/tsconfig.json +++ b/examples/gjs/gtk-3-webkit/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gtk-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-4-application/package.json b/examples/gjs/gtk-4-application/package.json index 7a61ef3d2..fcba8b643 100644 --- a/examples/gjs/gtk-4-application/package.json +++ b/examples/gjs/gtk-4-application/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-4-application/tsconfig.json b/examples/gjs/gtk-4-application/tsconfig.json index 18c6dbf89..fc0dbc315 100644 --- a/examples/gjs/gtk-4-application/tsconfig.json +++ b/examples/gjs/gtk-4-application/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gtk-4.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts", "@types/ambient.d.ts", "@types/gio-2.0.d.ts", "@types/glib-2.0.d.ts", "@types/gtk-3.0.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-4-custom-widget/package.json b/examples/gjs/gtk-4-custom-widget/package.json index 01777cc62..b7cd1bf03 100644 --- a/examples/gjs/gtk-4-custom-widget/package.json +++ b/examples/gjs/gtk-4-custom-widget/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 Gdk-4.0 Graphene-1.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-4.0 Gdk-4.0 Graphene-1.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/index.js", diff --git a/examples/gjs/gtk-4-custom-widget/tsconfig.json b/examples/gjs/gtk-4-custom-widget/tsconfig.json index f6ed449e8..91479c666 100644 --- a/examples/gjs/gtk-4-custom-widget/tsconfig.json +++ b/examples/gjs/gtk-4-custom-widget/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gtk-4.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -12,7 +13,6 @@ "alwaysStrict": true, "moduleResolution":"Bundler" }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts"], "files": [ "index.ts" ] diff --git a/examples/gjs/gtk-4-list-store/main.ts b/examples/gjs/gtk-4-list-store/main.ts index 2b70991f4..8b755210c 100644 --- a/examples/gjs/gtk-4-list-store/main.ts +++ b/examples/gjs/gtk-4-list-store/main.ts @@ -4,7 +4,6 @@ * @source https://github.com/optimisme/gjs-examples/blob/master/egList.js */ -import imports from './@types/gjs.js' import GObject from 'gi://GObject?version=2.0'; import GLib from 'gi://GLib?version=2.0'; import Gtk from 'gi://Gtk?version=4.0'; diff --git a/examples/gjs/gtk-4-list-store/package.json b/examples/gjs/gtk-4-list-store/package.json index 5e9e59260..e82db381d 100644 --- a/examples/gjs/gtk-4-list-store/package.json +++ b/examples/gjs/gtk-4-list-store/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-4-list-store/tsconfig.json b/examples/gjs/gtk-4-list-store/tsconfig.json index 27740af42..5adf3ada1 100644 --- a/examples/gjs/gtk-4-list-store/tsconfig.json +++ b/examples/gjs/gtk-4-list-store/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gtk-4.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/gtk-4-template/package.json b/examples/gjs/gtk-4-template/package.json index 89ea3d24d..f5e5df591 100644 --- a/examples/gjs/gtk-4-template/package.json +++ b/examples/gjs/gtk-4-template/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs -m dist/main.js", diff --git a/examples/gjs/gtk-4-template/tsconfig.json b/examples/gjs/gtk-4-template/tsconfig.json index de82d12da..8c7edc4a3 100644 --- a/examples/gjs/gtk-4-template/tsconfig.json +++ b/examples/gjs/gtk-4-template/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gtk-4.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts"], "files": [ "main.ts", ] diff --git a/examples/gjs/run-async/.gitignore b/examples/gjs/run-async/.gitignore deleted file mode 100644 index 1345bf22e..000000000 --- a/examples/gjs/run-async/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Yarn https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions - -!@types/ -@types/gio-2.0/* -!@types/gio-2.0/package.json -@types/gjs/* -!@types/gjs/package.json -@types/glib-2.0/* -!@types/glib-2.0/package.json -@types/gobject-2.0/* -!@types/gobject-2.0/package.json \ No newline at end of file diff --git a/examples/gjs/run-async/.ts-for-girrc.json b/examples/gjs/run-async/.ts-for-girrc.json index 21688bbbd..2e9ed5ccb 100644 --- a/examples/gjs/run-async/.ts-for-girrc.json +++ b/examples/gjs/run-async/.ts-for-girrc.json @@ -1,6 +1,6 @@ { "modules": ["Gio-2.0"], "noNamespace": false, - "outdir": "./@types", + "outdir": "./@types/@girs", "generateAlias": true } \ No newline at end of file diff --git a/examples/gjs/run-async/@types/gio-2.0/package.json b/examples/gjs/run-async/@types/gio-2.0/package.json index 9d3829af1..97c99130d 100644 --- a/examples/gjs/run-async/@types/gio-2.0/package.json +++ b/examples/gjs/run-async/@types/gio-2.0/package.json @@ -23,7 +23,7 @@ "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gio-2.0.d.ts" }, "dependencies": { - "@girs/gjs": "4.0.0", "@girs/gobject-2.0": "*", "@girs/glib-2.0": "*" + "@girs/gjs": "4.0.0" }, "devDependencies": { "typescript": "*" diff --git a/examples/gjs/run-async/@types/glib-2.0/package.json b/examples/gjs/run-async/@types/glib-2.0/package.json index 557547023..e2383d7c8 100644 --- a/examples/gjs/run-async/@types/glib-2.0/package.json +++ b/examples/gjs/run-async/@types/glib-2.0/package.json @@ -23,7 +23,7 @@ "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit glib-2.0.d.ts" }, "dependencies": { - "@girs/gjs": "4.0.0", "@girs/gobject-2.0": "*" + "@girs/gjs": "4.0.0" }, "devDependencies": { "typescript": "*" diff --git a/examples/gjs/run-async/@types/gobject-2.0/package.json b/examples/gjs/run-async/@types/gobject-2.0/package.json index 2db9df9c1..045d8bea8 100644 --- a/examples/gjs/run-async/@types/gobject-2.0/package.json +++ b/examples/gjs/run-async/@types/gobject-2.0/package.json @@ -23,7 +23,7 @@ "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gobject-2.0.d.ts" }, "dependencies": { - "@girs/gjs": "4.0.0", "@girs/glib-2.0": "*" + "@girs/gjs": "4.0.0" }, "devDependencies": { "typescript": "*" diff --git a/examples/gjs/run-async/main.ts b/examples/gjs/run-async/main.ts index 77b1c9132..fd88ca9f4 100644 --- a/examples/gjs/run-async/main.ts +++ b/examples/gjs/run-async/main.ts @@ -8,10 +8,6 @@ * the label should show a translation of 'Print help' */ -import './@types/gjs/gjs'; -import './@types/gjs/dom'; -import './@types/gio-2.0'; - // import Adw from "gi://Adw"; // import GLib from "gi://GLib"; import Gio from "gi://Gio"; diff --git a/examples/gjs/run-async/tsconfig.json b/examples/gjs/run-async/tsconfig.json index 8c0958ff2..86edbe188 100644 --- a/examples/gjs/run-async/tsconfig.json +++ b/examples/gjs/run-async/tsconfig.json @@ -3,17 +3,15 @@ "compilerOptions": { "baseUrl": ".", "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gio-2.0"], + "typeRoots": [ + "./@types" + ], "target": "ESNext", "module": "ESNext", "moduleResolution": "node", "noImplicitAny": true, - "paths": { - // Simulate the node_modules packaging... - "@girs/*": ["./@types/*"] - } }, - "include": ["./@types"], "files": [ "main.ts", ] diff --git a/examples/gjs/soup-3-http/package.json b/examples/gjs/soup-3-http/package.json index 02f1e7772..df0f752f6 100644 --- a/examples/gjs/soup-3-http/package.json +++ b/examples/gjs/soup-3-http/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Soup-3.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Soup-3.0 --generateAlias --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:server": "gjs -m dist/http-server.js", diff --git a/examples/gjs/soup-3-http/tsconfig.json b/examples/gjs/soup-3-http/tsconfig.json index 516172fba..e8f6ea75e 100644 --- a/examples/gjs/soup-3-http/tsconfig.json +++ b/examples/gjs/soup-3-http/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/soup-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "moduleResolution": "Bundler", @@ -14,7 +15,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts"], "files": [ "http-client.ts", "http-server.ts" diff --git a/examples/gjs/soup-3-websocket/client.ts b/examples/gjs/soup-3-websocket/client.ts index d78b8a89a..defc57374 100644 --- a/examples/gjs/soup-3-websocket/client.ts +++ b/examples/gjs/soup-3-websocket/client.ts @@ -7,7 +7,6 @@ // Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/websocket-client.js -import imports from './@types/gjs.js'; import GLib from 'gi://GLib?version=2.0'; import Soup from 'gi://Soup?version=3.0'; import Gio from 'gi://Gio?version=2.0'; diff --git a/examples/gjs/soup-3-websocket/package.json b/examples/gjs/soup-3-websocket/package.json index a62e942ee..e1db696f9 100644 --- a/examples/gjs/soup-3-websocket/package.json +++ b/examples/gjs/soup-3-websocket/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Soup-3.0 --generateAlias", + "build:types": "yarn ts-for-gir generate Soup-3.0 --generateAlias --outdir=@types/@girs", "build:client": "yarn node esbuild.js", "build": "yarn build:types && yarn build:client", "start:client": "gjs -m dist/main.js", diff --git a/examples/gjs/soup-3-websocket/tsconfig.json b/examples/gjs/soup-3-websocket/tsconfig.json index c48863475..a5160232f 100644 --- a/examples/gjs/soup-3-websocket/tsconfig.json +++ b/examples/gjs/soup-3-websocket/tsconfig.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.alias.json", "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/soup-3.0"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -11,7 +12,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts"], "files": [ "client.ts", ] diff --git a/examples/gjs/timers/package.json b/examples/gjs/timers/package.json index 6cc30535f..94988e926 100644 --- a/examples/gjs/timers/package.json +++ b/examples/gjs/timers/package.json @@ -7,7 +7,7 @@ "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 --noNamespace", + "build:types": "yarn ts-for-gir generate Gtk-4.0 --noNamespace --outdir=@types/@girs", "build:app": "yarn node esbuild.js", "build": "yarn build:types && yarn build:app", "start:app": "gjs dist/main.js", diff --git a/examples/gjs/timers/tsconfig.json b/examples/gjs/timers/tsconfig.json index 4c0e84e16..1c2bfe364 100644 --- a/examples/gjs/timers/tsconfig.json +++ b/examples/gjs/timers/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": [], + "types": ["@girs/gjs", "@girs/gjs/dom"], + "typeRoots": ["./@types"], "target": "ESNext", "module": "ESNext", "strict": true, @@ -10,7 +11,6 @@ "noImplicitThis": true, "alwaysStrict": true, }, - "include": ["@types/gjs.d.ts", "@types/dom.d.ts"], "files": [ "main.ts", ] diff --git a/examples/node-gtk/gtk-4-application/esbuild.mjs b/examples/node-gtk/gtk-4-application/esbuild.mjs deleted file mode 100644 index 48d5cbca5..000000000 --- a/examples/node-gtk/gtk-4-application/esbuild.mjs +++ /dev/null @@ -1,14 +0,0 @@ -import { build } from "esbuild"; - -await build({ - entryPoints: ['main.ts'], - outdir: 'dist', - bundle: true, - // target: "firefox60", // Since GJS 1.53.90 - // target: "firefox68", // Since GJS 1.63.90 - target: "firefox78", // Since GJS 1.65.90 - // target: "firefox91", // Since GJS 1.71.1 - format: 'cjs', - platform: 'node', - external: ['node-gtk', 'gi://*', 'resource://*', 'gettext', 'system', 'cairo'], -}) diff --git a/examples/node-gtk/gtk-4-application/main.ts b/examples/node-gtk/gtk-4-application/main.ts deleted file mode 100644 index 337501deb..000000000 --- a/examples/node-gtk/gtk-4-application/main.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Based on https://github.com/romgrk/node-gtk/blob/master/examples/gtk-4.js - -import gi from 'node-gtk'; -import GLib from './@types/node-glib-2.0.js'; -import Gtk from './@types/node-gtk-4.0.js'; - -const printHello = () => console.log('Hello') - -const loop = GLib.MainLoop.new(null, false) -const app = new Gtk.Application('com.github.romgrk.node-gtk.demo', 0) -app.on('activate', onActivate) -const status = app.run([]) - -console.log('Finished with status:', status) - -function onActivate() { - const window = new Gtk.ApplicationWindow(app) - window.setTitle('Window') - window.setDefaultSize(200, 200) - window.on('close-request', onQuit) - - const ui = ` - - - - - vertical - - - 1 - Hello World! - - - - - Action - 1 - - - - - Close - 1 - - - - - ` - - const builder = Gtk.Builder.newFromString(ui, ui.length) - const root = builder.getObject('root') as Gtk.Box; - - const actionButton = builder.getObject('actionButton') - actionButton?.on('clicked', printHello) - - const closeButton = builder.getObject('closeButton') - closeButton?.on('clicked', () => window.close()) - - window.setChild(root) - window.show() - window.present() - - gi.startLoop() - loop.run() -} - -function onQuit() { - loop.quit() - app.quit() - return false -} \ No newline at end of file diff --git a/examples/node-gtk/gtk-4-application/package.json b/examples/node-gtk/gtk-4-application/package.json deleted file mode 100644 index a4934ab5b..000000000 --- a/examples/node-gtk/gtk-4-application/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "ts-for-gir-node-gtk-gtk-4-application-example", - "version": "3.2.8", - "description": "Simple node-gtk Gtk 4 example app to demonstrate how you can use and extend Gtk.Application", - "main": "dist/main.js", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build:types": "yarn ts-for-gir generate Gtk-4.0 -e node", - "build:app": "yarn node esbuild.mjs", - "build": "yarn build:types && yarn build:app", - "start:app": "yarn node dist/main.js", - "debug:app": "GTK_DEBUG=interactive yarn start:app", - "start": "yarn build && yarn start:app", - "validate": "yarn validate:types && yarn validate:app", - "validate:types": "tsc --project tsconfig.types.json", - "validate:app": "tsc --noEmit", - "clear": "rm -rf dist @types" - }, - "author": "Pascal Garber ", - "license": "MIT", - "devDependencies": { - "@ts-for-gir/cli": "workspace:^", - "esbuild": "^0.20.0", - "typescript": "5.2.2" - } -} diff --git a/examples/node-gtk/gtk-4-application/tsconfig.json b/examples/node-gtk/gtk-4-application/tsconfig.json deleted file mode 100644 index 0c8696d6c..000000000 --- a/examples/node-gtk/gtk-4-application/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "types": ["node"], - "target": "ESNext", - "module": "Node16", - "strict": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "noImplicitAny": true, - "strictNullChecks": true, - "noImplicitThis": true, - "alwaysStrict": true, - "moduleResolution":"Node16", - }, - "include": [ - "./@types/node-ambient.d.ts" - ], - "files": [ - "main.ts" - ] -} diff --git a/examples/node-gtk/gtk-4-application/tsconfig.types.json b/examples/node-gtk/gtk-4-application/tsconfig.types.json deleted file mode 100644 index 9f910a243..000000000 --- a/examples/node-gtk/gtk-4-application/tsconfig.types.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true - } -} diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index 029be6218..828001d75 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -74,7 +74,10 @@ export class DependencyManager extends GirNSRegistry { createImportPath(packageName: string): string { const importName = this.transformation.transformImportName(packageName) - const importPath = `${this.config.npmScope}/${importName}` + // TODO: noNamespace is currently a proxy for "no npm packaging" + const importPath = this.config.noNamespace + ? `../${importName}/${importName}` + : `${this.config.npmScope}/${importName}` return importPath } From 0bc641b0375817accab56dab119579a17b43159c Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Tue, 12 Mar 2024 04:30:13 -0700 Subject: [PATCH 42/53] typescript: Fix generating interfaces and signal types --- .../src/type-definition-generator.ts | 160 ++++++++++++------ 1 file changed, 111 insertions(+), 49 deletions(-) diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 0874cac3f..0e7f1ff53 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -369,9 +369,10 @@ class ModuleGenerator extends FormatGenerator { desc.push(...this.addGirDocComment(tsProp.doc, [], indentCount)) const indent = generateIndent(indentCount) - const varDesc = this.generateVariable(tsProp, 0) + const name = this.generateMemberName(tsProp) const staticStr = isStatic ? 'static ' : '' const readonly = !tsProp.writable ? 'readonly ' : '' + const affix = tsProp.optional ? '?' : '' // temporary solution, will be solved differently later let commentOut = '' @@ -385,7 +386,9 @@ class ModuleGenerator extends FormatGenerator { type = new BinaryType(type.unwrap(), AnyType) } - desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`) + const typeStr = this.generateTypes(type) + + desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr}`) return desc } @@ -463,23 +466,6 @@ class ModuleGenerator extends FormatGenerator { return `${ComputedName}` } - generateVariable(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField, indentCount = 0) { - const indent = generateIndent(indentCount) - // Constants are not optional - const optional = false - - const ComputedName = this.generateMemberName(tsVar) - - const affix = optional ? '?' : '' - const typeStr = this.generateTypes(tsVar.type) - - // temporary solution, will be solved differently later - // TODO: const commentOut = allowCommentOut && tsVar.hasUnresolvedConflict ? '// Has conflict: ' : '' - const commentOut = '' - - return `${indent}${commentOut}${ComputedName}${affix}: ${typeStr}` - } - generateType(tsType: TypeExpression) { return tsType.print(this.namespace, this.config) } @@ -967,14 +953,15 @@ class ModuleGenerator extends FormatGenerator { generateConst(tsConst: IntrospectedConstant, indentCount = 0) { const desc: string[] = [] - // if (!tsConst.hasUnresolvedConflict) { desc.push(...this.addGirDocComment(tsConst.doc, [], indentCount)) - // } const indent = generateIndent(indentCount) const exp = !this.config.noNamespace ? '' : 'export ' - const varDesc = this.generateVariable(tsConst, 0) - desc.push(`${indent}${exp}const ${varDesc}`) + + const ComputedName = this.generateMemberName(tsConst) + const typeStr = this.generateTypes(tsConst.type) + + desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr}`) return desc } @@ -1011,7 +998,11 @@ class ModuleGenerator extends FormatGenerator { ) { const def: string[] = [] - if (!girClass.someParent((p: IntrospectedBaseClass) => p.namespace.name === 'GObject' && p.name === 'Object')) { + const isGObjectObject = girClass.name === 'Object' && girClass.namespace.name === 'GObject' + if ( + !isGObjectObject && + !girClass.someParent((p: IntrospectedBaseClass) => p.namespace.name === 'GObject' && p.name === 'Object') + ) { return def } @@ -1020,32 +1011,47 @@ class ModuleGenerator extends FormatGenerator { let ext = '' const resolution = girClass.resolveParents() const superType = resolution.extends() + const superTypes = superType ? [superType] : [] // Remove namespace and class module name const constructPropInterfaceName = `ConstructorProps` // Only add the "extends" if the parent type will be generated (it has props)... - if (superType && superType.node.props.length > 0) { - ext = `extends ${superType.node.getType().print(this.namespace, this.config)}.${constructPropInterfaceName}` + if (superType) { + ext = `extends ${superTypes.map((superType) => `${superType.node.getType().print(this.namespace, this.config)}.${constructPropInterfaceName}`).join(', ')}` } def.push(...this.addInfoComment('Constructor properties interface', indentCount)) + // TODO: Clean this up better, we may want to introduce interfaces + // also having construct property interfaces... + + // Include properties from parent interfaces... + const props = + 'implements' in resolution + ? [...resolution.implements().flatMap((iface) => iface.node.props), ...girClass.props] + : [...girClass.props] + const deduplicatedProps = [ + ...props + .reduce((prev, next) => { + prev.set(next.name, next) + + return prev + }, new Map()) + .values(), + ] + // START BODY - if (!girClass.mainConstructor) { - const ConstructorProps = filterConflicts( - girClass.namespace, - girClass, - // TODO: Include properties from interface parents too. - girClass.props, - ) - .flatMap((v) => v.asString(this, true)) - .join('\n ') - def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext} {`) - def.push(ConstructorProps) - def.push(`${indent}}`, '') - } + // TODO: Is filtering here correct if we're already "filtering" above? + const ConstructorProps = filterConflicts(girClass.namespace, girClass, deduplicatedProps, FilterBehavior.DELETE) + .flatMap((v) => v.asString(this, true)) + .join('\n ') + + def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext} {`) + def.push(ConstructorProps) + def.push(`${indent}}`, '') + // END BODY return def @@ -1059,7 +1065,11 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateFields( - girClass.fields.filter((field) => field.isStatic), + filterConflicts( + girClass.namespace, + girClass, + girClass.fields.filter((field) => field.isStatic), + ), `Static fields of ${girClass.namespace.namespace}.${girClass.name}`, indentCount, ), @@ -1076,7 +1086,11 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateFields( - girClass.fields.filter((field) => !field.isStatic), + filterConflicts( + girClass.namespace, + girClass, + girClass.fields.filter((field) => !field.isStatic), + ), `Own fields of ${girClass.namespace.namespace}.${girClass.name}`, indentCount, ), @@ -1101,7 +1115,7 @@ class ModuleGenerator extends FormatGenerator { def.push( ...this.generateProperties( - girClass.props, + filterConflicts(girClass.namespace, girClass, girClass.props), `Own properties of ${girClass.namespace.namespace}.${girClass.name}`, indentCount, ), @@ -1216,11 +1230,7 @@ class ModuleGenerator extends FormatGenerator { generateClassSignalInterfaces(girClass: IntrospectedClass, indentCount = 0) { const def: string[] = [] - if (!girClass) { - throw new Error(NO_TSDATA('generateClassSignalInterface')) - } - - const tsSignals = girClass.signals.map((signal) => signal).filter((signal) => !!signal) + const tsSignals = girClass.signals def.push( ...this.generateCallbackInterfaces( @@ -1362,7 +1372,7 @@ class ModuleGenerator extends FormatGenerator { const exp = !this.config.noNamespace ? '' : 'export ' - if ('signals' in girClass) { + if (girClass instanceof IntrospectedClass) { // Signal interfaces bodyDef.push(...this.generateClassSignalInterfaces(girClass, indentCount + 1)) } @@ -1444,6 +1454,7 @@ class ModuleGenerator extends FormatGenerator { protected extends(node: IntrospectedBaseClass) { const { namespace: ns, options } = this + if (node.superType) { const ResolvedType = node.superType.resolveIdentifier(ns, options) const Type = ResolvedType?.print(ns, options) @@ -1460,6 +1471,33 @@ class ModuleGenerator extends FormatGenerator { return '' } + protected implements(node: IntrospectedClass) { + const { namespace, options } = this + + const interfaces = node.interfaces.map((i) => { + const identifier = i.resolveIdentifier(namespace, options) + + if (!identifier) { + throw new Error( + `Unable to resolve type: ${i.name} from ${i.namespace} in ${node.namespace.name} ${node.namespace.version}`, + ) + } + + return identifier + }) + + if (interfaces.length > 0) { + return ` implements ${interfaces + .map((i) => { + const Type = i.print(namespace, options) + return `${Type}` + }) + .join(', ')}` + } + + return '' + } + /** * Represents a record, GObject class or interface as a Typescript class * @param girClass @@ -1477,7 +1515,8 @@ class ModuleGenerator extends FormatGenerator { const genericParameters = this.generateGenericParameters(girClass.generics) const ext = this.extends(girClass) - const classHead = `${girClass.name}${genericParameters}${ext}` + const impl = girClass instanceof IntrospectedClass ? this.implements(girClass) : '' + const classHead = `${girClass.name}${genericParameters}${ext}${impl}` // START CLASS { @@ -1508,6 +1547,29 @@ class ModuleGenerator extends FormatGenerator { // Static Methods def.push(...this.generateClassMethods(girClass)) + + if (girClass instanceof IntrospectedClass) { + const implementedProperties = girClass.implementedProperties() + const implementedMethods = girClass.implementedMethods(implementedProperties) + + const generatedImplementedProperties = filterConflicts( + girClass.namespace, + girClass, + implementedProperties, + ).flatMap((m) => m.asString(this)) + + def.push(...generatedImplementedProperties) + + const filteredImplMethods = filterFunctionConflict( + girClass.namespace, + girClass, + implementedMethods, + [], + ) + const generatedImplementedMethods = filteredImplMethods.flatMap((m) => m.asString(this)) + + def.push(...generatedImplementedMethods) + } } // END BODY From c2db1cf62ec0e28c939725ebfdb312706c4ca7e6 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:50:57 -0700 Subject: [PATCH 43/53] lib: Workaround broken namespace name in Tracker 1 --- packages/lib/src/gir.ts | 4 ++-- packages/lib/src/gir/util.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/lib/src/gir.ts b/packages/lib/src/gir.ts index fedff37f1..0c8078304 100644 --- a/packages/lib/src/gir.ts +++ b/packages/lib/src/gir.ts @@ -1,7 +1,7 @@ import { IntrospectedNamespace } from './gir/namespace.js' import { IntrospectedProperty, IntrospectedField } from './gir/property.js' import { GenerationOptions } from './types.js' -import { sanitizeIdentifierName } from './gir/util.js' +import { sanitizeIdentifierName, sanitizeNamespace } from './gir/util.js' export { sanitizeMemberName, isInvalid } from './gir/util.js' @@ -66,7 +66,7 @@ export class TypeIdentifier extends TypeExpression { * invalid names such as "3gppProfile" */ sanitize() { - return new TypeIdentifier(sanitizeIdentifierName(this.namespace, this.name), this.namespace) + return new TypeIdentifier(sanitizeIdentifierName(this.namespace, this.name), sanitizeNamespace(this.namespace)) } protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { diff --git a/packages/lib/src/gir/util.ts b/packages/lib/src/gir/util.ts index f5ba7d2a9..2ba66553e 100644 --- a/packages/lib/src/gir/util.ts +++ b/packages/lib/src/gir/util.ts @@ -333,6 +333,16 @@ export function sanitizeIdentifierName(namespace: string | null, name: string): return sanitized_name; } +// TODO: Until we support resolving via c:type, fix GIRs with +// broken namespacing... +export function sanitizeNamespace(namespace: string): string { + if (namespace === "Tracker_Vala") { + return "Tracker"; + } + + return namespace; +} + export function sanitizeMemberName(name: string): string { // This is a unique case where the name is "empty". if (name === "") { From 316438d7d27849a546a164a69f5ae12cc266a029 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:51:23 -0700 Subject: [PATCH 44/53] lib: Add injection workarounds for broken types --- packages/lib/src/injections/gee08.ts | 89 +++++++++++++++++++++++++ packages/lib/src/injections/gee1.ts | 35 ++++++++++ packages/lib/src/injections/inject.ts | 22 ++++-- packages/lib/src/injections/tracker1.ts | 41 ++++++++++++ 4 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 packages/lib/src/injections/gee08.ts create mode 100644 packages/lib/src/injections/gee1.ts create mode 100644 packages/lib/src/injections/tracker1.ts diff --git a/packages/lib/src/injections/gee08.ts b/packages/lib/src/injections/gee08.ts new file mode 100644 index 000000000..235a09036 --- /dev/null +++ b/packages/lib/src/injections/gee08.ts @@ -0,0 +1,89 @@ +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { IntrospectedProperty } from "../index.js"; + +export default { + namespace: "Gee", + version: "0.8", + modifier(namespace: IntrospectedNamespace) { + const SortedMap = namespace.assertClass("SortedMap"); + const AbstractSortedMap = namespace.assertClass("AbstractSortedMap"); + + if (SortedMap.props.some(prop => prop.name === "readOnlyView")) + AbstractSortedMap.props.push( + new IntrospectedProperty({ + name: "readOnlyView", + type: AbstractSortedMap.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: AbstractSortedMap + }) + ); + + if (SortedMap.props.some(prop => prop.name === "read_only_view")) + AbstractSortedMap.props.push( + new IntrospectedProperty({ + name: "read_only_view", + type: AbstractSortedMap.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: AbstractSortedMap + }) + ); + + const AbstractList = namespace.assertClass("AbstractList"); + const LinkedList = namespace.assertClass("LinkedList"); + + if (AbstractList.props.some(prop => prop.name === "readOnlyView")) + LinkedList.props.push( + new IntrospectedProperty({ + name: "readOnlyView", + type: LinkedList.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: LinkedList + }) + ); + + if (AbstractList.props.some(prop => prop.name === "read_only_view")) + LinkedList.props.push( + new IntrospectedProperty({ + name: "read_only_view", + type: LinkedList.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: LinkedList + }) + ); + + const AbstractBidirList = namespace.assertClass("AbstractBidirList"); + const UnrolledLinkedList = namespace.assertClass("UnrolledLinkedList"); + + if (AbstractBidirList.props.some(prop => prop.name === "readOnlyView")) + UnrolledLinkedList.props.push( + new IntrospectedProperty({ + name: "readOnlyView", + type: UnrolledLinkedList.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: UnrolledLinkedList + }) + ); + + if (AbstractBidirList.props.some(prop => prop.name === "read_only_view")) + UnrolledLinkedList.props.push( + new IntrospectedProperty({ + name: "read_only_view", + type: UnrolledLinkedList.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: UnrolledLinkedList + }) + ); + } +}; diff --git a/packages/lib/src/injections/gee1.ts b/packages/lib/src/injections/gee1.ts new file mode 100644 index 000000000..98ae2dc6c --- /dev/null +++ b/packages/lib/src/injections/gee1.ts @@ -0,0 +1,35 @@ +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { IntrospectedProperty } from "../index.js"; + +export default { + namespace: "Gee", + version: "1.0", + modifier(namespace: IntrospectedNamespace) { + const AbstractList = namespace.assertClass("AbstractList"); + const LinkedList = namespace.assertClass("LinkedList"); + + if (AbstractList.props.some(prop => prop.name === "readOnlyView")) + LinkedList.props.push( + new IntrospectedProperty({ + name: "readOnlyView", + type: LinkedList.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: LinkedList + }) + ); + + if (AbstractList.props.some(prop => prop.name === "read_only_view")) + LinkedList.props.push( + new IntrospectedProperty({ + name: "read_only_view", + type: LinkedList.getType(), + readable: true, + writable: false, + constructOnly: false, + parent: LinkedList + }) + ); + } +}; diff --git a/packages/lib/src/injections/inject.ts b/packages/lib/src/injections/inject.ts index 91d85b340..4fc2f0e85 100644 --- a/packages/lib/src/injections/inject.ts +++ b/packages/lib/src/injections/inject.ts @@ -1,17 +1,25 @@ import glib from "./glib.js"; import gobject from "./gobject.js"; import gio from "./gio.js"; - +import tracker1 from "./tracker1.js"; +import gee08 from "./gee08.js"; +import gee1 from "./gee1.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; import { NSRegistry } from "../gir/registry.js"; export type NamespaceInjection = (namespace: IntrospectedNamespace, registry: NSRegistry) => void; -function injectDefinitions(registry: NSRegistry) { +function injectDefinitions(registry: NSRegistry, required = true) { return (definition: { namespace: string; version: string; modifier: NamespaceInjection }) => { - const ns = registry.assertNamespace(definition.namespace, definition.version); + const ns = registry.namespace(definition.namespace, definition.version); + + if (required && !ns) { + throw new Error(`Namespace '${definition.namespace}' not found.`); + } - definition.modifier(ns, registry); + if (ns) { + definition.modifier(ns, registry); + } }; } @@ -21,4 +29,10 @@ export function inject(registry: NSRegistry) { $(glib); $(gobject); $(gio); + + const $_ = injectDefinitions(registry, false); + + $_(tracker1); + $_(gee08); + $_(gee1); } diff --git a/packages/lib/src/injections/tracker1.ts b/packages/lib/src/injections/tracker1.ts new file mode 100644 index 000000000..1721259b1 --- /dev/null +++ b/packages/lib/src/injections/tracker1.ts @@ -0,0 +1,41 @@ +import { IntrospectedNamespace } from "../gir/namespace.js"; +import { ClassStructTypeIdentifier, IntrospectedRecord } from "../index.js"; + +export default { + namespace: "Tracker", + version: "1.0", + modifier(namespace: IntrospectedNamespace) { + const SparqlError = namespace.getEnum("Error"); + + if (!SparqlError) throw new Error("Error enum not found in Tracker."); + + namespace.members.delete("Error"); + + SparqlError.name = "SparqlError"; + + namespace.members.set("SparqlError", SparqlError); + + // Hack around broken references in Tracker + + const CursorClass = namespace.members.get("SparqlCursorClass"); + + if (CursorClass instanceof IntrospectedRecord) { + // @ts-expect-error This is a private property by Tracker is cursed + CursorClass._structFor = new ClassStructTypeIdentifier("SparqlCursor", "Tracker"); + } + + const ConnectionClass = namespace.members.get("SparqlConnectionClass"); + + if (ConnectionClass instanceof IntrospectedRecord) { + // @ts-expect-error This is a private property by Tracker is cursed + ConnectionClass._structFor = new ClassStructTypeIdentifier("SparqlConnection", "Tracker"); + } + + const BuilderClass = namespace.members.get("SparqlBuilderClass"); + + if (BuilderClass instanceof IntrospectedRecord) { + // @ts-expect-error This is a private property by Tracker is cursed + BuilderClass._structFor = new ClassStructTypeIdentifier("SparqlBuilder", "Tracker"); + } + } +}; From e609ef31c6654b3451e5baa804614439964760ae Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:52:06 -0700 Subject: [PATCH 45/53] lib: Apply generics to all St, Mutter, and Clutter versions --- packages/lib/src/generics/clutter.ts | 10 ++++++-- packages/lib/src/generics/generify.ts | 37 +++++++++++++++------------ packages/lib/src/generics/meta.ts | 10 ++++++-- packages/lib/src/generics/st.ts | 10 +++++--- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/packages/lib/src/generics/clutter.ts b/packages/lib/src/generics/clutter.ts index 247066395..015bd1d9f 100644 --- a/packages/lib/src/generics/clutter.ts +++ b/packages/lib/src/generics/clutter.ts @@ -1,8 +1,9 @@ import { GenericType } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; -export default { +export const clutterTemplate = (version: string) => ({ namespace: "Clutter", + version, modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { if (!inferGenerics) { return; @@ -50,4 +51,9 @@ export default { prop.type = new GenericType("A", Content.getType()); }); } -}; +}); + +export const clutter10 = clutterTemplate("10"); +export const clutter11 = clutterTemplate("11"); +export const clutter12 = clutterTemplate("12"); +export const clutter13 = clutterTemplate("13"); diff --git a/packages/lib/src/generics/generify.ts b/packages/lib/src/generics/generify.ts index 821b319ad..52d0a833f 100644 --- a/packages/lib/src/generics/generify.ts +++ b/packages/lib/src/generics/generify.ts @@ -1,8 +1,8 @@ import gio from "./gio.js"; import glib from "./glib.js"; -import clutter from "./clutter.js"; -import st from "./st.js"; -import meta from "./meta.js"; +import { clutter10, clutter11, clutter12, clutter13 } from "./clutter.js"; +import { st1, st12, st13 } from "./st.js"; +import { meta10, meta11, meta12, meta13 } from "./meta.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; import { NSRegistry } from "../gir/registry.js"; @@ -11,20 +11,17 @@ import { GenericVisitor } from "./visitor.js"; type NamespaceModifier = (namespace: IntrospectedNamespace, inferGenerics: boolean) => void; function generifyDefinitions(registry: NSRegistry, inferGenerics: boolean, required: boolean = true) { - return (definition: { namespace: string; version?: string; modifier: NamespaceModifier }) => { - const version = definition?.version ?? registry.defaultVersionOf(definition.namespace); + return (definition: { namespace: string; version: string; modifier: NamespaceModifier }) => { + const version = definition.version; + const ns = registry.namespace(definition.namespace, version); - if (version) { - const ns = registry.namespace(definition.namespace, version); - - if (ns) { - definition.modifier(ns, inferGenerics); - return; - } + if (ns) { + definition.modifier(ns, inferGenerics); + return; } if (required) { - console.error(`Failed to generify ${definition.namespace}`); + throw new Error(`Could not generify ${definition.namespace} ${definition.version}`); } }; } @@ -37,9 +34,17 @@ export function generify(registry: NSRegistry, inferGenerics: boolean) { const $_ = generifyDefinitions(registry, inferGenerics, false); - $_(clutter); - $_(st); - $_(meta); + $_(clutter10); + $_(clutter11); + $_(clutter12); + $_(clutter13); + $_(st1); + $_(st12); + $_(st13); + $_(meta10); + $_(meta11); + $_(meta12); + $_(meta13); const visitor = new GenericVisitor(registry, inferGenerics); diff --git a/packages/lib/src/generics/meta.ts b/packages/lib/src/generics/meta.ts index 5cbb63c8f..18899fadf 100644 --- a/packages/lib/src/generics/meta.ts +++ b/packages/lib/src/generics/meta.ts @@ -1,8 +1,9 @@ import { GenerifiedTypeIdentifier } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; -export default { +const metaTemplate = (version: string) => ({ namespace: "Meta", + version, modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { if (!inferGenerics) { return; @@ -24,4 +25,9 @@ export default { ]); } } -}; +}); + +export const meta10 = metaTemplate("10"); +export const meta11 = metaTemplate("11"); +export const meta12 = metaTemplate("12"); +export const meta13 = metaTemplate("13"); diff --git a/packages/lib/src/generics/st.ts b/packages/lib/src/generics/st.ts index ec150e07c..7765e88b6 100644 --- a/packages/lib/src/generics/st.ts +++ b/packages/lib/src/generics/st.ts @@ -1,9 +1,9 @@ import { GenericType, GenerifiedTypeIdentifier } from "../gir.js"; import { IntrospectedNamespace } from "../gir/namespace.js"; -export default { +const stTemplate = (version: string) => ({ namespace: "St", - version: "1.0", + version, modifier: (namespace: IntrospectedNamespace, inferGenerics: boolean) => { if (!inferGenerics) { return; @@ -109,4 +109,8 @@ export default { prop.type = new GenericType("A", Actor.getType()); }); } -}; +}); + +export const st1 = stTemplate("1.0"); +export const st12 = stTemplate("12"); +export const st13 = stTemplate("13"); From 1a6847a91a4df990fb480bb3ec414e428664b052 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:53:02 -0700 Subject: [PATCH 46/53] typescript: Update workaround templates for type changes --- .../templates/gjs/gobject-2.0.d.ts | 22 ++----------------- .../templates/granite-1.0.d.ts | 2 +- .../templates/granite-7.0.d.ts | 2 +- .../templates/gstbase-0.10.d.ts | 2 +- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/gobject-2.0.d.ts b/packages/generator-typescript/templates/gjs/gobject-2.0.d.ts index a5519d993..f5ccf87fb 100644 --- a/packages/generator-typescript/templates/gjs/gobject-2.0.d.ts +++ b/packages/generator-typescript/templates/gjs/gobject-2.0.d.ts @@ -192,26 +192,8 @@ export function signal_handlers_unblock_by_func(instance: Object, func: (...args export function signal_handlers_disconnect_by_func(instance: Object, func: (...args: any[]) => any): number; export function signal_handlers_disconnect_by_data(): void; -export type Property = K extends ParamSpecBoolean - ? boolean - : K extends ParamSpecDouble | ParamSpecInt | ParamSpecUInt | ParamSpecFloat | ParamSpecLong - ? number - : K extends ParamSpecInt64 | ParamSpecUInt64 | ParamSpecULong - ? number - : K extends ParamSpecFlags - ? number - : K extends ParamSpecString | ParamSpecUnichar - ? string - : K extends ParamSpecValueArray - ? any[] - : K extends ParamSpecObject // TODO?: - ? ParamSpecObject // T - : K extends ParamSpecEnum // TODO?: - ? ParamSpecEnum // E - : K extends ParamSpecBoxed // TODO?: - ? ParamSpecBoxed //B - : K extends ParamSpecVariant - ? GLib.Variant +export type Property = K extends ParamSpec + ? T : any; // TODO: What about the generated class Closure diff --git a/packages/generator-typescript/templates/granite-1.0.d.ts b/packages/generator-typescript/templates/granite-1.0.d.ts index 7f0647c3c..2d76ed4b8 100644 --- a/packages/generator-typescript/templates/granite-1.0.d.ts +++ b/packages/generator-typescript/templates/granite-1.0.d.ts @@ -1,7 +1,7 @@ // Workaround /** @ignore */ export module GraniteServicesSettingsSerializable { - export interface ConstructorProperties extends ServicesSettingsSerializable.ConstructorProperties {} + export interface ConstructorProps extends ServicesSettingsSerializable.ConstructorProps {} } /** @ignore */ export interface GraniteServicesSettingsSerializable extends ServicesSettingsSerializable {} \ No newline at end of file diff --git a/packages/generator-typescript/templates/granite-7.0.d.ts b/packages/generator-typescript/templates/granite-7.0.d.ts index 7f0647c3c..2d76ed4b8 100644 --- a/packages/generator-typescript/templates/granite-7.0.d.ts +++ b/packages/generator-typescript/templates/granite-7.0.d.ts @@ -1,7 +1,7 @@ // Workaround /** @ignore */ export module GraniteServicesSettingsSerializable { - export interface ConstructorProperties extends ServicesSettingsSerializable.ConstructorProperties {} + export interface ConstructorProps extends ServicesSettingsSerializable.ConstructorProps {} } /** @ignore */ export interface GraniteServicesSettingsSerializable extends ServicesSettingsSerializable {} \ No newline at end of file diff --git a/packages/generator-typescript/templates/gstbase-0.10.d.ts b/packages/generator-typescript/templates/gstbase-0.10.d.ts index 7fd1f25d3..735254f41 100644 --- a/packages/generator-typescript/templates/gstbase-0.10.d.ts +++ b/packages/generator-typescript/templates/gstbase-0.10.d.ts @@ -1,5 +1,5 @@ // Workaround /** @ignore */ export module BaseSink { - export type ConstructorProperties = Gst.BaseSink.ConstructorProperties; + export type ConstructorProps = Gst.BaseSink.ConstructorProps; } From b39e9f28fd1376a87fb282934779dda99776be59 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:53:19 -0700 Subject: [PATCH 47/53] parser: Update XML definition for GIR files --- packages/parser/src/xml.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/parser/src/xml.ts b/packages/parser/src/xml.ts index 57d770f40..4ce6b53f3 100644 --- a/packages/parser/src/xml.ts +++ b/packages/parser/src/xml.ts @@ -233,9 +233,20 @@ export interface GirRecordElement extends GirInfoElements { name: string; /** Corresponding C type of the record */ "c:type"?: string; - /** Binary attribute to tell if the record is disguised, i.e. whether the c:type is a typedef that doesn't look like a pointer, but is one internally */ - /** Its second meaning is "private" and is set when any typedef struct is parsed which doesn't also include a full struct with fields (https://gitlab.gnome.org/GNOME/gobject-introspection/issues/101) */ + /** + * @deprecated + * + * Binary attribute to tell if the record is disguised, i.e. whether the c:type + * is a typedef that doesn't look like a pointer, but is one internally. Its second meaning + * is "private" and is set when any typedef struct is parsed which doesn't also include a + * full struct with fields (https://gitlab.gnome.org/GNOME/gobject-introspection/issues/101) + * Replaced by "opaque" and "pointer". + */ disguised?: GirBoolean; + /** Binary attribute for a typedef struct that does not have a corresponding public structure definition */ + opaque?: GirBoolean; + /** Binary attribute for a typedef struct pointer, e.g. typedef struct Foo* FooPtr */ + pointer?: GirBoolean; /** GObject compatible C type of the record */ "glib:type-name"?: string; /** Function to get the GObject compatible type of the record */ From d81a40da16ad2a18c45e9db871debcc86f234ebe Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:53:39 -0700 Subject: [PATCH 48/53] lib: Filter reserved object keys like constructor --- packages/lib/src/validators/class.ts | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/lib/src/validators/class.ts b/packages/lib/src/validators/class.ts index 6f7b49eb4..24b200f09 100644 --- a/packages/lib/src/validators/class.ts +++ b/packages/lib/src/validators/class.ts @@ -31,6 +31,28 @@ const filterProtectedFields = (node: T): T => { return node; }; +/** + * Filters fields, properties, and members to ensure they are not named + * after reserved object keys (prototype, constructor) + */ +const filterReservedProperties = (node: T): T => { + const set = new Set(["prototype", "constructor"]); + + node.fields = node.fields.filter(f => { + return !set.has(f.name); + }); + + node.props = node.props.filter(p => { + return !set.has(p.name); + }); + + node.members = node.members.filter(m => { + return !set.has(m.name); + }); + + return node; +}; + const filterConflictingNamedClassMembers = (node: T): T => { // Props shadow members node.members = node.members.filter(m => { @@ -269,10 +291,12 @@ export class ClassVisitor extends GirVisitor { mergeStaticDefinitions, filterConflictingNamedClassMembers, filterIntrospectableClassMembers, - filterProtectedFields + filterProtectedFields, + filterReservedProperties ); - visitInterface = (node: IntrospectedInterface) => chainVisitors(node, filterIntrospectableClassMembers); + visitInterface = (node: IntrospectedInterface) => + chainVisitors(node, filterIntrospectableClassMembers, filterReservedProperties); visitRecord = (node: IntrospectedRecord) => chainVisitors( @@ -284,6 +308,7 @@ export class ClassVisitor extends GirVisitor { removePrivateFields, filterConflictingNamedClassMembers, filterIntrospectableClassMembers, - filterProtectedFields + filterProtectedFields, + filterReservedProperties ); } From 373f257a86260bb35400f9a86fc7527dcc16c720 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:53:54 -0700 Subject: [PATCH 49/53] lib: Add additional primitive numeric types --- packages/lib/src/gir/util.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/gir/util.ts b/packages/lib/src/gir/util.ts index 2ba66553e..73fd2fcad 100644 --- a/packages/lib/src/gir/util.ts +++ b/packages/lib/src/gir/util.ts @@ -474,9 +474,19 @@ export function resolvePrimitiveType(name: string): TypeExpression | null { case "none": return VoidType; // TODO Some libraries are bad and don't use g-prefixed numerical types + case "uint": + case "int": + case "uint8": + case "int8": + case "uint16": + case "int16": case "uint32": case "int32": + case "int64": + case "uint64": case "double": + case "long": + case "float": // Most libraries will use these though: case "gshort": case "guint32": @@ -498,7 +508,6 @@ export function resolvePrimitiveType(name: string): TypeExpression | null { case "gdouble": case "gssize": case "gsize": - case "long": return NumberType; case "gboolean": return BooleanType; From b24b84a1bb7d32147d61750066d2c2649cd4f6ed Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:54:45 -0700 Subject: [PATCH 50/53] lib: Fix c:prefixes for namespaces and remove unused gi.ts code --- packages/lib/src/gir-module.ts | 48 +++++++++++++++- packages/lib/src/gir/registry.ts | 96 ++++---------------------------- 2 files changed, 56 insertions(+), 88 deletions(-) diff --git a/packages/lib/src/gir-module.ts b/packages/lib/src/gir-module.ts index b5558fe9c..6ffe0fb3a 100644 --- a/packages/lib/src/gir-module.ts +++ b/packages/lib/src/gir-module.ts @@ -78,6 +78,8 @@ export class GirModule { importName!: string + prefixes: string[] = [] + /** * The version of the library as an object. * E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`' @@ -464,6 +466,39 @@ export class GirModule { const dep = this.dependencies.find((dep) => dep.namespace === name) ?? this.transitiveDependencies.find((dep) => dep.namespace === name) + + // Handle finding imports via their other prefixes + if (!dep) { + this.log.info(`Failed to find namespace ${name} in dependencies, resolving via c:prefixes`) + + // TODO: It might make more sense to move this conversion _before_ + // the _getImport call. + const resolvedNamespaces = this.dependencyManager.namespacesForPrefix(name) + if (resolvedNamespaces.length > 0) { + this.log.info( + `Found namespaces for prefix ${name}: ${resolvedNamespaces.map((r) => `${r.name} (${r.version})`).join(', ')}`, + ) + } + + for (const resolvedNamespace of resolvedNamespaces) { + if (resolvedNamespace.name === this.name && resolvedNamespace.version === this.version) { + return this + } + + const dep = + this.dependencies.find( + (dep) => dep.namespace === resolvedNamespace.name && dep.version === resolvedNamespace.version, + ) ?? + this.transitiveDependencies.find( + (dep) => dep.namespace === resolvedNamespace.name && dep.version === resolvedNamespace.version, + ) + + if (dep) { + return this.parent.namespace(resolvedNamespace.name, dep.version) + } + } + } + let version = dep?.version if (!version) { @@ -650,7 +685,7 @@ export class GirModule { throw new Error('Invalid GIR file: no version name specified.') } - const c_prefix = ns.$?.['c:symbol-prefixes']?.split(',') ?? [] + const c_prefix = ns.$?.['c:identifier-prefixes']?.split(',') ?? [] if (options.verbose) { console.debug(`Parsing ${modName}...`) @@ -660,7 +695,16 @@ export class GirModule { building.parent = registry // Set the namespace object here to prevent re-parsing the namespace if // another namespace imports it. - registry.mapping.set(modName, version, building) + registry.register(building) + + const prefixes = repo.repository[0]?.$?.['c:identifier-prefixes']?.split(',') + const unknownPrefixes = prefixes?.filter((pre) => pre !== modName) + + if (unknownPrefixes && unknownPrefixes.length > 0) { + console.log(`Found additional prefixes for ${modName}: ${unknownPrefixes.join(', ')}`) + + building.prefixes.push(...unknownPrefixes) + } const importConflicts = (el: IntrospectedConstant | IntrospectedBaseClass | IntrospectedFunction) => { return !building.hasImport(el.name) diff --git a/packages/lib/src/gir/registry.ts b/packages/lib/src/gir/registry.ts index dbfb1a877..224ea69aa 100644 --- a/packages/lib/src/gir/registry.ts +++ b/packages/lib/src/gir/registry.ts @@ -6,7 +6,7 @@ import { JsonGenerator } from "../generators/json.js"; import { FormatGenerator } from "../generators/generator.js"; import { generify } from "../generics/generify.js"; import { inject } from "../injections/inject.js"; -import { GenerationOptions, LoadOptions, TransformOptions } from "../types.js"; +import { GenerationOptions, TransformOptions } from "../types.js"; import { TwoKeyMap } from "../util.js"; import { ClassVisitor } from "../validators/class.js"; import { InterfaceVisitor } from "../validators/interface.js"; @@ -15,7 +15,7 @@ import { IntrospectedNamespace } from "./namespace.js"; import { DtsModuleGenerator } from "../generators/dts-modules.js"; import { DtsInlineGenerator } from "../generators/dts-inline.js"; import { ParsedGir } from "../types/parsed-gir.js"; -import { GenerateConfig } from "../types/generate-config.js"; +import { GirModule } from "../index.js"; export interface NSLoader { load(namespace: string, version: string): ParsedGir | null; @@ -31,9 +31,8 @@ export class NSRegistry { mapping: TwoKeyMap = new TwoKeyMap(); private formatters: Map = new Map(); private generators: Map> = new Map(); - c_mapping: Map = new Map(); + c_mapping: Map = new Map(); transformations: GirVisitor[] = []; - loaders: [NSLoader, LoadOptions][] = []; subtypes = new TwoKeyMap>(); constructor() { @@ -128,15 +127,13 @@ export class NSRegistry { namespace(name: string, version: string): IntrospectedNamespace | null { const namespace = this.mapping.get(name, version); - if (!namespace) { - return this._internalLoad(name, version); - } - - return namespace; + return namespace ?? null; } namespacesForPrefix(c_prefix: string): IntrospectedNamespace[] { - return this.c_mapping.get(c_prefix) ?? []; + return (this.c_mapping.get(c_prefix) ?? []).map(c_mapping => + this.assertNamespace(c_mapping.name, c_mapping.version) + ); } transform(options: TransformOptions) { @@ -175,12 +172,6 @@ export class NSRegistry { return meta[0]; } - const ns = this._defaultVersionInternalLoad(name); - - if (ns) { - return ns.version; - } - return null; } @@ -197,11 +188,7 @@ export class NSRegistry { } assertNamespace(name: string, version: string): IntrospectedNamespace { - let namespace = this.mapping.get(name, version) ?? null; - - if (!namespace) { - namespace = this._internalLoad(name, version); - } + const namespace = this.mapping.get(name, version) ?? null; if (!namespace) { throw new Error(`Namespace '${name}' not found.`); @@ -210,15 +197,13 @@ export class NSRegistry { return namespace; } - load(gir: ParsedGir, options: LoadOptions): IntrospectedNamespace { - const namespace = IntrospectedNamespace.load(gir, options as LoadOptions & GenerateConfig, this); - + register(namespace: GirModule): IntrospectedNamespace { this.mapping.set(namespace.name, namespace.version, namespace); namespace.c_prefixes.forEach(c_prefix => { const c_map = this.c_mapping.get(c_prefix) || []; - c_map.push(namespace); + c_map.push({ name: namespace.name, version: namespace.version }); this.c_mapping.set(c_prefix, c_map); }); @@ -227,65 +212,4 @@ export class NSRegistry { return namespace; } - - private _defaultVersionInternalLoad(name: string): IntrospectedNamespace | null { - const all = this.loaders - .map(([loader, options]) => { - try { - return [loader.loadAll(name), options] as const; - } catch (error) { - // TODO: Should we throw here? - console.error(error); - return null; - } - }) - .filter((a): a is [ParsedGir[], LoadOptions] => a != null); - - if (all.length === 0 || all.length > 1) { - return null; - } - - const [[xmls, options]] = all; - - if (xmls.length === 0 || xmls.length > 1) { - return null; - } - - const [xml] = xmls; - - const ns = this.load(xml, options); - - if (ns) { - this._transformNamespace(ns); - } - - return ns; - } - - private _internalLoad(name: string, version: string): IntrospectedNamespace | null { - for (const [loader, options] of this.loaders) { - try { - const xml = loader.load(name, version); - - if (xml) { - const ns = this.load(xml, options); - - if (ns) { - this._transformNamespace(ns); - } - - return ns; - } - } catch (error) { - // TODO: Should we throw here? - console.error(error); - } - } - - return null; - } - - registerLoader(loader: NSLoader, options: LoadOptions) { - this.loaders.push([loader, options]); - } } From d068aaac9531c17ead365efc996ddfa4b99ff066 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:56:15 -0700 Subject: [PATCH 51/53] lib: Ensure classes implement interface methods when interfaces extend classes --- .../src/type-definition-generator.ts | 251 +++++++++++------- packages/lib/src/generators/dts.ts | 18 +- packages/lib/src/gir.ts | 109 ++++++-- packages/lib/src/gir/class.ts | 88 ++++-- packages/lib/src/gir/function.ts | 10 +- packages/lib/src/injections/gio.ts | 2 +- packages/lib/src/injections/glib.ts | 35 +-- 7 files changed, 361 insertions(+), 152 deletions(-) diff --git a/packages/generator-typescript/src/type-definition-generator.ts b/packages/generator-typescript/src/type-definition-generator.ts index 0e7f1ff53..826a16507 100644 --- a/packages/generator-typescript/src/type-definition-generator.ts +++ b/packages/generator-typescript/src/type-definition-generator.ts @@ -6,7 +6,6 @@ import { removeClassModule, Dependency, DependencyManager, - NO_TSDATA, WARN_NOT_FOUND_DEPENDENCY_GIR_FILE, //WARN_IGNORE_MULTIPLE_CALLBACKS, //WARN_IGNORE_MULTIPLE_FUNC_DESC, @@ -34,6 +33,7 @@ import { ArrayType, FilterBehavior, VoidType, + ClassStructTypeIdentifier, } from '@ts-for-gir/lib' import { TemplateProcessor } from './template-processor.js' import { PackageDataParser } from './package-data-parser.js' @@ -170,16 +170,37 @@ class ModuleGenerator extends FormatGenerator { const invalid = isInvalid(node.name) const name = invalid ? `["${node.name}"]` : node.name const warning = node.getWarning() + const genericTypes = this.generateGenericParameters(node.generics) + return [ `${warning ? `${warning}\n` : ''}`, ...this.addGirDocComment(node.doc), - `static ${name}(${Parameters}): ${node + `static ${name}${genericTypes}(${Parameters}): ${node .return() .resolve(namespace, options) .rootPrint(namespace, options)};`, ] } generateRecord(node: IntrospectedRecord): string[] { + const structFor = node.structFor + + if (structFor) { + const resolvedIdentifier = structFor.resolveIdentifier(this.namespace, this.config) + + // Only create aliases for structs which resolve... + if (resolvedIdentifier) { + return this.generateAlias( + new IntrospectedAlias({ + name: node.name, + namespace: node.namespace, + type: new ClassStructTypeIdentifier(structFor.name, structFor.namespace), + }), + ) + } + + return [] + } + return this.generateClass(node) } generateInterface(node: IntrospectedInterface): string[] { @@ -190,6 +211,7 @@ class ModuleGenerator extends FormatGenerator { const hasNamespace = isGObject || hasStaticFunctions || node.callbacks.length > 0 return [ + ...this.generateClassModules(node), ...(hasNamespace ? this.generateInterfaceNamespace(node) : []), ...this.generateImplementationInterface(node), ...(hasNamespace ? this.generateInterfaceDeclaration(node) : []), @@ -288,37 +310,35 @@ class ModuleGenerator extends FormatGenerator { generateProperty(tsProp: IntrospectedProperty, construct?: boolean, indentCount = 0) { const desc: string[] = [] - const isStatic = false // TODO: tsProp.isStatic desc.push(...this.addGirDocComment(tsProp.doc, [], indentCount)) const indent = generateIndent(indentCount) const name = this.generateMemberName(tsProp) - const staticStr = isStatic ? 'static ' : '' const { readable, writable, constructOnly } = tsProp const hasGetter = readable const hasSetter = writable && !constructOnly - const readonly = !hasSetter && hasGetter ? 'readonly ' : '' let type = tsProp.type let getterAnnotation = '' let setterAnnotation = '' let getterSetterAnnotation = '' + let printAsProperty = false if (type instanceof TypeConflict) { switch (type.conflictType) { case ConflictType.FUNCTION_NAME_CONFLICT: case ConflictType.FIELD_NAME_CONFLICT: getterSetterAnnotation = - setterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. - // @ts-expect-error\n` + setterAnnotation = `// This accessor conflicts with a field or function name in a parent class or interface.\n` case ConflictType.ACCESSOR_PROPERTY_CONFLICT: getterSetterAnnotation = - getterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. - // @ts-expect-error\n` - type = type.unwrap() + getterAnnotation = `// This accessor conflicts with a property or field in a parent class or interface.\n` + type = new BinaryType(type.unwrap(), AnyType) + // A child class cannot have an accessor declared if the parent has a property + printAsProperty = true break case ConflictType.PROPERTY_ACCESSOR_CONFLICT: type = new BinaryType(type.unwrap(), AnyType) @@ -344,8 +364,10 @@ class ModuleGenerator extends FormatGenerator { return [`${name}: ${Type};`] } - if (tsProp.parent instanceof IntrospectedInterface) { - return [`${staticStr}${readonly}${name}: ${Type};`] + if (printAsProperty) { + desc.push(`${getterSetterAnnotation}${indent} ${name}: ${Type};`) + + return desc } if (hasGetter && hasSetter) { @@ -380,13 +402,19 @@ class ModuleGenerator extends FormatGenerator { if (type instanceof TypeConflict) { if (type.conflictType === ConflictType.PROPERTY_ACCESSOR_CONFLICT) { - commentOut = `// This accessor conflicts with a property, field, or function name in a parent class or interface.\n// @ts-expect-error\n` - } + commentOut = `\n// @ts-expect-error This property conflicts with an accessor in a parent class or interface.\n` + + type = type.unwrap() + } else if (type.conflictType === ConflictType.FUNCTION_NAME_CONFLICT) { + commentOut = `\n// This field conflicts with a function in a parent class or interface.\n` - type = new BinaryType(type.unwrap(), AnyType) + type = new BinaryType(type.unwrap(), AnyType) + } else { + type = type.unwrap() + } } - const typeStr = this.generateTypes(type) + const typeStr = this.generateType(type) desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr}`) return desc @@ -452,10 +480,8 @@ class ModuleGenerator extends FormatGenerator { generateMemberName(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField) { const name = tsVar.name const invalid = isInvalid(name) - const Name = - invalid && (tsVar instanceof IntrospectedProperty || tsVar instanceof IntrospectedField) - ? `"${name}"` - : name + const hasInvalidName = invalid && (tsVar instanceof IntrospectedProperty || tsVar instanceof IntrospectedField) + const Name = hasInvalidName ? `"${name}"` : name if (!Name) { throw new Error('[generateVariable] "name" not set!') @@ -466,12 +492,13 @@ class ModuleGenerator extends FormatGenerator { return `${ComputedName}` } + /** + * @param tsType The type expression + * @param namespace Provides the namespace to import relative to, defaults to the current namespace + * @returns A string for the type expression + */ generateType(tsType: TypeExpression) { - return tsType.print(this.namespace, this.config) - } - - generateTypes(tsTypes: TypeExpression) { - return tsTypes.print(this.namespace, this.config) + return tsType.resolve(this.namespace, this.config).print(this.namespace, this.config) } // TODO: @@ -656,13 +683,9 @@ class ModuleGenerator extends FormatGenerator { } generateParameter(tsParam: IntrospectedFunctionParameter) { - if (typeof tsParam?.name !== 'string') { - throw new Error(NO_TSDATA('generateParameter')) - } - const types = tsParam.type const name = tsParam.name - const typeStr = this.generateTypes(types) + const typeStr = this.generateType(types) const optional = tsParam.isOptional && !tsParam.isVarArgs const affix = optional ? '?' : '' const prefix = tsParam.isVarArgs ? '...' : '' @@ -776,10 +799,6 @@ class ModuleGenerator extends FormatGenerator { const { parameters: inParams } = tsFunction - // if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) { - // return def - // } - if (tsFunction.doc) def.push( ...this.addGirDocComment( @@ -872,7 +891,7 @@ class ModuleGenerator extends FormatGenerator { const indent = generateIndent(indentCount) const indentBody = generateIndent(indentCount + 1) const { parameters: inParams } = tsCallback - const returnTypeStr = this.generateTypes(tsCallback.return()) + const returnTypeStr = this.generateType(tsCallback.return()) // Get name, remove namespace and remove module class name prefix let { name } = tsCallback @@ -914,13 +933,19 @@ class ModuleGenerator extends FormatGenerator { generateEnum(girEnum: IntrospectedEnum, indentCount = 0) { const desc: string[] = [] - if (!girEnum) { - this.log.warn(NO_TSDATA('generateEnumeration')) + desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount)) + + // Enums can't have numerical keys + const isInvalidEnum = Array.from(girEnum.members.keys()).some( + (name) => name.match(/^[0-9]+$/) || name === 'NaN' || name === 'Infinity', + ) + + if (isInvalidEnum) { + desc.push(...girEnum.asClass().asString(this)) + return desc } - desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount)) - const { name } = girEnum desc.push(this.generateExport('enum', name, '{', indentCount)) if (girEnum.members) { @@ -959,7 +984,7 @@ class ModuleGenerator extends FormatGenerator { const exp = !this.config.noNamespace ? '' : 'export ' const ComputedName = this.generateMemberName(tsConst) - const typeStr = this.generateTypes(tsConst.type) + const typeStr = this.generateType(tsConst.type) desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr}`) return desc @@ -1010,45 +1035,52 @@ class ModuleGenerator extends FormatGenerator { const exp = !this.config.noNamespace ? '' : 'export ' let ext = '' const resolution = girClass.resolveParents() - const superType = resolution.extends() - const superTypes = superType ? [superType] : [] + const superType = girClass.superType + const superTypeIdentifier = superType + ?.resolveIdentifier(this.namespace, this.config) + ?.print(this.namespace, this.config) + const genericTypes = this.generateGenericParameters(girClass.generics) // Remove namespace and class module name const constructPropInterfaceName = `ConstructorProps` // Only add the "extends" if the parent type will be generated (it has props)... - if (superType) { - ext = `extends ${superTypes.map((superType) => `${superType.node.getType().print(this.namespace, this.config)}.${constructPropInterfaceName}`).join(', ')}` + if (superTypeIdentifier) { + const interfaceExtends = + 'implements' in resolution + ? resolution + .implements() + .map((iface) => + iface.identifier + .resolveIdentifier(this.namespace, this.config) + ?.print(this.namespace, this.config), + ) + .filter((identifier): identifier is string => !!identifier) + .map((identifier) => { + const identifierParts = identifier.split('<') + const generics = identifierParts.length > 1 ? `<${identifierParts[1]}` : '' + return `${identifierParts[0]}.${constructPropInterfaceName}${generics}` + }) + : [] + + const superTypeIdentifierParts = superTypeIdentifier.split('<') + const generics = superTypeIdentifierParts.length > 1 ? `<${superTypeIdentifierParts[1]}` : '' + const superTypeExtends = `${superTypeIdentifierParts[0]}.${constructPropInterfaceName}${generics}` + ext = `extends ${[superTypeExtends, ...interfaceExtends].join(', ')}` } def.push(...this.addInfoComment('Constructor properties interface', indentCount)) - // TODO: Clean this up better, we may want to introduce interfaces - // also having construct property interfaces... - // Include properties from parent interfaces... - const props = - 'implements' in resolution - ? [...resolution.implements().flatMap((iface) => iface.node.props), ...girClass.props] - : [...girClass.props] - const deduplicatedProps = [ - ...props - .reduce((prev, next) => { - prev.set(next.name, next) - - return prev - }, new Map()) - .values(), - ] + const { props } = girClass // START BODY - // TODO: Is filtering here correct if we're already "filtering" above? - const ConstructorProps = filterConflicts(girClass.namespace, girClass, deduplicatedProps, FilterBehavior.DELETE) + const ConstructorProps = filterConflicts(girClass.namespace, girClass, props, FilterBehavior.PRESERVE) .flatMap((v) => v.asString(this, true)) .join('\n ') - def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext} {`) + def.push(`${indent}${exp}interface ${constructPropInterfaceName}${genericTypes} ${ext} {`) def.push(ConstructorProps) def.push(`${indent}}`, '') @@ -1138,7 +1170,7 @@ class ModuleGenerator extends FormatGenerator { [], ), indentCount, - `Owm methods of ${girClass.namespace.namespace}.${girClass.name}`, + `Own static methods of ${girClass.namespace.namespace}.${girClass.name}`, ), ) @@ -1161,7 +1193,7 @@ class ModuleGenerator extends FormatGenerator { [], ), indentCount, - `Owm methods of ${girClass.namespace.namespace}.${girClass.name}`, + `Own methods of ${girClass.namespace.namespace}.${girClass.name}`, ), ) @@ -1184,8 +1216,14 @@ class ModuleGenerator extends FormatGenerator { ) def.push(`\nconstructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: any[]);\n`) - // _init method - def.push('_init(...args: any[]): void;\n') + // Don't inject a constructor hook if a stricter index signature is set, + // as the types may not be compatible. + // + // TODO: Don't hardcode string index signatures + if (!girClass.__ts__indexSignature || girClass.__ts__indexSignature.includes('[key: string]: any')) { + // _init method + def.push('_init(...args: any[]): void;\n') + } def.push( ...filterFunctionConflict(girClass.parent, girClass, girClass.constructors, []).flatMap((constructor) => @@ -1377,7 +1415,10 @@ class ModuleGenerator extends FormatGenerator { bodyDef.push(...this.generateClassSignalInterfaces(girClass, indentCount + 1)) } + bodyDef.push(...this.generateClassCallbacks(girClass)) + // Properties interface for construction + // TODO: Actually use this interface to build class' construction props interface bodyDef.push(...this.generateConstructPropsInterface(girClass, indentCount + 1)) if (!bodyDef.length) { @@ -1398,6 +1439,12 @@ class ModuleGenerator extends FormatGenerator { return def } + generateClassCallbacks(girClass: IntrospectedClass | IntrospectedInterface | IntrospectedRecord) { + if (girClass.callbacks.length === 0) return [] + + return girClass.callbacks.flatMap((c) => this.generateClassCallback(c)) + } + /** * In Typescript, interfaces and classes can have the same name, * so we use this to generate interfaces with the same name to implement multiple inheritance @@ -1411,10 +1458,13 @@ class ModuleGenerator extends FormatGenerator { const genericParameters = this.generateGenericParameters(girClass.generics) const resolution = girClass.resolveParents() - const implementationNames = - 'implements' in resolution + const superType = resolution.extends() + const implementationNames = [ + ...(superType ? [superType.node.getType().print(this.namespace, this.config)] : []), + ...('implements' in resolution ? resolution.implements().map((i) => i.node.getType().print(this.namespace, this.config)) - : [] + : []), + ] const ext = implementationNames.length ? ` extends ${implementationNames.join(', ')}` : '' const interfaceHead = `${girClass.name}${genericParameters}${ext}` @@ -1422,6 +1472,10 @@ class ModuleGenerator extends FormatGenerator { { def.push(this.generateExport('interface', interfaceHead, '{')) + if (girClass.__ts__indexSignature) { + def.push(`\n${girClass.__ts__indexSignature}\n`) + } + // START BODY { // Properties @@ -1430,17 +1484,11 @@ class ModuleGenerator extends FormatGenerator { // Fields def.push(...this.generateClassMemberFields(girClass)) - // Methods - // TODO def.push(...this.generateClassStaticMethods(girClass)) - // Methods def.push(...this.generateClassMethods(girClass)) // Virtual methods def.push(...this.generateClassVirtualMethods(girClass)) - - // TODO: Generate `GirSignalElement`s instead of generate the signal definition strings directly - // TODO: def.push(...this.generateClassPropertySignals(girClass)) } // END BODY @@ -1508,9 +1556,6 @@ class ModuleGenerator extends FormatGenerator { def.push(...this.generateClassModules(girClass)) - // TODO: Should implementation interfaces be supported? - // def.push(...this.generateImplementationInterface(girClass)) - def.push(...this.addGirDocComment(girClass.doc, [], 0)) const genericParameters = this.generateGenericParameters(girClass.generics) @@ -1520,12 +1565,18 @@ class ModuleGenerator extends FormatGenerator { // START CLASS { - if (girClass instanceof IntrospectedClass && girClass.isAbstract) { + const isAbstract = girClass instanceof IntrospectedClass && girClass.isAbstract + const isOpaque = girClass instanceof IntrospectedRecord && girClass.isPrivate + if (isAbstract || isOpaque) { def.push(this.generateExport('abstract class', classHead, '{')) } else { def.push(this.generateExport('class', classHead, '{')) } + if (girClass.__ts__indexSignature) { + def.push(`\n${girClass.__ts__indexSignature}\n`) + } + // START BODY { // Static Properties @@ -1542,15 +1593,22 @@ class ModuleGenerator extends FormatGenerator { def.push(...this.generateClassSignals(girClass)) } - // Methods + // Static Methods def.push(...this.generateClassStaticMethods(girClass)) - // Static Methods + // Virtual methods + def.push(...this.generateClassVirtualMethods(girClass)) + + // Methods def.push(...this.generateClassMethods(girClass)) if (girClass instanceof IntrospectedClass) { - const implementedProperties = girClass.implementedProperties() - const implementedMethods = girClass.implementedMethods(implementedProperties) + const implementedProperties = girClass + .implementedProperties() + .map((prop) => prop.copy({ parent: girClass })) + const implementedMethods = girClass + .implementedMethods(implementedProperties) + .map((method) => method.copy({ parent: girClass })) const generatedImplementedProperties = filterConflicts( girClass.namespace, @@ -1558,7 +1616,8 @@ class ModuleGenerator extends FormatGenerator { implementedProperties, ).flatMap((m) => m.asString(this)) - def.push(...generatedImplementedProperties) + if (generatedImplementedProperties.length > 0) + def.push('\n// Inherited properties', ...generatedImplementedProperties) const filteredImplMethods = filterFunctionConflict( girClass.namespace, @@ -1568,7 +1627,8 @@ class ModuleGenerator extends FormatGenerator { ) const generatedImplementedMethods = filteredImplMethods.flatMap((m) => m.asString(this)) - def.push(...generatedImplementedMethods) + if (generatedImplementedMethods.length > 0) + def.push('\n// Inherited methods', ...generatedImplementedMethods) } } // END BODY @@ -1711,7 +1771,11 @@ class ModuleGenerator extends FormatGenerator { if (this.config.outdir) { const outputPath = this.moduleTemplateProcessor.getOutputPath(this.config.outdir, target) - console.log(outputPath, target) + + if (this.config.verbose) { + this.log.debug(`Outputting ${target} to ${outputPath}`) + } + // write template result file await mkdir(dirname(outputPath), { recursive: true }) await writeFile(outputPath, contents, { encoding: 'utf8', flag: 'w' }) @@ -1864,7 +1928,7 @@ class ModuleGenerator extends FormatGenerator { await this.exportModuleImportTS(girModule) await this.exportModuleImportJS(girModule) - const pkg = new NpmPackage(this.config, this.dependencyManager, girModule) + const pkg = new NpmPackage(this.config, this.dependencyManager, girModule, girModule.dependencies) await pkg.exportNPMPackage() } @@ -1966,7 +2030,7 @@ export class TypeDefinitionGenerator implements Generator { await templateProcessor.create('tsconfig.alias.json', config.root, 'tsconfig.alias.json', true) } - const pkg = new NpmPackage(config, dependencyManager, gjs) + const pkg = new NpmPackage(config, dependencyManager, gjs, dependencyManager.core()) // Package await pkg.exportNPMPackage() @@ -1996,7 +2060,12 @@ class NpmPackage { log: Logger packageName: string - constructor(config: GenerateConfig, dependencyManager: DependencyManager, dependencyOrModule: Wrapped) { + constructor( + config: GenerateConfig, + dependencyManager: DependencyManager, + dependencyOrModule: Wrapped, + deps: Dependency[], + ) { this.config = config this.packageName = dependencyOrModule.packageName @@ -2015,7 +2084,7 @@ class NpmPackage { girModule: dependencyOrModule instanceof GirModule ? dependencyOrModule : undefined, }, dependencyOrModule.packageName, - [], + deps, this.config, ) } diff --git a/packages/lib/src/generators/dts.ts b/packages/lib/src/generators/dts.ts index c6777c283..2f2c519f2 100644 --- a/packages/lib/src/generators/dts.ts +++ b/packages/lib/src/generators/dts.ts @@ -329,7 +329,7 @@ ${this.docString(node)}export enum ${node.name} { : "" } export type ${name}${Generics} = ${name}Prototype${GenericTypes}; -export interface ${name}Prototype${Generics}${Extends} {${node.indexSignature ? `\n${node.indexSignature}\n` : ""} +export interface ${name}Prototype${Generics}${Extends} {${node.__ts__indexSignature ? `\n${node.__ts__indexSignature}\n` : ""} ${node.props.length > 0 ? "// Properties" : ""} ${filterConflicts(node.namespace, node, node.props) .map(p => p.asString(this)) @@ -395,7 +395,7 @@ export interface ${name}Prototype${Generics}${Extends} {${node.indexSignature ? } ${this.docString(node)}export class ${name}${Generics}${Extends} {${ - node.indexSignature ? `\n${node.indexSignature}\n` : "" + node.__ts__indexSignature ? `\n${node.__ts__indexSignature}\n` : "" } static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>; @@ -620,7 +620,7 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${ : "" } export ${node.isAbstract ? "abstract " : ""}class ${name}${Generics}${Extends}${Implements} {${ - node.indexSignature ? `\n${node.indexSignature}\n` : "" + node.__ts__indexSignature ? `\n${node.__ts__indexSignature}\n` : "" } static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>; @@ -692,14 +692,12 @@ ${this.docString(node)}export class ${name}${Generics}${Extends} {${ switch (type.conflictType) { case ConflictType.FUNCTION_NAME_CONFLICT: case ConflictType.FIELD_NAME_CONFLICT: - getterSetterAnnotation = - setterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. - // @ts-expect-error\n`; + getterSetterAnnotation = setterAnnotation = + "// This accessor conflicts with a property, field, or function name in a parent class or interface.\n"; case ConflictType.ACCESSOR_PROPERTY_CONFLICT: - getterSetterAnnotation = - getterAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface. - // @ts-expect-error\n`; - type = type.unwrap(); + getterSetterAnnotation = getterAnnotation = + "// This accessor conflicts with a property, field, or function name in a parent class or interface.\n"; + type = new BinaryType(type.unwrap(), AnyType); break; case ConflictType.PROPERTY_ACCESSOR_CONFLICT: type = new BinaryType(type.unwrap(), AnyType); diff --git a/packages/lib/src/gir.ts b/packages/lib/src/gir.ts index 0c8078304..6ac2cfa6c 100644 --- a/packages/lib/src/gir.ts +++ b/packages/lib/src/gir.ts @@ -1,7 +1,7 @@ import { IntrospectedNamespace } from './gir/namespace.js' import { IntrospectedProperty, IntrospectedField } from './gir/property.js' import { GenerationOptions } from './types.js' -import { sanitizeIdentifierName, sanitizeNamespace } from './gir/util.js' +import { isInvalid, sanitizeIdentifierName, sanitizeNamespace } from './gir/util.js' export { sanitizeMemberName, isInvalid } from './gir/util.js' @@ -71,9 +71,9 @@ export class TypeIdentifier extends TypeExpression { protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): TypeIdentifier | null { const name: string = sanitizeIdentifierName(null, this.name) - const ns_name = this.namespace + const unresolvedNamespaceName = this.namespace - const ns = namespace.assertInstalledImport(ns_name) + const ns = namespace.assertInstalledImport(unresolvedNamespaceName) if (ns.hasSymbol(name)) { const c = ns.getClass(name) @@ -82,7 +82,7 @@ export class TypeIdentifier extends TypeExpression { // GirRecord.prototype.getType resolves this relationship. if (c) return c.getType() - return new TypeIdentifier(name, ns_name) + return new TypeIdentifier(name, ns.name) } // Handle "class callback" types (they're in a definition-merged module) @@ -96,20 +96,24 @@ export class TypeIdentifier extends TypeExpression { let c_resolved_name: string | null = null if (!c_resolved_name) { - c_resolved_name = ns.resolveSymbolFromTypeName(`${ns_name}${name}`) + c_resolved_name = ns.resolveSymbolFromTypeName(`${unresolvedNamespaceName}${name}`) + } + + if (!c_resolved_name) { + c_resolved_name = ns.resolveSymbolFromTypeName(`${ns.name}${name}`) } if (!cb && !resolved_name && !c_resolved_name) { // Don't warn if a missing import is at fault, this will be dealt with later. - if (namespace.name === ns_name) { - console.error(`Attempting to fall back on c:type inference for ${ns_name}.${name}.`) + if (namespace.name === ns.name) { + console.error(`Attempting to fall back on c:type inference for ${ns.name}.${name}.`) } - ;[cb, corrected_name] = ns.findClassCallback(`${ns_name}${name}`) + ;[cb, corrected_name] = ns.findClassCallback(`${ns.name}${name}`) if (cb) { console.error( - `Falling back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.`, + `Falling back on c:type inference for ${ns.name}.${name} and found ${ns.name}.${corrected_name}.`, ) } } @@ -119,21 +123,21 @@ export class TypeIdentifier extends TypeExpression { console.debug(`Callback found: ${cb}.${corrected_name}`) } - return new TypeIdentifier(corrected_name, cb) + return new ModuleTypeIdentifier(corrected_name, cb, ns.name) } else if (resolved_name) { - return new TypeIdentifier(resolved_name, ns_name) + return new TypeIdentifier(resolved_name, ns.name) } else if (c_resolved_name) { console.error( - `Fell back on c:type inference for ${ns_name}.${name} and found ${ns_name}.${corrected_name}.`, + `Fell back on c:type inference for ${ns.name}.${name} and found ${ns.name}.${corrected_name}.`, ) - return new TypeIdentifier(c_resolved_name, ns_name) - } else if (namespace.name === ns_name) { - console.error(`Unable to resolve type ${this.name} in same namespace ${ns_name}!`) + return new TypeIdentifier(c_resolved_name, ns.name) + } else if (namespace.name === ns.name) { + console.error(`Unable to resolve type ${this.name} in same namespace ${ns.name}!`) return null } - console.error(`Type ${this.namespace}.${this.name} could not be resolved in ${namespace.name}`) + console.error(`Type ${this.name} could not be resolved in ${namespace.name}`) return null } @@ -163,6 +167,79 @@ export class TypeIdentifier extends TypeExpression { } } +export class ModuleTypeIdentifier extends TypeIdentifier { + readonly moduleName: string + + constructor(name: string, moduleName: string, namespace: string) { + super(name, namespace) + + this.moduleName = moduleName + } + + equals(type: TypeExpression): boolean { + return super.equals(type) && type instanceof ModuleTypeIdentifier && this.moduleName === type.moduleName + } + + is(namespace: string, moduleName: string, name?: string) { + return ( + this.namespace === namespace && this.moduleName === moduleName && this.name === name && name !== undefined + ) + } + + unwrap() { + return this + } + + rewrap(type: TypeExpression): TypeExpression { + return type + } + + sanitize() { + return new ModuleTypeIdentifier( + sanitizeIdentifierName(this.namespace, this.name), + sanitizeIdentifierName(this.namespace, this.moduleName), + sanitizeNamespace(this.namespace), + ) + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + protected _resolve(namespace: IntrospectedNamespace, options: GenerationOptions): ModuleTypeIdentifier | null { + return this + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + if (namespace.name === this.namespace) { + return `${this.moduleName}.${this.name}` + } else { + return `${this.namespace}.${this.moduleName}.${this.name}` + } + } +} + +/** + * This class overrides the default printing for types + */ +export class ClassStructTypeIdentifier extends TypeIdentifier { + constructor(name: string, namespace: string) { + super(name, namespace) + } + + equals(type: TypeExpression): boolean { + return type instanceof ClassStructTypeIdentifier && super.equals(type) + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + print(namespace: IntrospectedNamespace, options: GenerationOptions): string { + if (namespace.name === this.namespace) { + // TODO: Mapping to invalid names should happen at the generator level... + return `typeof ${isInvalid(this.name) ? `__${this.name}` : this.name}` + } else { + return `typeof ${this.namespace}.${isInvalid(this.name) ? `__${this.name}` : this.name}` + } + } +} + export class GenerifiedTypeIdentifier extends TypeIdentifier { generics: TypeExpression[] diff --git a/packages/lib/src/gir/class.ts b/packages/lib/src/gir/class.ts index dcf24622b..f3b392025 100644 --- a/packages/lib/src/gir/class.ts +++ b/packages/lib/src/gir/class.ts @@ -19,7 +19,14 @@ import { import { TypeExpression } from "../gir.js"; import { IntrospectedBase, IntrospectedClassMember, IntrospectedNamespaceMember, Options } from "./base.js"; -import { GirInterfaceElement, GirClassElement, GirRecordElement, GirDirection, GirUnionElement } from "../index.js"; +import { + GirInterfaceElement, + GirClassElement, + GirRecordElement, + GirDirection, + GirUnionElement, + ClassStructTypeIdentifier +} from "../index.js"; import { IntrospectedClassFunction, IntrospectedVirtualClassFunction, @@ -85,7 +92,14 @@ export function filterConflicts { return findMap([...resolved_parent.props], p => { if (p.name && p.name == next.name) { - if (next instanceof IntrospectedField) { + // TODO: This is very TypeScript-specific but until we include which parent + // a conflict originates from in the return, we have to handle this here + // and not in the generator... + // + // Classes can override parent interface accessors with properties _but_ + // classes cannot override parent class accessors with properties without + // an error occuring. + if (p.parent instanceof IntrospectedClass && next instanceof IntrospectedField) { return ConflictType.PROPERTY_ACCESSOR_CONFLICT; } @@ -212,9 +226,13 @@ export function filterFunctionConflict< }); }); - const field_conflicts = base.someParent(resolved_parent => - [...resolved_parent.props, ...resolved_parent.fields].some(p => p.name && p.name == next.name) - ); + // Check if the method name conflicts with any props or fields either on + // the class or in the parent... + const field_conflicts = + [...base.props, ...base.fields].some(p => p.name && p.name === next.name) || + base.someParent(resolved_parent => + [...resolved_parent.props, ...resolved_parent.fields].some(p => p.name && p.name === next.name) + ); const isGObject = base.someParent(p => p.namespace.name === "GObject" && p.name === "Object"); @@ -267,7 +285,7 @@ export function filterFunctionConflict< prev.push(next, never as T); } else if (field_conflicts) { - console.error(`Omitting ${next.name} due to field conflict.`); + console.error(`Omitting ${next.name} due to field or property conflict.`); } else { prev.push(next); } @@ -400,7 +418,12 @@ export interface RecordResolution extends ResolutionNode, Iterable r.implements()).flat(); + const implementedOnParent = [...(resolution.extends() ?? [])].map(r => r.implements()).flat(); const methods = new Map(); const validateMethod = (method: IntrospectedClassFunction) => @@ -653,8 +690,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { if (implemented.node instanceof IntrospectedClass) continue; if ( - implemented_on_parent.find(p => p.identifier.equals(implemented.identifier))?.node?.generics?.length === - 0 + implementedOnParent.find(p => p.identifier.equals(implemented.identifier))?.node?.generics?.length === 0 ) continue; for (const member of implemented.node.members) { @@ -667,7 +703,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { [...implemented].forEach(e => { if (e.node instanceof IntrospectedClass) return; - if (implemented_on_parent.find(p => p.identifier.equals(e.identifier))?.node.generics.length === 0) + if (implementedOnParent.find(p => p.identifier.equals(e.identifier))?.node.generics.length === 0) return; for (const member of e.node.members) { if (!validateMethod(member)) continue; @@ -677,6 +713,20 @@ export class IntrospectedClass extends IntrospectedBaseClass { }); } + // If an interface inherits from a class (such as Gtk.Widget) + // we need to pull in every method from that class... + for (const implemented of resolution.implements()) { + const extended = implemented.extends(); + + if (extended?.node instanceof IntrospectedClass) { + for (const member of extended.node.members) { + if (!validateMethod(member)) continue; + + methods.set(member.name, member); + } + } + } + return [...methods.values()].map(f => { const mapping = new Map(); if (f.parent instanceof IntrospectedBaseClass) { @@ -992,7 +1042,7 @@ export class IntrospectedClass extends IntrospectedBaseClass { export class IntrospectedRecord extends IntrospectedBaseClass { private _isForeign: boolean = false; - private _structFor: TypeIdentifier | null = null; + private _structFor: ClassStructTypeIdentifier | null = null; private _isSimple: boolean | null = null; private _isSimpleWithoutPointers: string | null = null; @@ -1000,6 +1050,10 @@ export class IntrospectedRecord extends IntrospectedBaseClass { return this._isForeign; } + get structFor() { + return this._structFor; + } + getType(): TypeIdentifier { if (this._structFor) { return this._structFor; @@ -1154,15 +1208,14 @@ export class IntrospectedRecord extends IntrospectedBaseClass { clazz.setPrivate( element.$.name.startsWith("_") || ("disguised" in element.$ && element.$.disguised === "1") || - // Don't generate records for structs - (typeof element.$["glib:is-gtype-struct-for"] === "string" && !!element.$["glib:is-gtype-struct-for"]) + ("opaque" in element.$ && element.$.opaque === "1") ); if (typeof element.$["glib:is-gtype-struct-for"] === "string" && !!element.$["glib:is-gtype-struct-for"]) { - clazz.noEmit(); + const structFor = parseTypeIdentifier(namespace.name, element.$["glib:is-gtype-struct-for"]); - // This let's us replace these references when generating. - clazz._structFor = parseTypeIdentifier(namespace.name, element.$["glib:is-gtype-struct-for"]); + // This let's replace these references when generating. + clazz._structFor = new ClassStructTypeIdentifier(structFor.name, structFor.namespace); } else { if (element.$["glib:type-name"]) { clazz.resolve_names.push(element.$["glib:type-name"]); @@ -1556,7 +1609,6 @@ export class IntrospectedInterface extends IntrospectedBaseClass { if (element.property) { clazz.props.push( ...element.property - .map(prop => IntrospectedProperty.fromXML(prop, clazz, options)) .map(prop => { switch (options.propertyCase) { diff --git a/packages/lib/src/gir/function.ts b/packages/lib/src/gir/function.ts index c1cb665fd..00453d0c7 100644 --- a/packages/lib/src/gir/function.ts +++ b/packages/lib/src/gir/function.ts @@ -278,6 +278,7 @@ export class IntrospectedFunction extends IntrospectedNamespaceMember { }); fn.returnTypeDoc = this.returnTypeDoc; + fn.generics = [...this.generics]; return fn; } @@ -380,6 +381,8 @@ export class IntrospectedConstructor extends IntrospectedClassMember { readonly parameters: IntrospectedFunctionParameter[] = []; readonly return_type: TypeExpression = UnknownType; + generics: Generic[] = []; + constructor({ name, parameters = [], @@ -406,12 +409,16 @@ export class IntrospectedConstructor extends IntrospectedClassMember { parameters?: IntrospectedFunctionParameter[]; return_type?: TypeExpression; } = {}): IntrospectedConstructor { - return new IntrospectedConstructor({ + const constr = new IntrospectedConstructor({ name: this.name, parent: parent ?? this.parent ?? null, return_type: return_type ?? this.return_type, parameters: parameters ?? this.parameters })._copyBaseProperties(this); + + constr.generics = [...this.generics]; + + return constr; } static fromXML( @@ -941,6 +948,7 @@ export class IntrospectedStaticClassFunction extends IntrospectedClassFunction { }); fn.returnTypeDoc = this.returnTypeDoc; + fn.generics = [...this.generics]; return fn; } diff --git a/packages/lib/src/injections/gio.ts b/packages/lib/src/injections/gio.ts index c16115fe5..329bb5ccb 100644 --- a/packages/lib/src/injections/gio.ts +++ b/packages/lib/src/injections/gio.ts @@ -129,7 +129,7 @@ export default { const DBusProxy = namespace.assertClass("DBusProxy"); // This is not ideal, but DBusProxy's define functions and properties on the prototype. - DBusProxy.indexSignature = "[key: string]: any;"; + DBusProxy.__ts__indexSignature = "[key: string]: any;"; const makeProxyWrapper = new IntrospectedStaticClassFunction({ name: "makeProxyWrapper", diff --git a/packages/lib/src/injections/glib.ts b/packages/lib/src/injections/glib.ts index 86abf6511..b584da71f 100644 --- a/packages/lib/src/injections/glib.ts +++ b/packages/lib/src/injections/glib.ts @@ -15,7 +15,8 @@ import { UnknownType, GenericType, TypeIdentifier, - BinaryType + BinaryType, + Generic } from "../gir.js"; import { GirDirection } from "@gi.ts/parser"; import { IntrospectedRecord } from "../gir/class.js"; @@ -101,7 +102,7 @@ export default { { const HashTable = namespace.assertClass("HashTable") as IntrospectedRecord; - HashTable.indexSignature = "[key: string]: B;"; + HashTable.__ts__indexSignature = "[key: string]: B;"; } // GLib.Variant @@ -132,26 +133,30 @@ export default { direction: GirDirection.In }) ]; + + // static "new"(sig: A, value: any) => Variant; const VariantConstructor = new IntrospectedConstructor({ name: "new", parent: Variant, parameters: VariantParams.map(vp => vp.copy()), - return_type: Variant.getType() + return_type: new NativeType("Variant") }); + VariantConstructor.generics = [new Generic(new GenericType("A"), undefined, undefined, StringType)]; + Variant.mainConstructor = VariantConstructor.copy(); - Variant.constructors.unshift( - // static new: (sig: any, value: any) => Variant; - VariantConstructor.copy(), - // static _new_internal: (sig: any, value: any) => any;, - new IntrospectedConstructor({ - name: "_new_internal", - parent: Variant, - parameters: VariantParams.map(vp => vp.copy()), - return_type: AnyType - }) - ); + // static _new_internal: (sig: any, value: any) => any; + const internalConstructor = new IntrospectedConstructor({ + name: "_new_internal", + parent: Variant, + parameters: VariantParams.map(vp => vp.copy()), + return_type: AnyType + }); + + internalConstructor.generics = [new Generic(new GenericType("A"), undefined, undefined, StringType)]; + + Variant.constructors.unshift(VariantConstructor.copy(), internalConstructor); Variant.members.push( // unpack(): T; @@ -166,7 +171,7 @@ export default { return_type: UnknownType, parent: Variant }), - // deep_unpack: any; + // deep_unpack(): T; new IntrospectedClassFunction({ name: "deep_unpack", return_type: UnknownType, From ec16084bd3bd5fb26089cd0f1324ba3730e046f6 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:56:42 -0700 Subject: [PATCH 52/53] typescript: Make non-versioned ambient module depend on the versioned module --- .../generator-typescript/templates/gjs/module-ambient.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/module-ambient.d.ts b/packages/generator-typescript/templates/gjs/module-ambient.d.ts index fdc96114f..d942b5068 100644 --- a/packages/generator-typescript/templates/gjs/module-ambient.d.ts +++ b/packages/generator-typescript/templates/gjs/module-ambient.d.ts @@ -17,6 +17,5 @@ declare module 'gi://<%= name %>?version=<%= version %>' { <%# // Generate ambient module declarations Without version number if there are no conflicts or the target is an NPM package _%> declare module 'gi://<%= name %>' { - <%- moduleImportStr %>; - export default <%- girModule.importNamespace -%>; + export * from 'gi://<%= name %>?version=<%= version %>'; } \ No newline at end of file From 04a2ee3e53a880276ad0343473a966f7072ab1ab Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 13 Mar 2024 00:58:24 -0700 Subject: [PATCH 53/53] ci: Build local types in a separate project --- .eslintignore | 2 + .ts-for-gir.all.rc.js | 2 + local/.gitignore | 9 + local/.yarnrc.yml | 1 + local/all.ts | 423 ++++++++++++++++++++++++++++++++++++++++++ local/package.json | 9 + local/tsconfig.json | 18 ++ local/yarn.lock | 34 ++++ package.json | 2 +- yarn.lock | 251 ------------------------- 10 files changed, 499 insertions(+), 252 deletions(-) create mode 100644 local/.gitignore create mode 100644 local/.yarnrc.yml create mode 100644 local/all.ts create mode 100644 local/package.json create mode 100644 local/tsconfig.json create mode 100644 local/yarn.lock diff --git a/.eslintignore b/.eslintignore index 19054844a..cf681b00c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,3 +12,5 @@ examples/ @types/ *.js */*.js +# ignore local test as it is a separate typescript project +local/ \ No newline at end of file diff --git a/.ts-for-gir.all.rc.js b/.ts-for-gir.all.rc.js index 829eb580e..6086e3706 100644 --- a/.ts-for-gir.all.rc.js +++ b/.ts-for-gir.all.rc.js @@ -1,8 +1,10 @@ export default { + outdir: './local/@girs/', modules: ['*'], girDirectories: ['./vala-girs/gir-1.0', './girs'], ignoreVersionConflicts: true, promisify: true, + packageYarn: true, ignore: [ 'Colorhug-1.0', // Duplicate of ColorHug-1.0 'GUPnP-DLNA-1.0', // Same namespace as GUPnP-1.0.gir, is this a bug or should we merge the type definitions? diff --git a/local/.gitignore b/local/.gitignore new file mode 100644 index 000000000..cd11ad1b0 --- /dev/null +++ b/local/.gitignore @@ -0,0 +1,9 @@ +@girs + +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/local/.yarnrc.yml b/local/.yarnrc.yml new file mode 100644 index 000000000..8b757b29a --- /dev/null +++ b/local/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules \ No newline at end of file diff --git a/local/all.ts b/local/all.ts new file mode 100644 index 000000000..45d95e9f8 --- /dev/null +++ b/local/all.ts @@ -0,0 +1,423 @@ +import '@girs/accounts-1.0' +import '@girs/accountsservice-1.0' +import '@girs/adw-1' +import '@girs/amtk-4' +import '@girs/amtk-5' +import '@girs/anjuta-3.0' +import '@girs/anthy-9000' +import '@girs/appindicator3-0.1' +import '@girs/appstream-1.0' +import '@girs/appstreambuilder-1.0' +import '@girs/appstreamglib-1.0' +import '@girs/arrow-1.0' +import '@girs/arrowcuda-1.0' +import '@girs/arrowdataset-1.0' +import '@girs/arrowflight-1.0' +import '@girs/atk-1.0' +import '@girs/atspi-2.0' +import '@girs/babl-0.1' +import '@girs/bamf-3' +import '@girs/builder-1.0' +import '@girs/bump-0.1' +import '@girs/cairo-1.0' +import '@girs/cally-1.0' +import '@girs/cally-10' +import '@girs/cally-11' +import '@girs/cally-12' +import '@girs/cally-13' +import '@girs/camel-1.2' +import '@girs/caribou-1.0' +import '@girs/champlain-0.12' +import '@girs/cheese-3.0' +import '@girs/cloudproviders-0.3' +import '@girs/clutter-1.0' +import '@girs/clutter-10' +import '@girs/clutter-11' +import '@girs/clutter-12' +import '@girs/clutter-13' +import '@girs/cluttergdk-1.0' +import '@girs/cluttergst-2.0' +import '@girs/cluttergst-3.0' +import '@girs/clutterx11-1.0' +import '@girs/cogl-1.0' +import '@girs/cogl-2.0' +import '@girs/cogl-10' +import '@girs/cogl-11' +import '@girs/cogl-12' +import '@girs/cogl-13' +import '@girs/coglgst-2.0' +import '@girs/coglpango-1.0' +import '@girs/coglpango-2.0' +import '@girs/coglpango-10' +import '@girs/coglpango-11' +import '@girs/coglpango-12' +import '@girs/coglpango-13' +import '@girs/colord-1.0' +import '@girs/colordgtk-1.0' +import '@girs/colorhug-1.0' +import '@girs/dazzle-1.0' +import '@girs/dbus-1.0' +import '@girs/dbusglib-1.0' +import '@girs/dbusmenu-0.4' +import '@girs/dbusmenugtk-0.4' +import '@girs/dbusmenugtk3-0.4' +import '@girs/dee-1.0' +import '@girs/devhelp-3.0' +import '@girs/dex-1' +import '@girs/dmap-3.0' +import '@girs/ebackend-1.2' +import '@girs/ebook-1.2' +import '@girs/ebookcontacts-1.2' +import '@girs/ecal-2.0' +import '@girs/ecalendar-1.2' +import '@girs/edatabook-1.2' +import '@girs/edatacal-2.0' +import '@girs/edataserver-1.2' +import '@girs/edataserverui-1.2' +import '@girs/edataserverui4-1.0' +import '@girs/egg-1.0' +import '@girs/eog-3.0' +import '@girs/epc-1.0' +import '@girs/epcui-1.0' +import '@girs/evincedocument-3.0' +import '@girs/evinceview-3.0' +import '@girs/farstream-0.1' +import '@girs/farstream-0.2' +import '@girs/flatpak-1.0' +import '@girs/folks-0.6' +import '@girs/folks-0.7' +import '@girs/folksdummy-0.6' +import '@girs/folksdummy-0.7' +import '@girs/folkseds-0.6' +import '@girs/folkseds-0.7' +import '@girs/folkslibsocialweb-0.6' +import '@girs/folkstelepathy-0.6' +import '@girs/folkstelepathy-0.7' +import '@girs/fontconfig-2.0' +import '@girs/freetype2-2.0' +import '@girs/fwupd-2.0' +import '@girs/gandiva-1.0' +import '@girs/gcab-1.0' +import '@girs/gcalc-1' +import '@girs/gcalc-2' +import '@girs/gck-1' +import '@girs/gck-2' +import '@girs/gconf-2.0' +import '@girs/gcr-3' +import '@girs/gcr-4' +import '@girs/gcrgtk3-4' +import '@girs/gcrgtk4-4' +import '@girs/gcrui-3' +import '@girs/gd-1.0' +import '@girs/gda-5.0' +import '@girs/gda-6.0' +import '@girs/gdata-0.0' +import '@girs/gdaui-5.0' +import '@girs/gdaui-6.0' +import '@girs/gdesktopenums-3.0' +import '@girs/gdk-2.0' +import '@girs/gdk-3.0' +import '@girs/gdk-4.0' +import '@girs/gdkpixbuf-2.0' +import '@girs/gdkpixdata-2.0' +import '@girs/gdkwayland-4.0' +import '@girs/gdkx11-2.0' +import '@girs/gdkx11-3.0' +import '@girs/gdkx11-4.0' +import '@girs/gdl-3' +import '@girs/gdm-1.0' +import '@girs/gedit-3.0' +import '@girs/gee-0.8' +import '@girs/gee-1.0' +import '@girs/gegl-0.3' +import '@girs/gegl-0.4' +import '@girs/geglgtk3-0.1' +import '@girs/geoclue-2.0' +import '@girs/geocodeglib-1.0' +import '@girs/geocodeglib-2.0' +import '@girs/gepub-0.5' +import '@girs/ges-1.0' +import '@girs/gexiv2-0.10' +import '@girs/gfbgraph-0.2' +import '@girs/gfbgraph-0.3' +import '@girs/ggit-1.0' +import '@girs/gio-2.0' +import '@girs/girepository-2.0' +import '@girs/gitg-1.0' +import '@girs/gitgext-1.0' +import '@girs/gjs' +import '@girs/gjsdbus-1.0' +import '@girs/gkbd-3.0' +import '@girs/gl-1.0' +import '@girs/gladeui-2.0' +import '@girs/glib-2.0' +import '@girs/gmenu-3.0' +import '@girs/gmime-3.0' +import '@girs/gmodule-2.0' +import '@girs/gnomeautoar-0.1' +import '@girs/gnomeautoargtk-0.1' +import '@girs/gnomebg-4.0' +import '@girs/gnomebluetooth-1.0' +import '@girs/gnomebluetooth-3.0' +import '@girs/gnomedesktop-3.0' +import '@girs/gnomedesktop-4.0' +import '@girs/gnomekeyring-1.0' +import '@girs/gnomemaps-1.0' +import '@girs/gnomerr-4.0' +import '@girs/goa-1.0' +import '@girs/gobject-2.0' +import '@girs/goocanvas-2.0' +import '@girs/goocanvas-3.0' +import '@girs/govirt-1.0' +import '@girs/gpseq-1.0' +import '@girs/granite-1.0' +import '@girs/granite-7.0' +import '@girs/graphene-1.0' +import '@girs/grl-0.1' +import '@girs/grl-0.2' +import '@girs/grl-0.3' +import '@girs/grlnet-0.1' +import '@girs/grlnet-0.2' +import '@girs/grlnet-0.3' +import '@girs/grlpls-0.2' +import '@girs/grlpls-0.3' +import '@girs/grss-0.7' +import '@girs/gsf-1' +import '@girs/gsignon-1.0' +import '@girs/gsignond-1.0' +import '@girs/gsk-4.0' +import '@girs/gsound-1.0' +import '@girs/gspell-1' +import '@girs/gssdp-1.0' +import '@girs/gssdp-1.2' +import '@girs/gssdp-1.6' +import '@girs/gst-0.10' +import '@girs/gst-1.0' +import '@girs/gstallocators-1.0' +import '@girs/gstapp-1.0' +import '@girs/gstaudio-1.0' +import '@girs/gstbadallocators-1.0' +import '@girs/gstbadaudio-1.0' +import '@girs/gstbase-0.10' +import '@girs/gstbase-1.0' +import '@girs/gstcheck-1.0' +import '@girs/gstcodecs-1.0' +import '@girs/gstcontroller-1.0' +import '@girs/gstfft-1.0' +import '@girs/gstgl-1.0' +import '@girs/gstglegl-1.0' +import '@girs/gstglwayland-1.0' +import '@girs/gstglx11-1.0' +import '@girs/gstinsertbin-1.0' +import '@girs/gstinterfaces-0.10' +import '@girs/gstmpegts-1.0' +import '@girs/gstnet-1.0' +import '@girs/gstpbutils-0.10' +import '@girs/gstpbutils-1.0' +import '@girs/gstplay-1.0' +import '@girs/gstplayer-1.0' +import '@girs/gstriff-1.0' +import '@girs/gstrtp-1.0' +import '@girs/gstrtsp-1.0' +import '@girs/gstrtspserver-1.0' +import '@girs/gstsdp-1.0' +import '@girs/gsttag-0.10' +import '@girs/gsttag-1.0' +import '@girs/gsttranscoder-1.0' +import '@girs/gstvideo-0.10' +import '@girs/gstvideo-1.0' +import '@girs/gstvulkan-1.0' +import '@girs/gstwebrtc-1.0' +import '@girs/gsystem-1.0' +import '@girs/gtef-2' +import '@girs/gtk-2.0' +import '@girs/gtk-3.0' +import '@girs/gtk-4.0' +import '@girs/gtkchamplain-0.12' +import '@girs/gtkclutter-1.0' +import '@girs/gtksource-3.0' +import '@girs/gtksource-4' +import '@girs/gtksource-5' +import '@girs/gtkvnc-2.0' +import '@girs/gtop-2.0' +import '@girs/gucharmap-2.90' +import '@girs/gudev-1.0' +import '@girs/guestfs-1.0' +import '@girs/gupnp-1.0' +import '@girs/gupnp-1.2' +import '@girs/gupnp-1.6' +import '@girs/gupnpav-1.0' +import '@girs/gupnpdlna-1.0' +import '@girs/gupnpdlna-2.0' +import '@girs/gupnpdlnagst-2.0' +import '@girs/gupnpigd-1.0' +import '@girs/gusb-1.0' +import '@girs/gvc-1.0' +import '@girs/gvnc-1.0' +import '@girs/gvncpulse-1.0' +import '@girs/gweather-3.0' +import '@girs/gweather-4.0' +import '@girs/gxml-0.14' +import '@girs/gxml-0.16' +import '@girs/gxml-0.18' +import '@girs/gxml-0.20' +import '@girs/gxps-0.1' +import '@girs/gxps-1.0' +import '@girs/handy-0.0' +import '@girs/handy-1' +import '@girs/harfbuzz-0.0' +import '@girs/ianjuta-3.0' +import '@girs/ibus-1.0' +import '@girs/ical-3.0' +import '@girs/icalglib-3.0' +import '@girs/ide-1.0' +import '@girs/javascriptcore-4.0' +import '@girs/javascriptcore-4.1' +import '@girs/javascriptcore-5.0' +import '@girs/javascriptcore-6.0' +import '@girs/jscore-3.0' +import '@girs/json-1.0' +import '@girs/jsonrpc-1.0' +import '@girs/libmsi-1.0' +import '@girs/libosinfo-1.0' +import '@girs/libvirtgconfig-1.0' +import '@girs/libvirtglib-1.0' +import '@girs/libvirtgobject-1.0' +import '@girs/libxml2-2.0' +import '@girs/manette-0.2' +import '@girs/mash-0.2' +import '@girs/mbim-1.0' +import '@girs/mediaart-1.0' +import '@girs/mediaart-2.0' +import '@girs/meta-10' +import '@girs/meta-11' +import '@girs/meta-12' +import '@girs/meta-13' +import '@girs/metatest-12' +import '@girs/metatest-13' +import '@girs/modemmanager-1.0' +import '@girs/mtk-13' +import '@girs/mx-1.0' +import '@girs/mx-2.0' +import '@girs/mxgtk-1.0' +import '@girs/nautilus-3.0' +import '@girs/networkmanager-1.0' +import '@girs/nice-0.1' +import '@girs/nm-1.0' +import '@girs/nma-1.0' +import '@girs/nmclient-1.0' +import '@girs/nmgtk-1.0' +import '@girs/notify-0.7' +import '@girs/ostree-1.0' +import '@girs/p11kit-1.0' +import '@girs/packagekitglib-1.0' +import '@girs/packagekitplugin-1.0' +import '@girs/panelapplet-4.0' +import '@girs/pango-1.0' +import '@girs/pangocairo-1.0' +import '@girs/pangofc-1.0' +import '@girs/pangoft2-1.0' +import '@girs/pangoot-1.0' +import '@girs/pangoxft-1.0' +import '@girs/parquet-1.0' +import '@girs/peas-1.0' +import '@girs/peas-2' +import '@girs/peasgtk-1.0' +import '@girs/plasma-1.0' +import '@girs/pnl-1.0' +import '@girs/polkit-1.0' +import '@girs/polkitagent-1.0' +import '@girs/poppler-0.18' +import '@girs/qmi-1.0' +import '@girs/qrtr-1.0' +import '@girs/rest-0.7' +import '@girs/rest-1.0' +import '@girs/restextras-0.7' +import '@girs/restextras-1.0' +import '@girs/retro-0.14' +import '@girs/retro-1' +import '@girs/retro-2' +import '@girs/rsvg-2.0' +import '@girs/rygelcore-2.6' +import '@girs/rygelcore-2.8' +import '@girs/rygelrenderer-2.6' +import '@girs/rygelrenderer-2.8' +import '@girs/rygelrenderergst-2.6' +import '@girs/rygelrenderergst-2.8' +import '@girs/rygelserver-2.6' +import '@girs/rygelserver-2.8' +import '@girs/secret-1' +import '@girs/secretunstable-0' +import '@girs/shell-0.1' +import '@girs/shell-12' +import '@girs/shell-13' +import '@girs/shew-0' +import '@girs/shumate-1.0' +import '@girs/signon-2.0' +import '@girs/snapd-1' +import '@girs/socialwebclient-0.25' +import '@girs/soup-2.4' +import '@girs/soup-3.0' +import '@girs/soupgnome-2.4' +import '@girs/spiceclientglib-2.0' +import '@girs/spiceclientgtk-3.0' +import '@girs/st-1.0' +import '@girs/st-12' +import '@girs/st-13' +import '@girs/sushi-1.0' +import '@girs/telepathyfarstream-0.6' +import '@girs/telepathyglib-0.12' +import '@girs/telepathylogger-0.2' +import '@girs/template-1.0' +import '@girs/tepl-4' +import '@girs/tepl-5' +import '@girs/tepl-6' +import '@girs/timezonemap-1.0' +import '@girs/totem-1.0' +import '@girs/totemplparser-1.0' +import '@girs/tracker-1.0' +import '@girs/tracker-2.0' +import '@girs/tracker-3.0' +import '@girs/trackercontrol-1.0' +import '@girs/trackercontrol-2.0' +import '@girs/trackerminer-1.0' +import '@girs/trackerminer-2.0' +import '@girs/udisks-2.0' +import '@girs/uhm-0.0' +import '@girs/unique-3.0' +import '@girs/unity-6.0' +import '@girs/unity-7.0' +import '@girs/unityextras-7.0' +import '@girs/upowerglib-1.0' +import '@girs/vda-1' +import '@girs/vgda-1' +import '@girs/vgpg-1' +import '@girs/vgsl-1' +import '@girs/vips-8.0' +import '@girs/vpg-1' +import '@girs/vsqlite-1' +import '@girs/vte-2.91' +import '@girs/vte-3.91' +import '@girs/vte-4-2.91' +import '@girs/vulkan-1.0' +import '@girs/webkit-6.0' +import '@girs/webkit2-4.0' +import '@girs/webkit2-4.1' +import '@girs/webkit2-5.0' +import '@girs/webkit2webextension-4.0' +import '@girs/webkit2webextension-4.1' +import '@girs/webkit2webextension-5.0' +import '@girs/webkitwebextension-6.0' +import '@girs/webkitwebprocessextension-6.0' +import '@girs/win32-1.0' +import '@girs/wnck-3.0' +import '@girs/xdp-1.0' +import '@girs/xdpgtk3-1.0' +import '@girs/xdpgtk4-1.0' +import '@girs/xfixes-4.0' +import '@girs/xft-2.0' +import '@girs/xkl-1.0' +import '@girs/xlib-2.0' +import '@girs/xrandr-1.3' +import '@girs/zeitgeist-2.0' +import '@girs/zpj-0.0' diff --git a/local/package.json b/local/package.json new file mode 100644 index 000000000..f68e02ef2 --- /dev/null +++ b/local/package.json @@ -0,0 +1,9 @@ +{ + "private": true, + "devDependencies": { + "typescript": "^5.2.2" + }, + "scripts": { + "validate:types": "tsc --project tsconfig.json" + } +} diff --git a/local/tsconfig.json b/local/tsconfig.json new file mode 100644 index 000000000..7ccbab9b0 --- /dev/null +++ b/local/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "types": [], + "moduleResolution": "Bundler", + "module": "ESNext", + "strict": true, + "noEmit": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "skipLibCheck": false, + }, + "files": ["all.ts"], + "exclude": [] + } + \ No newline at end of file diff --git a/local/yarn.lock b/local/yarn.lock new file mode 100644 index 000000000..4ad27cba5 --- /dev/null +++ b/local/yarn.lock @@ -0,0 +1,34 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 8 + cacheKey: 10 + +"root-workspace-0b6124@workspace:.": + version: 0.0.0-use.local + resolution: "root-workspace-0b6124@workspace:." + dependencies: + typescript: "npm:^5.2.2" + languageName: unknown + linkType: soft + +"typescript@npm:^5.2.2": + version: 5.4.2 + resolution: "typescript@npm:5.4.2" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/f8cfdc630ab1672f004e9561eb2916935b2d267792d07ce93e97fc601c7a65191af32033d5e9c0169b7dc37da7db9bf320f7432bc84527cb7697effaa4e4559d + languageName: node + linkType: hard + +"typescript@patch:typescript@npm%3A^5.2.2#optional!builtin": + version: 5.4.2 + resolution: "typescript@patch:typescript@npm%3A5.4.2#optional!builtin::version=5.4.2&hash=d69c25" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/ef4fc2994cc0219dc9ada94c92106ba8d44cbfd7a0328ed6f8d730311caf66e114cdfa07fbc6f369bfc0fc182d9493851b3bf1644c06fc5818690b19ee960d72 + languageName: node + linkType: hard diff --git a/package.json b/package.json index dd4bb3c70..dea43b03c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "validate": "yarn workspaces foreach -v --all --parallel run validate", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app", - "validate:types:local": "tsc --project tsconfig.json", + "validate:types:local": "cd local && yarn install && tsc --project tsconfig.json", "clear": "yarn clear:build && yarn clear:types", "clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build", "clear:types": "rimraf ./@types", diff --git a/yarn.lock b/yarn.lock index ae2f3c6d2..fe0953908 100644 --- a/yarn.lock +++ b/yarn.lock @@ -290,13 +290,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/aix-ppc64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/aix-ppc64@npm:0.20.0" - conditions: os=aix & cpu=ppc64 - languageName: node - linkType: hard - "@esbuild/aix-ppc64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/aix-ppc64@npm:0.20.1" @@ -311,13 +304,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-arm64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/android-arm64@npm:0.20.0" - conditions: os=android & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/android-arm64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/android-arm64@npm:0.20.1" @@ -332,13 +318,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-arm@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/android-arm@npm:0.20.0" - conditions: os=android & cpu=arm - languageName: node - linkType: hard - "@esbuild/android-arm@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/android-arm@npm:0.20.1" @@ -353,13 +332,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/android-x64@npm:0.20.0" - conditions: os=android & cpu=x64 - languageName: node - linkType: hard - "@esbuild/android-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/android-x64@npm:0.20.1" @@ -374,13 +346,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/darwin-arm64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/darwin-arm64@npm:0.20.0" - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/darwin-arm64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/darwin-arm64@npm:0.20.1" @@ -395,13 +360,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/darwin-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/darwin-x64@npm:0.20.0" - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - "@esbuild/darwin-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/darwin-x64@npm:0.20.1" @@ -416,13 +374,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/freebsd-arm64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/freebsd-arm64@npm:0.20.0" - conditions: os=freebsd & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/freebsd-arm64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/freebsd-arm64@npm:0.20.1" @@ -437,13 +388,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/freebsd-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/freebsd-x64@npm:0.20.0" - conditions: os=freebsd & cpu=x64 - languageName: node - linkType: hard - "@esbuild/freebsd-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/freebsd-x64@npm:0.20.1" @@ -458,13 +402,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-arm64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-arm64@npm:0.20.0" - conditions: os=linux & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/linux-arm64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-arm64@npm:0.20.1" @@ -479,13 +416,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-arm@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-arm@npm:0.20.0" - conditions: os=linux & cpu=arm - languageName: node - linkType: hard - "@esbuild/linux-arm@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-arm@npm:0.20.1" @@ -500,13 +430,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-ia32@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-ia32@npm:0.20.0" - conditions: os=linux & cpu=ia32 - languageName: node - linkType: hard - "@esbuild/linux-ia32@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-ia32@npm:0.20.1" @@ -521,13 +444,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-loong64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-loong64@npm:0.20.0" - conditions: os=linux & cpu=loong64 - languageName: node - linkType: hard - "@esbuild/linux-loong64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-loong64@npm:0.20.1" @@ -542,13 +458,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-mips64el@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-mips64el@npm:0.20.0" - conditions: os=linux & cpu=mips64el - languageName: node - linkType: hard - "@esbuild/linux-mips64el@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-mips64el@npm:0.20.1" @@ -563,13 +472,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-ppc64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-ppc64@npm:0.20.0" - conditions: os=linux & cpu=ppc64 - languageName: node - linkType: hard - "@esbuild/linux-ppc64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-ppc64@npm:0.20.1" @@ -584,13 +486,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-riscv64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-riscv64@npm:0.20.0" - conditions: os=linux & cpu=riscv64 - languageName: node - linkType: hard - "@esbuild/linux-riscv64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-riscv64@npm:0.20.1" @@ -605,13 +500,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-s390x@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-s390x@npm:0.20.0" - conditions: os=linux & cpu=s390x - languageName: node - linkType: hard - "@esbuild/linux-s390x@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-s390x@npm:0.20.1" @@ -626,13 +514,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/linux-x64@npm:0.20.0" - conditions: os=linux & cpu=x64 - languageName: node - linkType: hard - "@esbuild/linux-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/linux-x64@npm:0.20.1" @@ -647,13 +528,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/netbsd-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/netbsd-x64@npm:0.20.0" - conditions: os=netbsd & cpu=x64 - languageName: node - linkType: hard - "@esbuild/netbsd-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/netbsd-x64@npm:0.20.1" @@ -668,13 +542,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/openbsd-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/openbsd-x64@npm:0.20.0" - conditions: os=openbsd & cpu=x64 - languageName: node - linkType: hard - "@esbuild/openbsd-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/openbsd-x64@npm:0.20.1" @@ -689,13 +556,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/sunos-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/sunos-x64@npm:0.20.0" - conditions: os=sunos & cpu=x64 - languageName: node - linkType: hard - "@esbuild/sunos-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/sunos-x64@npm:0.20.1" @@ -710,13 +570,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/win32-arm64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/win32-arm64@npm:0.20.0" - conditions: os=win32 & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/win32-arm64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/win32-arm64@npm:0.20.1" @@ -731,13 +584,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/win32-ia32@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/win32-ia32@npm:0.20.0" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - "@esbuild/win32-ia32@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/win32-ia32@npm:0.20.1" @@ -752,13 +598,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/win32-x64@npm:0.20.0": - version: 0.20.0 - resolution: "@esbuild/win32-x64@npm:0.20.0" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - "@esbuild/win32-x64@npm:0.20.1": version: 0.20.1 resolution: "@esbuild/win32-x64@npm:0.20.1" @@ -2857,86 +2696,6 @@ __metadata: languageName: node linkType: hard -"esbuild@npm:^0.20.0": - version: 0.20.0 - resolution: "esbuild@npm:0.20.0" - dependencies: - "@esbuild/aix-ppc64": "npm:0.20.0" - "@esbuild/android-arm": "npm:0.20.0" - "@esbuild/android-arm64": "npm:0.20.0" - "@esbuild/android-x64": "npm:0.20.0" - "@esbuild/darwin-arm64": "npm:0.20.0" - "@esbuild/darwin-x64": "npm:0.20.0" - "@esbuild/freebsd-arm64": "npm:0.20.0" - "@esbuild/freebsd-x64": "npm:0.20.0" - "@esbuild/linux-arm": "npm:0.20.0" - "@esbuild/linux-arm64": "npm:0.20.0" - "@esbuild/linux-ia32": "npm:0.20.0" - "@esbuild/linux-loong64": "npm:0.20.0" - "@esbuild/linux-mips64el": "npm:0.20.0" - "@esbuild/linux-ppc64": "npm:0.20.0" - "@esbuild/linux-riscv64": "npm:0.20.0" - "@esbuild/linux-s390x": "npm:0.20.0" - "@esbuild/linux-x64": "npm:0.20.0" - "@esbuild/netbsd-x64": "npm:0.20.0" - "@esbuild/openbsd-x64": "npm:0.20.0" - "@esbuild/sunos-x64": "npm:0.20.0" - "@esbuild/win32-arm64": "npm:0.20.0" - "@esbuild/win32-ia32": "npm:0.20.0" - "@esbuild/win32-x64": "npm:0.20.0" - dependenciesMeta: - "@esbuild/aix-ppc64": - optional: true - "@esbuild/android-arm": - optional: true - "@esbuild/android-arm64": - optional: true - "@esbuild/android-x64": - optional: true - "@esbuild/darwin-arm64": - optional: true - "@esbuild/darwin-x64": - optional: true - "@esbuild/freebsd-arm64": - optional: true - "@esbuild/freebsd-x64": - optional: true - "@esbuild/linux-arm": - optional: true - "@esbuild/linux-arm64": - optional: true - "@esbuild/linux-ia32": - optional: true - "@esbuild/linux-loong64": - optional: true - "@esbuild/linux-mips64el": - optional: true - "@esbuild/linux-ppc64": - optional: true - "@esbuild/linux-riscv64": - optional: true - "@esbuild/linux-s390x": - optional: true - "@esbuild/linux-x64": - optional: true - "@esbuild/netbsd-x64": - optional: true - "@esbuild/openbsd-x64": - optional: true - "@esbuild/sunos-x64": - optional: true - "@esbuild/win32-arm64": - optional: true - "@esbuild/win32-ia32": - optional: true - "@esbuild/win32-x64": - optional: true - bin: - esbuild: bin/esbuild - checksum: 10/d881b7462fac5ceea071417984bfb835f60c1ddf83bc018c755cbd7aefedfde13e9e1aec730d4605f5d7ac61cbe0ac5d37a73c9401abe8afb7c39458d84bbfa3 - languageName: node - linkType: hard - "esbuild@npm:^0.20.1": version: 0.20.1 resolution: "esbuild@npm:0.20.1" @@ -5732,16 +5491,6 @@ __metadata: languageName: unknown linkType: soft -"ts-for-gir-node-gtk-gtk-4-application-example@workspace:examples/node-gtk/gtk-4-application": - version: 0.0.0-use.local - resolution: "ts-for-gir-node-gtk-gtk-4-application-example@workspace:examples/node-gtk/gtk-4-application" - dependencies: - "@ts-for-gir/cli": "workspace:^" - esbuild: "npm:^0.20.0" - typescript: "npm:5.2.2" - languageName: unknown - linkType: soft - "ts-for-gir-run-async-example@workspace:examples/gjs/run-async": version: 0.0.0-use.local resolution: "ts-for-gir-run-async-example@workspace:examples/gjs/run-async"