Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gi.ts/parser

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gi.ts/parser - npm Package Compare versions

Comparing version 2.0.0-alpha.0 to 2.0.0

77

dist/parser.js

@@ -1,15 +0,66 @@

import { parse } from "fast-xml-parser";
import { XMLParser } from "fast-xml-parser";
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: "$",
textNodeName: "_",
ignoreAttributes: false,
removeNSPrefix: false,
allowBooleanAttributes: true,
parseTagValue: true,
parseAttributeValue: false,
trimValues: true,
isArray: (name, _jpath, isLeafNode, _isAttribute) => {
if (isArrayProperty.includes(name)) {
return true;
}
return !isLeafNode;
},
});
export function parseGir(contents) {
return parse(contents, {
attributeNamePrefix: "",
attrNodeName: "$",
textNodeName: "_",
ignoreAttributes: false,
ignoreNameSpace: false,
allowBooleanAttributes: true,
parseNodeValue: true,
parseAttributeValue: false,
trimValues: true,
arrayMode: true
});
return parser.parse(contents);
}

431

dist/xml.d.ts

@@ -1,12 +0,13 @@

export declare enum Direction {
export declare enum GirDirection {
In = "in",
Inout = "inout",
Out = "out"
Out = "out",
InOut = "in-out"
}
export interface GirXML {
repository: Repository[];
repository: GirRepository[];
}
declare type UnparsedNumber = string;
declare type BinaryOption = "0" | "1";
export interface Repository {
export type GirUnparsedNumber = string;
export type GirBoolean = "0" | "1";
export interface GirRepository {
$: {

@@ -17,9 +18,9 @@ version?: string;

};
include: Include[];
"c:include": CInclude[];
package: Package[];
namespace: Namespace[];
include?: GirInclude[];
"c:include": GirCInclude[];
package: GirPackage[];
namespace?: GirNamespace[];
}
export interface Namespace {
$: InfoAttrs & {
export interface GirNamespace {
$: GirInfoAttrs & {
name: string;

@@ -32,16 +33,16 @@ version: string;

};
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[];
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[];
}
export interface Annotation {
export interface GirAnnotation {
$: {

@@ -52,3 +53,3 @@ name: string;

}
export interface CInclude {
export interface GirCInclude {
$: {

@@ -58,3 +59,3 @@ name: string;

}
export interface Include {
export interface GirInclude {
$: {

@@ -65,3 +66,3 @@ name: string;

}
export interface Package {
export interface GirPackage {
$: {

@@ -71,11 +72,11 @@ name: string;

}
export interface AliasElement extends InfoElements {
$: InfoAttrs & {
export interface GirAliasElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;
"c:type": string;
"c:type"?: string;
};
type: Type[];
type?: GirType[];
}
export interface InterfaceElement extends InfoElements {
$: {
export interface GirInterfaceElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;

@@ -88,16 +89,17 @@ "glib:type-name": string;

};
prerequisite?: Prerequisite[];
implements?: Implements[];
function?: FunctionElement[];
constructors?: ConstructorElement[];
method?: MethodElement[];
"virtual-method"?: VirtualMethodElement[];
field?: FieldElement[];
property?: PropertyElement[];
signal?: SignalElement[];
callback?: CallbackElement[];
constant?: ConstantElement[];
prerequisite?: GirPrerequisite[];
implements?: GirImplements[];
function?: GirFunctionElement[];
constructors?: GirConstructorElement[];
method?: GirMethodElement[];
"virtual-method"?: GirVirtualMethodElement[];
field?: GirFieldElement[];
property?: GirPropertyElement[];
signal?: GirSignalElement[];
"glib:signal"?: GirSignalElement[];
callback?: GirCallbackElement[];
constant?: GirConstantElement[];
}
export interface ClassElement extends InfoElements {
$: InfoAttrs & {
export interface GirClassElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;

@@ -114,20 +116,22 @@ "glib:type-name": string;

"c:symbol-prefix"?: string;
abstract?: BinaryOption | BinaryOption;
"glib:fundamental"?: BinaryOption | BinaryOption;
abstract?: GirBoolean;
"glib:fundamental"?: GirBoolean;
final: GirBoolean;
};
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[];
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 BoxedElement {
$: InfoAttrs & {
export interface GirBoxedElement {
$: GirInfoAttrs & {
"glib:name": string;

@@ -138,24 +142,26 @@ "c:symbol-prefix"?: string;

};
function?: FunctionElement[];
function?: GirFunctionElement[];
}
export interface RecordElement extends InfoElements {
$: InfoAttrs & {
export interface GirRecordElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;
"c:type"?: string;
disguised?: BinaryOption | BinaryOption;
disguised?: GirBoolean;
opaque?: GirBoolean;
pointer?: GirBoolean;
"glib:type-name"?: string;
"glib:get-type"?: string;
"c:symbol-prefix"?: string;
foreign?: BinaryOption | BinaryOption;
foreign?: GirBoolean;
"glib:is-gtype-struct-for"?: string;
};
field?: FieldElement[];
function?: FunctionElement[];
union?: UnionElement[];
method?: MethodElement[];
"constructor"?: ConstructorElement[];
property?: PropertyElement[];
field?: GirFieldElement[];
function?: GirFunctionElement[];
union?: GirUnionElement[];
method?: GirMethodElement[];
constructor?: GirConstructorElement[];
property?: GirPropertyElement[];
}
export interface InfoAttrs {
introspectable?: BinaryOption | BinaryOption;
export interface GirInfoAttrs {
introspectable?: GirBoolean;
deprecated?: string;

@@ -166,3 +172,3 @@ "deprecated-version"?: string;

}
export interface DocElement {
export interface GirDocElement {
"doc-version"?: [

@@ -215,7 +221,7 @@ {

}
export interface InfoElements extends DocElement {
annotation: Annotation[];
export interface GirInfoElements extends GirDocElement {
annotation: GirAnnotation[];
}
export interface ConstantElement extends InfoElements, AnyType {
$: InfoAttrs & {
export interface GirConstantElement extends GirInfoElements, GirAnyType {
$: GirInfoAttrs & {
name: string;

@@ -227,79 +233,82 @@ value: string;

}
export interface PropertyElement extends InfoElements, AnyType {
$: InfoAttrs & {
export interface GirPropertyElement extends GirInfoElements, GirAnyType {
$: GirInfoAttrs & {
name: string;
writable?: BinaryOption | BinaryOption;
readable?: BinaryOption | BinaryOption;
construct?: BinaryOption | BinaryOption;
"construct-only"?: BinaryOption | BinaryOption;
TransferOwnership?: any;
};
writable?: GirBoolean;
readable?: GirBoolean;
construct?: GirBoolean;
"construct-only"?: GirBoolean;
setter?: string;
getter?: string;
"default-value"?: string;
} & Partial<GirTransferOwnership>;
}
export interface SignalElement extends InfoElements {
$: InfoAttrs & {
export interface GirSignalElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;
detailed?: BinaryOption | BinaryOption;
detailed?: GirBoolean;
when?: "first" | "last" | "cleanup";
action?: BinaryOption | BinaryOption;
"no-hooks"?: BinaryOption | BinaryOption;
"no-recurse"?: BinaryOption | BinaryOption;
action?: GirBoolean;
"no-hooks"?: GirBoolean;
"no-recurse"?: GirBoolean;
};
parameters?: [CallableParams];
"return-value"?: CallableReturn[];
parameters?: [GirCallableParams];
"return-value"?: GirCallableReturn[];
}
export interface FieldElement extends InfoElements, AnyType {
$: InfoAttrs & {
export interface GirFieldElement extends GirInfoElements, GirAnyType {
$: GirInfoAttrs & {
name: string;
writable?: BinaryOption | BinaryOption;
readable?: BinaryOption | BinaryOption;
private?: BinaryOption | BinaryOption;
bits?: UnparsedNumber;
writable?: GirBoolean;
readable?: GirBoolean;
private?: GirBoolean;
bits?: GirUnparsedNumber;
};
callback?: CallbackElement[];
callback?: GirCallbackElement[];
}
export interface CallbackElement extends InfoElements {
$: InfoAttrs & {
export interface GirCallbackElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;
"c:type"?: string;
throws?: BinaryOption | BinaryOption;
throws?: GirBoolean;
"glib:type-name"?: string;
};
parameters?: [CallableParams];
"return-value"?: CallableReturn[];
parameters?: [GirCallableParams];
"return-value"?: GirCallableReturn[];
}
export interface Implements {
$: InfoAttrs & {
export interface GirImplements {
$: GirInfoAttrs & {
name: string;
};
}
export interface Prerequisite {
$: InfoAttrs & {
name: string;
export interface GirPrerequisite {
$: {
name?: string;
};
}
export interface AnyType {
type?: Type[];
array?: ArrayType[];
export interface GirAnyType {
type?: GirType[];
array?: GirArrayType[];
}
export interface Type extends DocElement {
$: InfoAttrs & {
export interface GirType extends GirDocElement {
$: GirInfoAttrs & {
name?: string;
"c:type"?: string;
introspectable?: BinaryOption | BinaryOption;
introspectable?: GirBoolean;
};
array?: ArrayType[];
type: Type[];
array?: GirArrayType[];
type: GirType[];
}
export interface ArrayType {
$: InfoAttrs & {
export interface GirArrayType {
$: GirInfoAttrs & {
name?: string;
"zero-terminated"?: BinaryOption | BinaryOption;
"fixed-size"?: UnparsedNumber;
introspectable?: BinaryOption | BinaryOption;
length?: UnparsedNumber;
"zero-terminated"?: GirBoolean;
"fixed-size"?: GirUnparsedNumber;
introspectable?: GirBoolean;
length?: GirUnparsedNumber;
"c:type"?: string;
};
array?: ArrayType[];
type?: Type[];
array?: GirArrayType[];
type?: GirType[];
}
export declare enum TransferOwnershipType {
export declare enum GirTransferOwnershipType {
Container = "container",

@@ -309,11 +318,11 @@ Full = "full",

}
export interface TransferOwnership {
"transfer-ownership": TransferOwnershipType;
export interface GirTransferOwnership {
"transfer-ownership": GirTransferOwnershipType;
}
export interface ConstructorElement {
$: InfoAttrs & CallableAttrs;
parameters?: [CallableParams];
"return-value"?: CallableReturn[];
export interface GirConstructorElement {
$: GirInfoAttrs & GirCallableAttrs;
parameters?: [GirCallableParams];
"return-value"?: GirCallableReturn[];
}
export interface CallableAttrs {
export interface GirCallableAttrs {
name: string;

@@ -323,66 +332,74 @@ "c:identifier"?: string;

shadows?: string;
throws?: BinaryOption | BinaryOption;
throws?: GirBoolean;
"moved-to"?: string[];
}
export interface VarArgs {
$: InfoAttrs;
export interface GirVarArgs {
$: GirInfoAttrs;
}
export interface CallableParamElement extends DocElement, AnyType {
$: InfoAttrs & Partial<TransferOwnership> & {
export interface GirCallableParamElement extends GirDocElement, GirAnyType {
$: GirInfoAttrs & Partial<GirTransferOwnership> & {
name?: string;
nullable?: BinaryOption | BinaryOption;
"allow-none"?: BinaryOption | BinaryOption;
introspectable?: BinaryOption | BinaryOption;
closure?: UnparsedNumber;
destroy?: UnparsedNumber;
nullable?: GirBoolean;
"null-ok"?: GirBoolean;
"allow-none"?: GirBoolean;
introspectable?: GirBoolean;
closure?: GirUnparsedNumber;
destroy?: GirUnparsedNumber;
scope?: "notified" | "async" | "call";
direction?: Direction;
"caller-allocates"?: BinaryOption | BinaryOption;
optional?: BinaryOption | BinaryOption;
skip?: BinaryOption | BinaryOption;
direction?: GirDirection;
"caller-allocates"?: GirBoolean;
optional?: GirBoolean;
skip?: GirBoolean;
};
varargs?: VarArgs[];
varargs?: GirVarArgs[];
}
export interface CallableParams {
parameter: CallableParamElement[];
"instance-parameter"?: AnyType & {
$: Partial<{
name: string;
nullable?: BinaryOption | BinaryOption;
"allow-none"?: BinaryOption | BinaryOption;
direction?: Direction;
"caller-allocates"?: BinaryOption | BinaryOption;
}> & Partial<TransferOwnership>;
}[];
export interface GirCallableParams {
parameter: GirCallableParamElement[];
"instance-parameter"?: GirInstanceParameter[];
}
export interface CallableReturn extends AnyType, DocElement {
export interface GirInstanceParameter extends GirAnyType {
$: Partial<{
name: string;
nullable?: GirBoolean;
"allow-none"?: GirBoolean;
"null-ok"?: GirBoolean;
direction?: GirDirection;
"caller-allocates"?: GirBoolean;
}> & Partial<GirTransferOwnership>;
type?: GirType[];
}
export interface GirCallableReturn extends GirAnyType, GirDocElement {
$: {
introspectable?: BinaryOption | BinaryOption;
nullable?: BinaryOption | BinaryOption;
closure?: UnparsedNumber;
name?: string;
introspectable?: GirBoolean;
nullable?: GirBoolean;
closure?: GirUnparsedNumber;
scope?: "notified" | "async" | "call";
destroy?: UnparsedNumber;
skip?: BinaryOption | BinaryOption;
"allow-none"?: BinaryOption | BinaryOption;
} & Partial<TransferOwnership>;
destroy?: GirUnparsedNumber;
skip?: GirBoolean;
"allow-none"?: GirBoolean;
} & Partial<GirTransferOwnership>;
}
export interface FunctionElement extends DocElement {
$: InfoAttrs & CallableAttrs;
parameters?: [CallableParams];
"return-value"?: CallableReturn[];
export interface GirFunctionElement extends GirDocElement {
$: GirInfoAttrs & GirCallableAttrs;
parameters?: [GirCallableParams];
"return-value"?: GirCallableReturn[];
}
export interface MethodElement extends DocElement {
$: InfoAttrs & CallableAttrs;
parameters?: [CallableParams];
"return-value"?: CallableReturn[];
export interface GirMethodElement extends GirDocElement {
$: GirInfoAttrs & GirCallableAttrs & {
"glib:set-property": string;
"glib:get-property": string;
};
parameters?: [GirCallableParams];
"return-value"?: GirCallableReturn[];
}
export interface VirtualMethodElement extends DocElement {
$: InfoAttrs & CallableAttrs & {
export interface GirVirtualMethodElement extends GirDocElement {
$: GirInfoAttrs & GirCallableAttrs & {
invoker?: string;
};
parameters?: [CallableParams];
"return-value"?: CallableReturn[];
parameters?: [GirCallableParams];
"return-value"?: GirCallableReturn[];
}
export interface UnionElement extends InfoElements {
$: InfoAttrs & {
export interface GirUnionElement extends GirInfoElements {
$: GirInfoAttrs & {
name?: string;

@@ -394,10 +411,10 @@ "c: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 {
$: InfoAttrs & {
export interface GirBitfieldElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;

@@ -408,7 +425,7 @@ "c:type": string;

};
member: MemberElement[];
function: FunctionElement[];
member: GirMemberElement[];
function: GirFunctionElement[];
}
export interface EnumElement extends InfoElements {
$: InfoAttrs & {
export interface GirEnumElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;

@@ -420,13 +437,23 @@ "c:type": string;

};
member?: MemberElement[];
function?: FunctionElement[];
member?: GirMemberElement[];
function?: GirFunctionElement[];
}
export interface MemberElement extends InfoElements {
$: InfoAttrs & {
export interface GirFieldElement extends GirInfoElements, GirAnyType {
$: GirInfoAttrs & {
name: string;
writable?: GirBoolean;
readable?: GirBoolean;
private?: GirBoolean;
bits?: GirUnparsedNumber;
};
callback?: GirCallbackElement[];
}
export interface GirMemberElement extends GirInfoElements {
$: GirInfoAttrs & {
name: string;
value: string;
"c:identifier": string;
"glib:nick"?: string;
"glib:name"?: string;
};
}
export {};

@@ -1,12 +0,13 @@

export var Direction;
(function (Direction) {
Direction["In"] = "in";
Direction["Inout"] = "inout";
Direction["Out"] = "out";
})(Direction || (Direction = {}));
export var TransferOwnershipType;
(function (TransferOwnershipType) {
TransferOwnershipType["Container"] = "container";
TransferOwnershipType["Full"] = "full";
TransferOwnershipType["None"] = "none";
})(TransferOwnershipType || (TransferOwnershipType = {}));
export var GirDirection;
(function (GirDirection) {
GirDirection["In"] = "in";
GirDirection["Inout"] = "inout";
GirDirection["Out"] = "out";
GirDirection["InOut"] = "in-out";
})(GirDirection || (GirDirection = {}));
export var GirTransferOwnershipType;
(function (GirTransferOwnershipType) {
GirTransferOwnershipType["Container"] = "container";
GirTransferOwnershipType["Full"] = "full";
GirTransferOwnershipType["None"] = "none";
})(GirTransferOwnershipType || (GirTransferOwnershipType = {}));
{
"name": "@gi.ts/parser",
"version": "2.0.0-alpha.0",
"version": "2.0.0",
"type": "module",

@@ -31,9 +31,13 @@ "main": "dist/lib.js",

"dependencies": {
"fast-xml-parser": "^3.17.5"
"fast-xml-parser": "^4.3.5"
},
"devDependencies": {
"@types/xml2js": "^0.4.4",
"typescript": "5.1.3"
},
"gitHead": "18a5d3b74bec68a3530016e2c1dd69d7f235a1e0"
}
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"typescript": "^5.4.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc