@gi.ts/node-loader
Advanced tools
Comparing version 1.4.0 to 1.5.0
interface Namespace { | ||
name: string; | ||
api_version: string; | ||
c_prefix: string; | ||
c_prefix: string[]; | ||
} | ||
@@ -11,9 +11,9 @@ export declare type GirInfo = Namespace & { | ||
}; | ||
export declare function generate(gir_path: any): Promise<GirInfo | null>; | ||
export declare function generate(gir_path: any, verbose?: boolean): Promise<GirInfo | null>; | ||
export declare function generateAll(gir_dir?: string): string[]; | ||
export declare function resolveLibraries(libraries: { | ||
[key: string]: string | string[]; | ||
}): Promise<Map<string, { | ||
}, verbose?: boolean): Promise<Map<string, { | ||
[version: string]: GirInfo; | ||
}>>; | ||
export {}; |
@@ -26,10 +26,12 @@ "use strict"; | ||
const fs = __importStar(require("fs")); | ||
// Depends on: sax, xmlbuilder, util.promisify | ||
const xml2js_1 = require("xml2js"); | ||
const parser = new xml2js_1.Parser(); | ||
function read_gir(path) { | ||
const data = fs.readFileSync(path); | ||
return new Promise((res, rej) => parser.parseString(data, (err, result) => (err ? rej(err) : res(result)))); | ||
const path = __importStar(require("path")); | ||
const parser_1 = require("@gi.ts/parser"); | ||
function readGir(path) { | ||
const data = fs.readFileSync(path, { | ||
encoding: 'utf-8' | ||
}); | ||
return parser_1.parser.parseGir(data); | ||
} | ||
function process_namespace(namespace) { | ||
var _a, _b; | ||
// adapt the xml2js api | ||
@@ -40,3 +42,3 @@ namespace.attributes = namespace[0]["$"]; | ||
api_version: namespace.attributes["version"], | ||
c_prefix: namespace.attributes["c:symbol-prefixes"] | ||
c_prefix: (_b = (_a = namespace.attributes["c:symbol-prefixes"]) === null || _a === void 0 ? void 0 : _a.split(",")) !== null && _b !== void 0 ? _b : [] | ||
}; | ||
@@ -53,3 +55,3 @@ } | ||
} | ||
async function generate(gir_path) { | ||
async function generate(gir_path, verbose = false) { | ||
if (typeof gir_path === "object") | ||
@@ -59,4 +61,6 @@ return gir_path; | ||
try { | ||
console.log(`Found ${gir_path}...`); | ||
gir = await read_gir(gir_path); | ||
if (verbose) { | ||
console.log(`Found ${gir_path}...`); | ||
} | ||
gir = readGir(gir_path); | ||
} | ||
@@ -68,3 +72,3 @@ catch (err) { | ||
} | ||
const namespace = gir.repository.namespace; | ||
const namespace = gir.repository[0].namespace; | ||
const ns_info = Object.assign({}, process_namespace(namespace)); | ||
@@ -94,3 +98,4 @@ const scraper_info = Object.assign(Object.assign({}, ns_info), { path: gir_path, id: scraper_code(ns_info), slug: generate_slug(ns_info) }); | ||
.map(dir => { | ||
return [`${dir}/*.gir`, `${dir}/gir-1.0/*.gir`]; | ||
const resolved = path.resolve(dir); | ||
return [`${resolved}/*.gir`, `${resolved}/gir-1.0/*.gir`]; | ||
}) | ||
@@ -105,5 +110,7 @@ .reduce((prev, [dir, girdir]) => [...prev, ...glob_1.sync(dir), ...glob_1.sync(girdir)], []); | ||
exports.generateAll = generateAll; | ||
async function resolveLibraries(libraries) { | ||
async function resolveLibraries(libraries, verbose = false) { | ||
var _a; | ||
let allLibraries = (await Promise.all(generateAll().map(l => generate(l)))).filter((l) => l != null); | ||
console.log("Finding GIR files..."); | ||
let allLibraries = (await Promise.all(generateAll().map(l => generate(l, verbose)))).filter((l) => l != null); | ||
console.log("Resolving libraries..."); | ||
const libraryMap = new Map(); | ||
@@ -110,0 +117,0 @@ for (const library of allLibraries) { |
{ | ||
"name": "@gi.ts/node-loader", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"main": "dist/loader.js", | ||
@@ -20,3 +20,3 @@ "types": "dist/loader.d.ts", | ||
"dependencies": { | ||
"@gi.ts/parser": "^1.4.0" | ||
"@gi.ts/parser": "^1.5.0" | ||
}, | ||
@@ -29,3 +29,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "a94a1cd0c94d8c42b284a57fe2a6c712dd2caace" | ||
"gitHead": "db567857bb7e2675d07b8ef8d95541b5000a7e0a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
8656
7
169
1
3
Updated@gi.ts/parser@^1.5.0