@ts-for-gir/cli 4.0.0-rc.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -3
- package/bin/ts-for-gir +458 -130
- package/bin/ts-for-gir-gjs +1213 -0
- package/package.json +194 -83
- package/src/commands/create.ts +84 -12
- package/src/commands/index.ts +1 -0
- package/src/commands/self-update.ts +142 -0
- package/src/config/config-loader.ts +6 -2
- package/src/config/defaults.ts +14 -0
- package/src/config/options.ts +2 -2
- package/src/start.ts +20 -6
- package/src/types/command-args.ts +8 -1
- package/dist-templates/types-locally/.ts-for-girrc.js +0 -6
- package/dist-templates/types-locally/README.md +0 -15
- package/dist-templates/types-locally/esbuild.ts +0 -10
- package/dist-templates/types-locally/main.ts +0 -21
- package/dist-templates/types-locally/package.json +0 -18
- package/dist-templates/types-locally/tsconfig.json +0 -17
- package/dist-templates/types-npm/README.md +0 -14
- package/dist-templates/types-npm/esbuild.ts +0 -10
- package/dist-templates/types-npm/main.ts +0 -19
- package/dist-templates/types-npm/package.json +0 -23
- package/dist-templates/types-npm/tsconfig.json +0 -15
- package/dist-templates/types-workspace/.ts-for-girrc.js +0 -12
- package/dist-templates/types-workspace/README.md +0 -26
- package/dist-templates/types-workspace/package.json +0 -22
- package/dist-templates/types-workspace/packages/app/esbuild.ts +0 -10
- package/dist-templates/types-workspace/packages/app/main.ts +0 -19
- package/dist-templates/types-workspace/packages/app/package.json +0 -23
- package/dist-templates/types-workspace/packages/app/tsconfig.json +0 -15
- package/dist-templates/types-workspace/tsconfig.json +0 -11
package/bin/ts-for-gir
CHANGED
|
@@ -29,9 +29,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// ../../node_modules/lodash/lodash.js
|
|
33
33
|
var require_lodash = __commonJS({
|
|
34
|
-
"
|
|
34
|
+
"../../node_modules/lodash/lodash.js"(exports2, module) {
|
|
35
35
|
(function() {
|
|
36
36
|
var undefined2;
|
|
37
37
|
var VERSION = "4.18.1";
|
|
@@ -3346,7 +3346,7 @@ var require_lodash = __commonJS({
|
|
|
3346
3346
|
}
|
|
3347
3347
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
|
|
3348
3348
|
});
|
|
3349
|
-
function
|
|
3349
|
+
function join18(array, separator) {
|
|
3350
3350
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
3351
3351
|
}
|
|
3352
3352
|
function last(array) {
|
|
@@ -5270,7 +5270,7 @@ var require_lodash = __commonJS({
|
|
|
5270
5270
|
lodash2.isUndefined = isUndefined;
|
|
5271
5271
|
lodash2.isWeakMap = isWeakMap;
|
|
5272
5272
|
lodash2.isWeakSet = isWeakSet;
|
|
5273
|
-
lodash2.join =
|
|
5273
|
+
lodash2.join = join18;
|
|
5274
5274
|
lodash2.kebabCase = kebabCase;
|
|
5275
5275
|
lodash2.last = last;
|
|
5276
5276
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -5527,22 +5527,22 @@ var require_lodash = __commonJS({
|
|
|
5527
5527
|
}
|
|
5528
5528
|
});
|
|
5529
5529
|
|
|
5530
|
-
//
|
|
5530
|
+
// ../../node_modules/lunr/lunr.js
|
|
5531
5531
|
var require_lunr = __commonJS({
|
|
5532
|
-
"
|
|
5532
|
+
"../../node_modules/lunr/lunr.js"(exports2, module) {
|
|
5533
5533
|
(function() {
|
|
5534
5534
|
var lunr2 = function(config) {
|
|
5535
|
-
var
|
|
5536
|
-
|
|
5535
|
+
var builder9 = new lunr2.Builder();
|
|
5536
|
+
builder9.pipeline.add(
|
|
5537
5537
|
lunr2.trimmer,
|
|
5538
5538
|
lunr2.stopWordFilter,
|
|
5539
5539
|
lunr2.stemmer
|
|
5540
5540
|
);
|
|
5541
|
-
|
|
5541
|
+
builder9.searchPipeline.add(
|
|
5542
5542
|
lunr2.stemmer
|
|
5543
5543
|
);
|
|
5544
|
-
config.call(
|
|
5545
|
-
return
|
|
5544
|
+
config.call(builder9, builder9);
|
|
5545
|
+
return builder9.build();
|
|
5546
5546
|
};
|
|
5547
5547
|
lunr2.version = "2.3.9";
|
|
5548
5548
|
lunr2.utils = {};
|
|
@@ -6218,12 +6218,12 @@ var require_lunr = __commonJS({
|
|
|
6218
6218
|
};
|
|
6219
6219
|
lunr2.TokenSet._nextId = 1;
|
|
6220
6220
|
lunr2.TokenSet.fromArray = function(arr) {
|
|
6221
|
-
var
|
|
6221
|
+
var builder9 = new lunr2.TokenSet.Builder();
|
|
6222
6222
|
for (var i = 0, len = arr.length; i < len; i++) {
|
|
6223
|
-
|
|
6223
|
+
builder9.insert(arr[i]);
|
|
6224
6224
|
}
|
|
6225
|
-
|
|
6226
|
-
return
|
|
6225
|
+
builder9.finish();
|
|
6226
|
+
return builder9.root;
|
|
6227
6227
|
};
|
|
6228
6228
|
lunr2.TokenSet.fromClause = function(clause) {
|
|
6229
6229
|
if ("editDistance" in clause) {
|
|
@@ -7268,7 +7268,7 @@ import { dirname, join } from "node:path";
|
|
|
7268
7268
|
import { fileURLToPath } from "node:url";
|
|
7269
7269
|
function getPackageVersion() {
|
|
7270
7270
|
if (true) {
|
|
7271
|
-
return "4.0.0
|
|
7271
|
+
return "4.0.0";
|
|
7272
7272
|
}
|
|
7273
7273
|
const currentModulePath = fileURLToPath(import.meta.url);
|
|
7274
7274
|
const currentDir = dirname(currentModulePath);
|
|
@@ -7879,10 +7879,10 @@ ${"=".repeat(50)}`);
|
|
|
7879
7879
|
if (statistics.typeStatistics.commonTypeConflicts.length > 0) {
|
|
7880
7880
|
console.log(`
|
|
7881
7881
|
\u2694\uFE0F Type Conflicts:`);
|
|
7882
|
-
statistics.typeStatistics.commonTypeConflicts.forEach(({ conflictType, count, examples:
|
|
7882
|
+
statistics.typeStatistics.commonTypeConflicts.forEach(({ conflictType, count, examples: examples9 }) => {
|
|
7883
7883
|
console.log(` ${yellow(conflictType)}: ${count} conflicts`);
|
|
7884
|
-
if (
|
|
7885
|
-
console.log(` \u2514\u2500 Examples: ${gray(
|
|
7884
|
+
if (examples9.length > 0) {
|
|
7885
|
+
console.log(` \u2514\u2500 Examples: ${gray(examples9.join(", "))}`);
|
|
7886
7886
|
}
|
|
7887
7887
|
});
|
|
7888
7888
|
}
|
|
@@ -8165,7 +8165,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
8165
8165
|
var NEW_LINE_REG_EXP = /[\n\r]+/g;
|
|
8166
8166
|
function getPackageVersion2() {
|
|
8167
8167
|
if (true) {
|
|
8168
|
-
return "4.0.0
|
|
8168
|
+
return "4.0.0";
|
|
8169
8169
|
}
|
|
8170
8170
|
try {
|
|
8171
8171
|
const currentModulePath = fileURLToPath2(import.meta.url);
|
|
@@ -8201,7 +8201,7 @@ __export(parser_exports, {
|
|
|
8201
8201
|
parseGir: () => parseGir
|
|
8202
8202
|
});
|
|
8203
8203
|
|
|
8204
|
-
//
|
|
8204
|
+
// ../../node_modules/fast-xml-parser/src/util.js
|
|
8205
8205
|
var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
8206
8206
|
var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
8207
8207
|
var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
|
|
@@ -8242,7 +8242,7 @@ var DANGEROUS_PROPERTY_NAMES = [
|
|
|
8242
8242
|
];
|
|
8243
8243
|
var criticalProperties = ["__proto__", "constructor", "prototype"];
|
|
8244
8244
|
|
|
8245
|
-
//
|
|
8245
|
+
// ../../node_modules/fast-xml-parser/src/validator.js
|
|
8246
8246
|
var defaultOptions = {
|
|
8247
8247
|
allowBooleanAttributes: false,
|
|
8248
8248
|
//A tag can have attributes without any value
|
|
@@ -8548,7 +8548,7 @@ function getPositionFromMatch(match) {
|
|
|
8548
8548
|
return match.startIndex + match[1].length;
|
|
8549
8549
|
}
|
|
8550
8550
|
|
|
8551
|
-
//
|
|
8551
|
+
// ../../node_modules/@nodable/entities/src/entities.js
|
|
8552
8552
|
var BASIC_LATIN = {
|
|
8553
8553
|
amp: "&",
|
|
8554
8554
|
AMP: "&",
|
|
@@ -9648,7 +9648,7 @@ var COMMON_HTML = {
|
|
|
9648
9648
|
frac34: "\xBE"
|
|
9649
9649
|
};
|
|
9650
9650
|
|
|
9651
|
-
//
|
|
9651
|
+
// ../../node_modules/@nodable/entities/src/EntityDecoder.js
|
|
9652
9652
|
var SPECIAL_CHARS = new Set("!?\\\\/[]$%{}^&*()<>|+");
|
|
9653
9653
|
function validateEntityName(name) {
|
|
9654
9654
|
if (name[0] === "#") {
|
|
@@ -10017,7 +10017,7 @@ var EntityDecoder = class {
|
|
|
10017
10017
|
}
|
|
10018
10018
|
};
|
|
10019
10019
|
|
|
10020
|
-
//
|
|
10020
|
+
// ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
|
|
10021
10021
|
var defaultOnDangerousProperty = (name) => {
|
|
10022
10022
|
if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
|
|
10023
10023
|
return "__" + name;
|
|
@@ -10151,7 +10151,7 @@ var buildOptions = function(options2) {
|
|
|
10151
10151
|
return built;
|
|
10152
10152
|
};
|
|
10153
10153
|
|
|
10154
|
-
//
|
|
10154
|
+
// ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
|
|
10155
10155
|
var METADATA_SYMBOL;
|
|
10156
10156
|
if (typeof Symbol !== "function") {
|
|
10157
10157
|
METADATA_SYMBOL = "@@xmlMetadata";
|
|
@@ -10185,11 +10185,37 @@ var XmlNode = class {
|
|
|
10185
10185
|
}
|
|
10186
10186
|
};
|
|
10187
10187
|
|
|
10188
|
-
//
|
|
10188
|
+
// ../../node_modules/xml-naming/src/index.js
|
|
10189
|
+
var nameStartChar10 = ":A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
|
|
10190
|
+
var nameChar10 = nameStartChar10 + "\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040";
|
|
10191
|
+
var nameStartChar11 = ":A-Za-z_\xC0-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";
|
|
10192
|
+
var nameChar11 = nameStartChar11 + "\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040";
|
|
10193
|
+
var buildRegexes = (startChar, char, flags = "") => {
|
|
10194
|
+
const ncStart = startChar.replace(":", "");
|
|
10195
|
+
const ncChar = char.replace(":", "");
|
|
10196
|
+
const ncNamePat = `[${ncStart}][${ncChar}]*`;
|
|
10197
|
+
return {
|
|
10198
|
+
name: new RegExp(`^[${startChar}][${char}]*$`, flags),
|
|
10199
|
+
ncName: new RegExp(`^${ncNamePat}$`, flags),
|
|
10200
|
+
qName: new RegExp(`^${ncNamePat}(?::${ncNamePat})?$`, flags),
|
|
10201
|
+
nmToken: new RegExp(`^[${char}]+$`, flags),
|
|
10202
|
+
nmTokens: new RegExp(`^[${char}]+(?:\\s+[${char}]+)*$`, flags)
|
|
10203
|
+
};
|
|
10204
|
+
};
|
|
10205
|
+
var regexes10 = buildRegexes(nameStartChar10, nameChar10);
|
|
10206
|
+
var regexes11 = buildRegexes(nameStartChar11, nameChar11, "u");
|
|
10207
|
+
var getRegexes = (xmlVersion = "1.0") => xmlVersion === "1.1" ? regexes11 : regexes10;
|
|
10208
|
+
var qName = (str, { xmlVersion = "1.0" } = {}) => getRegexes(xmlVersion).qName.test(str);
|
|
10209
|
+
|
|
10210
|
+
// ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
|
|
10189
10211
|
var DocTypeReader = class {
|
|
10190
|
-
constructor(options2) {
|
|
10212
|
+
constructor(options2, xmlVersion) {
|
|
10191
10213
|
this.suppressValidationErr = !options2;
|
|
10192
10214
|
this.options = options2;
|
|
10215
|
+
this.xmlVersion = xmlVersion || 1;
|
|
10216
|
+
}
|
|
10217
|
+
setXmlVersion(xmlVersion = 1) {
|
|
10218
|
+
this.xmlVersion = xmlVersion;
|
|
10193
10219
|
}
|
|
10194
10220
|
readDocType(xmlData, i) {
|
|
10195
10221
|
const entities = /* @__PURE__ */ Object.create(null);
|
|
@@ -10261,7 +10287,7 @@ var DocTypeReader = class {
|
|
|
10261
10287
|
i++;
|
|
10262
10288
|
}
|
|
10263
10289
|
let entityName = xmlData.substring(startIndex, i);
|
|
10264
|
-
validateEntityName2(entityName);
|
|
10290
|
+
validateEntityName2(entityName, { xmlVersion: this.xmlVersion });
|
|
10265
10291
|
i = skipWhitespace(xmlData, i);
|
|
10266
10292
|
if (!this.suppressValidationErr) {
|
|
10267
10293
|
if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
|
|
@@ -10287,7 +10313,7 @@ var DocTypeReader = class {
|
|
|
10287
10313
|
i++;
|
|
10288
10314
|
}
|
|
10289
10315
|
let notationName = xmlData.substring(startIndex, i);
|
|
10290
|
-
!this.suppressValidationErr && validateEntityName2(notationName);
|
|
10316
|
+
!this.suppressValidationErr && validateEntityName2(notationName, { xmlVersion: this.xmlVersion });
|
|
10291
10317
|
i = skipWhitespace(xmlData, i);
|
|
10292
10318
|
const identifierType = xmlData.substring(i, i + 6).toUpperCase();
|
|
10293
10319
|
if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
|
|
@@ -10336,7 +10362,7 @@ var DocTypeReader = class {
|
|
|
10336
10362
|
i++;
|
|
10337
10363
|
}
|
|
10338
10364
|
let elementName = xmlData.substring(startIndex, i);
|
|
10339
|
-
if (!this.suppressValidationErr && !
|
|
10365
|
+
if (!this.suppressValidationErr && !qName(elementName, { xmlVersion: this.xmlVersion })) {
|
|
10340
10366
|
throw new Error(`Invalid element name: "${elementName}"`);
|
|
10341
10367
|
}
|
|
10342
10368
|
i = skipWhitespace(xmlData, i);
|
|
@@ -10369,14 +10395,14 @@ var DocTypeReader = class {
|
|
|
10369
10395
|
i++;
|
|
10370
10396
|
}
|
|
10371
10397
|
let elementName = xmlData.substring(startIndex, i);
|
|
10372
|
-
validateEntityName2(elementName);
|
|
10398
|
+
validateEntityName2(elementName, { xmlVersion: this.xmlVersion });
|
|
10373
10399
|
i = skipWhitespace(xmlData, i);
|
|
10374
10400
|
startIndex = i;
|
|
10375
10401
|
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
10376
10402
|
i++;
|
|
10377
10403
|
}
|
|
10378
10404
|
let attributeName = xmlData.substring(startIndex, i);
|
|
10379
|
-
if (!validateEntityName2(attributeName)) {
|
|
10405
|
+
if (!validateEntityName2(attributeName, { xmlVersion: this.xmlVersion })) {
|
|
10380
10406
|
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
|
10381
10407
|
}
|
|
10382
10408
|
i = skipWhitespace(xmlData, i);
|
|
@@ -10397,7 +10423,7 @@ var DocTypeReader = class {
|
|
|
10397
10423
|
}
|
|
10398
10424
|
let notation = xmlData.substring(startIndex2, i);
|
|
10399
10425
|
notation = notation.trim();
|
|
10400
|
-
if (!validateEntityName2(notation)) {
|
|
10426
|
+
if (!validateEntityName2(notation, { xmlVersion: this.xmlVersion })) {
|
|
10401
10427
|
throw new Error(`Invalid notation name: "${notation}"`);
|
|
10402
10428
|
}
|
|
10403
10429
|
allowedNotations.push(notation);
|
|
@@ -10454,19 +10480,22 @@ function hasSeq(data, seq, i) {
|
|
|
10454
10480
|
}
|
|
10455
10481
|
return true;
|
|
10456
10482
|
}
|
|
10457
|
-
function validateEntityName2(name) {
|
|
10458
|
-
if (
|
|
10483
|
+
function validateEntityName2(name, xmlVersion) {
|
|
10484
|
+
if (qName(name, { xmlVersion }))
|
|
10459
10485
|
return name;
|
|
10460
10486
|
else
|
|
10461
10487
|
throw new Error(`Invalid entity name ${name}`);
|
|
10462
10488
|
}
|
|
10463
10489
|
|
|
10464
|
-
//
|
|
10490
|
+
// ../../node_modules/strnum/strnum.js
|
|
10465
10491
|
var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
|
|
10492
|
+
var binRegex = /^0b[01]+$/;
|
|
10493
|
+
var octRegex = /^0o[0-7]+$/;
|
|
10466
10494
|
var numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
|
|
10467
10495
|
var consider = {
|
|
10468
10496
|
hex: true,
|
|
10469
|
-
|
|
10497
|
+
binary: false,
|
|
10498
|
+
octal: false,
|
|
10470
10499
|
leadingZeros: true,
|
|
10471
10500
|
decimalPoint: ".",
|
|
10472
10501
|
eNotation: true,
|
|
@@ -10483,6 +10512,10 @@ function toNumber(str, options2 = {}) {
|
|
|
10483
10512
|
else if (trimmedStr === "0") return 0;
|
|
10484
10513
|
else if (options2.hex && hexRegex.test(trimmedStr)) {
|
|
10485
10514
|
return parse_int(trimmedStr, 16);
|
|
10515
|
+
} else if (options2.binary && binRegex.test(trimmedStr)) {
|
|
10516
|
+
return parse_int(trimmedStr, 2);
|
|
10517
|
+
} else if (options2.octal && octRegex.test(trimmedStr)) {
|
|
10518
|
+
return parse_int(trimmedStr, 8);
|
|
10486
10519
|
} else if (!isFinite(trimmedStr)) {
|
|
10487
10520
|
return handleInfinity(str, Number(trimmedStr), options2);
|
|
10488
10521
|
} else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
|
|
@@ -10562,6 +10595,8 @@ function trimZeros(numStr) {
|
|
|
10562
10595
|
return numStr;
|
|
10563
10596
|
}
|
|
10564
10597
|
function parse_int(numStr, base) {
|
|
10598
|
+
const str = numStr.trim();
|
|
10599
|
+
if (base === 2 || base === 8) numStr = str.substring(2);
|
|
10565
10600
|
if (parseInt) return parseInt(numStr, base);
|
|
10566
10601
|
else if (Number.parseInt) return Number.parseInt(numStr, base);
|
|
10567
10602
|
else if (window && window.parseInt) return window.parseInt(numStr, base);
|
|
@@ -10583,7 +10618,7 @@ function handleInfinity(str, num, options2) {
|
|
|
10583
10618
|
}
|
|
10584
10619
|
}
|
|
10585
10620
|
|
|
10586
|
-
//
|
|
10621
|
+
// ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
|
|
10587
10622
|
function getIgnoreAttributesFn(ignoreAttributes) {
|
|
10588
10623
|
if (typeof ignoreAttributes === "function") {
|
|
10589
10624
|
return ignoreAttributes;
|
|
@@ -10603,7 +10638,7 @@ function getIgnoreAttributesFn(ignoreAttributes) {
|
|
|
10603
10638
|
return () => false;
|
|
10604
10639
|
}
|
|
10605
10640
|
|
|
10606
|
-
//
|
|
10641
|
+
// ../../node_modules/path-expression-matcher/src/Expression.js
|
|
10607
10642
|
var Expression = class {
|
|
10608
10643
|
/**
|
|
10609
10644
|
* Create a new Expression
|
|
@@ -10766,7 +10801,7 @@ var Expression = class {
|
|
|
10766
10801
|
}
|
|
10767
10802
|
};
|
|
10768
10803
|
|
|
10769
|
-
//
|
|
10804
|
+
// ../../node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
10770
10805
|
var ExpressionSet = class {
|
|
10771
10806
|
constructor() {
|
|
10772
10807
|
this._byDepthAndTag = /* @__PURE__ */ new Map();
|
|
@@ -10921,7 +10956,7 @@ var ExpressionSet = class {
|
|
|
10921
10956
|
}
|
|
10922
10957
|
};
|
|
10923
10958
|
|
|
10924
|
-
//
|
|
10959
|
+
// ../../node_modules/path-expression-matcher/src/Matcher.js
|
|
10925
10960
|
var MatcherView = class {
|
|
10926
10961
|
/**
|
|
10927
10962
|
* @param {Matcher} matcher - The parent Matcher instance to read from.
|
|
@@ -11371,7 +11406,7 @@ var Matcher = class {
|
|
|
11371
11406
|
}
|
|
11372
11407
|
};
|
|
11373
11408
|
|
|
11374
|
-
//
|
|
11409
|
+
// ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
|
|
11375
11410
|
function extractRawAttributes(prefixedAttrs, options2) {
|
|
11376
11411
|
if (!prefixedAttrs) return {};
|
|
11377
11412
|
const attrs = options2.attributesGroupName ? prefixedAttrs[options2.attributesGroupName] : prefixedAttrs;
|
|
@@ -11602,6 +11637,7 @@ var parseXml = function(xmlData) {
|
|
|
11602
11637
|
if (attsMap) {
|
|
11603
11638
|
const ver = attsMap[this.options.attributeNamePrefix + "version"];
|
|
11604
11639
|
this.entityDecoder.setXmlVersion(Number(ver) || 1);
|
|
11640
|
+
docTypeReader.setXmlVersion(Number(ver) || 1);
|
|
11605
11641
|
}
|
|
11606
11642
|
if (options2.ignoreDeclaration && tagData.tagName === "?xml" || options2.ignorePiTags) {
|
|
11607
11643
|
} else {
|
|
@@ -11905,7 +11941,7 @@ function readStopNodeData(xmlData, tagName, i) {
|
|
|
11905
11941
|
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
|
11906
11942
|
i = closeIndex;
|
|
11907
11943
|
} else {
|
|
11908
|
-
const tagData = readTagExp(xmlData, i,
|
|
11944
|
+
const tagData = readTagExp(xmlData, i, false);
|
|
11909
11945
|
if (tagData) {
|
|
11910
11946
|
const openTagName = tagData && tagData.tagName;
|
|
11911
11947
|
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
|
|
@@ -11951,7 +11987,7 @@ function sanitizeName(name, options2) {
|
|
|
11951
11987
|
return name;
|
|
11952
11988
|
}
|
|
11953
11989
|
|
|
11954
|
-
//
|
|
11990
|
+
// ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
|
|
11955
11991
|
var METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
|
|
11956
11992
|
function stripAttributePrefix(attrs, prefix) {
|
|
11957
11993
|
if (!attrs || typeof attrs !== "object") return {};
|
|
@@ -11991,6 +12027,9 @@ function compress(arr, options2, matcher, readonlyMatcher) {
|
|
|
11991
12027
|
} else if (tagObj[property]) {
|
|
11992
12028
|
let val = compress(tagObj[property], options2, matcher, readonlyMatcher);
|
|
11993
12029
|
const isLeaf = isLeafTag(val, options2);
|
|
12030
|
+
if (Object.keys(val).length === 0 && options2.alwaysCreateTextNode) {
|
|
12031
|
+
val[options2.textNodeName] = "";
|
|
12032
|
+
}
|
|
11994
12033
|
if (tagObj[":@"]) {
|
|
11995
12034
|
assignAttributes(val, tagObj[":@"], readonlyMatcher, options2);
|
|
11996
12035
|
} else if (Object.keys(val).length === 1 && val[options2.textNodeName] !== void 0 && !options2.alwaysCreateTextNode) {
|
|
@@ -12060,7 +12099,7 @@ function isLeafTag(obj, options2) {
|
|
|
12060
12099
|
return false;
|
|
12061
12100
|
}
|
|
12062
12101
|
|
|
12063
|
-
//
|
|
12102
|
+
// ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
|
|
12064
12103
|
var XMLParser = class {
|
|
12065
12104
|
constructor(options2) {
|
|
12066
12105
|
this.externalEntities = {};
|
|
@@ -13244,9 +13283,9 @@ var NativeType = class _NativeType extends TypeExpression {
|
|
|
13244
13283
|
};
|
|
13245
13284
|
var OrType = class _OrType extends TypeExpression {
|
|
13246
13285
|
types;
|
|
13247
|
-
constructor(
|
|
13286
|
+
constructor(...types) {
|
|
13248
13287
|
super();
|
|
13249
|
-
this.types = [
|
|
13288
|
+
this.types = [...types];
|
|
13250
13289
|
}
|
|
13251
13290
|
rewrap(type) {
|
|
13252
13291
|
return type;
|
|
@@ -13255,14 +13294,13 @@ var OrType = class _OrType extends TypeExpression {
|
|
|
13255
13294
|
return this;
|
|
13256
13295
|
}
|
|
13257
13296
|
resolve(namespace, options2) {
|
|
13258
|
-
|
|
13259
|
-
return new _OrType(type.resolve(namespace, options2), ...types.map((t) => t.resolve(namespace, options2)));
|
|
13297
|
+
return makeUnion(...this.types.map((t) => t.resolve(namespace, options2)));
|
|
13260
13298
|
}
|
|
13261
13299
|
print(namespace, options2) {
|
|
13262
|
-
return
|
|
13300
|
+
return `${this.types.map((t) => t.print(namespace, options2)).join(" | ")}`;
|
|
13263
13301
|
}
|
|
13264
13302
|
rootPrint(namespace, options2) {
|
|
13265
|
-
return
|
|
13303
|
+
return this.print(namespace, options2);
|
|
13266
13304
|
}
|
|
13267
13305
|
equals(type) {
|
|
13268
13306
|
if (type instanceof _OrType) {
|
|
@@ -13272,6 +13310,35 @@ var OrType = class _OrType extends TypeExpression {
|
|
|
13272
13310
|
}
|
|
13273
13311
|
}
|
|
13274
13312
|
};
|
|
13313
|
+
function makeUnion(...inputTypes) {
|
|
13314
|
+
const types = /* @__PURE__ */ new Set();
|
|
13315
|
+
for (const type of inputTypes) {
|
|
13316
|
+
if (type instanceof BinaryType) {
|
|
13317
|
+
types.add(type.a);
|
|
13318
|
+
types.add(type.b);
|
|
13319
|
+
} else if (type instanceof OrType && !(type instanceof TupleType)) {
|
|
13320
|
+
for (const t of type.types) {
|
|
13321
|
+
types.add(t);
|
|
13322
|
+
}
|
|
13323
|
+
} else {
|
|
13324
|
+
types.add(type);
|
|
13325
|
+
}
|
|
13326
|
+
}
|
|
13327
|
+
if (types.size === 1) {
|
|
13328
|
+
return [...types][0];
|
|
13329
|
+
}
|
|
13330
|
+
if (types.size === 2) {
|
|
13331
|
+
const typesArray = [...types];
|
|
13332
|
+
if (typesArray[0] === NullType) {
|
|
13333
|
+
return new NullableType(typesArray[1]);
|
|
13334
|
+
}
|
|
13335
|
+
if (typesArray[1] === NullType) {
|
|
13336
|
+
return new NullableType(typesArray[0]);
|
|
13337
|
+
}
|
|
13338
|
+
return new BinaryType(...typesArray);
|
|
13339
|
+
}
|
|
13340
|
+
return new OrType(...types);
|
|
13341
|
+
}
|
|
13275
13342
|
var TupleType = class _TupleType extends OrType {
|
|
13276
13343
|
print(namespace, options2) {
|
|
13277
13344
|
return `[${this.types.map((t) => t.print(namespace, options2)).join(", ")}]`;
|
|
@@ -13442,7 +13509,7 @@ var GenericType = class _GenericType extends TypeExpression {
|
|
|
13442
13509
|
return this.identifier;
|
|
13443
13510
|
}
|
|
13444
13511
|
};
|
|
13445
|
-
var NullableType = class
|
|
13512
|
+
var NullableType = class extends BinaryType {
|
|
13446
13513
|
constructor(type) {
|
|
13447
13514
|
super(type, NullType);
|
|
13448
13515
|
}
|
|
@@ -13450,12 +13517,18 @@ var NullableType = class _NullableType extends BinaryType {
|
|
|
13450
13517
|
return this.a;
|
|
13451
13518
|
}
|
|
13452
13519
|
rewrap(type) {
|
|
13453
|
-
return
|
|
13520
|
+
return makeNullable(this.a.rewrap(type));
|
|
13454
13521
|
}
|
|
13455
13522
|
get type() {
|
|
13456
13523
|
return this.a;
|
|
13457
13524
|
}
|
|
13458
13525
|
};
|
|
13526
|
+
function makeNullable(type) {
|
|
13527
|
+
if (type instanceof NullableType) return type;
|
|
13528
|
+
if (type === RawPointerType) return NullType;
|
|
13529
|
+
if (type === AnyType) return AnyType;
|
|
13530
|
+
return makeUnion(type, NullType);
|
|
13531
|
+
}
|
|
13459
13532
|
var PromiseType = class _PromiseType extends TypeExpression {
|
|
13460
13533
|
type;
|
|
13461
13534
|
constructor(type) {
|
|
@@ -13599,6 +13672,8 @@ var ArrayType = class _ArrayType extends TypeExpression {
|
|
|
13599
13672
|
} else {
|
|
13600
13673
|
typeSuffix = "".padStart(2 * depth, "[]");
|
|
13601
13674
|
}
|
|
13675
|
+
if (this.type instanceof OrType && !(this.type instanceof TupleType))
|
|
13676
|
+
return `(${this.type.print(namespace, options2)})${typeSuffix}`;
|
|
13602
13677
|
return `${this.type.print(namespace, options2)}${typeSuffix}`;
|
|
13603
13678
|
}
|
|
13604
13679
|
static new({
|
|
@@ -13625,6 +13700,7 @@ var NullType = new NativeType("null");
|
|
|
13625
13700
|
var VoidType = new NativeType("void");
|
|
13626
13701
|
var UnknownType = new NativeType("unknown");
|
|
13627
13702
|
var AnyFunctionType = new NativeType("(...args: any[]) => any");
|
|
13703
|
+
var RawPointerType = new NativeType("never");
|
|
13628
13704
|
|
|
13629
13705
|
// ../lib/src/utils/types.ts
|
|
13630
13706
|
function getAliasType(namespace, _ns, parameter) {
|
|
@@ -13753,7 +13829,7 @@ function resolvePrimitiveType(name) {
|
|
|
13753
13829
|
case "gboolean":
|
|
13754
13830
|
return BooleanType;
|
|
13755
13831
|
case "gpointer":
|
|
13756
|
-
return
|
|
13832
|
+
return RawPointerType;
|
|
13757
13833
|
case "object":
|
|
13758
13834
|
return ObjectType;
|
|
13759
13835
|
case "va_list":
|
|
@@ -13779,42 +13855,99 @@ function resolvePrimitiveType(name) {
|
|
|
13779
13855
|
function resolveDirectedType(type, direction) {
|
|
13780
13856
|
if (type instanceof ArrayType) {
|
|
13781
13857
|
if ((direction === "in" /* In */ || direction === "inout" /* Inout */) && type.type.equals(Uint8ArrayType) && type.arrayDepth === 0) {
|
|
13782
|
-
return
|
|
13858
|
+
return makeUnion(type, StringType);
|
|
13783
13859
|
} else {
|
|
13784
13860
|
return type.rewrap(resolveDirectedType(type.type, direction) ?? type.type);
|
|
13785
13861
|
}
|
|
13786
13862
|
} else if (type instanceof TypeIdentifier) {
|
|
13787
13863
|
if ((direction === "in" /* In */ || direction === "inout" /* Inout */) && type.is("GLib", "Bytes")) {
|
|
13788
|
-
return
|
|
13864
|
+
return makeUnion(type, Uint8ArrayType);
|
|
13789
13865
|
} else if (type.is("GObject", "Value")) {
|
|
13790
13866
|
if (direction === "in" /* In */ || direction === "inout" /* Inout */) {
|
|
13791
|
-
return
|
|
13867
|
+
return makeUnion(type, AnyType);
|
|
13792
13868
|
} else {
|
|
13793
13869
|
return UnknownType;
|
|
13794
13870
|
}
|
|
13795
13871
|
} else if (type.is("GLib", "HashTable")) {
|
|
13796
|
-
|
|
13797
|
-
return new BinaryType(new NativeType("{ [key: string]: any }"), type);
|
|
13798
|
-
} else {
|
|
13799
|
-
return type;
|
|
13800
|
-
}
|
|
13872
|
+
return hashTableToJsDict(type);
|
|
13801
13873
|
}
|
|
13802
13874
|
} else if (type === BigintOrNumberType && direction === "out" /* Out */) {
|
|
13803
13875
|
return NumberType;
|
|
13876
|
+
} else if (type === RawPointerType && direction === "out" /* Out */) {
|
|
13877
|
+
return NullType;
|
|
13804
13878
|
} else if (type instanceof PromiseType) {
|
|
13805
13879
|
const resolvedInner = resolveDirectedType(type.type, direction);
|
|
13806
13880
|
if (resolvedInner) return new PromiseType(resolvedInner);
|
|
13807
|
-
} else if (type instanceof
|
|
13881
|
+
} else if (type instanceof NullableType) {
|
|
13882
|
+
const inner = resolveDirectedType(type.a, direction);
|
|
13883
|
+
if (inner !== null) return makeNullable(inner);
|
|
13884
|
+
} else if (type instanceof TupleType) {
|
|
13885
|
+
let changed = false;
|
|
13886
|
+
const inner = type.types.map((t) => {
|
|
13887
|
+
const resolved = resolveDirectedType(t, direction);
|
|
13888
|
+
if (resolved !== null) {
|
|
13889
|
+
changed = true;
|
|
13890
|
+
return resolved;
|
|
13891
|
+
}
|
|
13892
|
+
return t;
|
|
13893
|
+
});
|
|
13894
|
+
if (changed) {
|
|
13895
|
+
const [first, ...rest2] = inner;
|
|
13896
|
+
return new TupleType(first, ...rest2);
|
|
13897
|
+
}
|
|
13898
|
+
} else if (type instanceof BinaryType) {
|
|
13808
13899
|
const a = resolveDirectedType(type.a, direction) ?? type.a;
|
|
13809
13900
|
const b = resolveDirectedType(type.b, direction) ?? type.b;
|
|
13810
|
-
if (a !== type.a || b !== type.b) return
|
|
13811
|
-
} else if (type instanceof OrType && !(type instanceof BinaryType || type instanceof TupleType)) {
|
|
13812
|
-
const types = type.types.map((t) => resolveDirectedType(t, direction) ?? t);
|
|
13813
|
-
if (types.length === 1) return types[0];
|
|
13814
|
-
return new OrType(types[0], ...types.slice(1));
|
|
13901
|
+
if (a !== type.a || b !== type.b) return makeUnion(a, b);
|
|
13815
13902
|
}
|
|
13816
13903
|
return null;
|
|
13817
13904
|
}
|
|
13905
|
+
function hashTableToJsDict(type) {
|
|
13906
|
+
if (!(type instanceof GenerifiedTypeIdentifier) || type.generics.length === 0) {
|
|
13907
|
+
return new NativeType("{ [key: string]: any }");
|
|
13908
|
+
}
|
|
13909
|
+
const [keyType, valueType] = type.generics;
|
|
13910
|
+
const keyShape = jsKeyShapeFor(keyType);
|
|
13911
|
+
if (keyShape === null) {
|
|
13912
|
+
return NeverType;
|
|
13913
|
+
}
|
|
13914
|
+
return new HashTableDictType(keyShape, valueType ?? AnyType);
|
|
13915
|
+
}
|
|
13916
|
+
function jsKeyShapeFor(keyType) {
|
|
13917
|
+
if (keyType === StringType) return "string";
|
|
13918
|
+
if (keyType instanceof TypeIdentifier && keyType.is("GLib", "filename")) return "string";
|
|
13919
|
+
if (keyType === NumberType) return "number";
|
|
13920
|
+
if (keyType === BooleanType) return "number";
|
|
13921
|
+
if (keyType === BigintOrNumberType) return "number";
|
|
13922
|
+
return null;
|
|
13923
|
+
}
|
|
13924
|
+
var HashTableDictType = class _HashTableDictType extends TypeExpression {
|
|
13925
|
+
constructor(keyShape, valueType) {
|
|
13926
|
+
super();
|
|
13927
|
+
this.keyShape = keyShape;
|
|
13928
|
+
this.valueType = valueType;
|
|
13929
|
+
}
|
|
13930
|
+
keyShape;
|
|
13931
|
+
valueType;
|
|
13932
|
+
print(namespace, options2) {
|
|
13933
|
+
return `{ [key: ${this.keyShape}]: ${this.valueType.rootPrint(namespace, options2)} }`;
|
|
13934
|
+
}
|
|
13935
|
+
resolve(_namespace, _options) {
|
|
13936
|
+
return this;
|
|
13937
|
+
}
|
|
13938
|
+
equals(type) {
|
|
13939
|
+
return type instanceof _HashTableDictType && this.keyShape === type.keyShape && this.valueType.equals(type.valueType);
|
|
13940
|
+
}
|
|
13941
|
+
rewrap(_type) {
|
|
13942
|
+
return this;
|
|
13943
|
+
}
|
|
13944
|
+
unwrap() {
|
|
13945
|
+
return this;
|
|
13946
|
+
}
|
|
13947
|
+
deepUnwrap() {
|
|
13948
|
+
return this.valueType.deepUnwrap();
|
|
13949
|
+
}
|
|
13950
|
+
};
|
|
13818
13951
|
|
|
13819
13952
|
// ../lib/src/utils/gir-parsing.ts
|
|
13820
13953
|
var girParsingReporter = new LazyReporter("GirParsing");
|
|
@@ -13965,10 +14098,10 @@ function getType(ns, param) {
|
|
|
13965
14098
|
variableType = ClosureType.new({ type: variableType, user_data: closure });
|
|
13966
14099
|
}
|
|
13967
14100
|
if (parameter.$ && (parameter.$.direction === "inout" /* Inout */ || parameter.$.direction === "out" /* Out */) && (nullable || allowNone) && !(variableType instanceof NativeType) && variableType !== BigintOrNumberType) {
|
|
13968
|
-
return
|
|
14101
|
+
return makeNullable(variableType);
|
|
13969
14102
|
}
|
|
13970
14103
|
if ((!parameter.$?.direction || parameter.$.direction === "in" /* In */) && nullable) {
|
|
13971
|
-
return
|
|
14104
|
+
return makeNullable(variableType);
|
|
13972
14105
|
}
|
|
13973
14106
|
variableType.isPointer = isPointer;
|
|
13974
14107
|
return variableType;
|
|
@@ -14477,7 +14610,7 @@ var IntrospectedProperty = class _IntrospectedProperty extends IntrospectedBase
|
|
|
14477
14610
|
property.defaultValue = element.$["default-value"];
|
|
14478
14611
|
property.getter = element.$.getter;
|
|
14479
14612
|
if (element.$.nullable === "1" || element.$["allow-none"] === "1") {
|
|
14480
|
-
property.type =
|
|
14613
|
+
property.type = makeNullable(property.type);
|
|
14481
14614
|
}
|
|
14482
14615
|
return property;
|
|
14483
14616
|
}
|
|
@@ -14585,7 +14718,7 @@ var IntrospectedSignal = class _IntrospectedSignal extends IntrospectedClassMemb
|
|
|
14585
14718
|
}
|
|
14586
14719
|
} else {
|
|
14587
14720
|
if (isOptional) {
|
|
14588
|
-
params.push(p.copy({ type:
|
|
14721
|
+
params.push(p.copy({ type: makeNullable(type), isOptional: false }));
|
|
14589
14722
|
} else {
|
|
14590
14723
|
params.push(p);
|
|
14591
14724
|
}
|
|
@@ -14689,7 +14822,7 @@ function resolveNullableProperties(cls) {
|
|
|
14689
14822
|
const getterName = prop.getter ?? `get_${prop.name}`;
|
|
14690
14823
|
const getter = cls.members.find((m) => m.name === getterName && !(m instanceof IntrospectedStaticClassFunction));
|
|
14691
14824
|
if (getter instanceof IntrospectedClassFunction && getter.return() instanceof NullableType) {
|
|
14692
|
-
prop.type =
|
|
14825
|
+
prop.type = makeNullable(prop.type);
|
|
14693
14826
|
}
|
|
14694
14827
|
}
|
|
14695
14828
|
}
|
|
@@ -15988,7 +16121,10 @@ var IntrospectedFunction = class _IntrospectedFunction extends IntrospectedNames
|
|
|
15988
16121
|
});
|
|
15989
16122
|
}
|
|
15990
16123
|
static filterParameters(parameters, length_params, user_data_params) {
|
|
15991
|
-
return parameters.filter((_, i) => !length_params.includes(i) && !user_data_params.includes(i)).filter((v) =>
|
|
16124
|
+
return parameters.filter((_, i) => !length_params.includes(i) && !user_data_params.includes(i)).filter((v) => {
|
|
16125
|
+
const unwrapped = v.type.unwrap();
|
|
16126
|
+
return !(unwrapped instanceof TypeIdentifier && unwrapped.is("GLib", "DestroyNotify"));
|
|
16127
|
+
});
|
|
15992
16128
|
}
|
|
15993
16129
|
static processOptionalParameters(parameters) {
|
|
15994
16130
|
return parameters.reverse().reduce(
|
|
@@ -16003,7 +16139,7 @@ var IntrospectedFunction = class _IntrospectedFunction extends IntrospectedNames
|
|
|
16003
16139
|
}
|
|
16004
16140
|
} else {
|
|
16005
16141
|
if (isOptional) {
|
|
16006
|
-
params.push(p.copy({ type:
|
|
16142
|
+
params.push(p.copy({ type: makeNullable(type), isOptional: false }));
|
|
16007
16143
|
} else {
|
|
16008
16144
|
params.push(p);
|
|
16009
16145
|
}
|
|
@@ -16886,16 +17022,16 @@ function transformBacktickTypeRefs(text, ctx) {
|
|
|
16886
17022
|
});
|
|
16887
17023
|
return text;
|
|
16888
17024
|
}
|
|
16889
|
-
function transformGirDocHighlights(
|
|
16890
|
-
return
|
|
17025
|
+
function transformGirDocHighlights(description9) {
|
|
17026
|
+
return description9.replace(/(?<!\{)(?<!\w)@([A-Za-z_][A-Za-z0-9_]*)/g, "`$1`");
|
|
16891
17027
|
}
|
|
16892
|
-
function transformGirDocCodeBlocks(
|
|
16893
|
-
|
|
17028
|
+
function transformGirDocCodeBlocks(description9) {
|
|
17029
|
+
description9 = description9.replaceAll(/```\s*\{\s*\.(\w+)[^}]*\}/gm, "```$1").replaceAll(/\|\[<!-- language="([^"]+)" -->/gm, (_match, lang) => {
|
|
16894
17030
|
if (lang === "plain" || lang === "text") return "\n```";
|
|
16895
17031
|
return `
|
|
16896
17032
|
\`\`\`${lang.toLowerCase()}`;
|
|
16897
17033
|
}).replaceAll(/\|\[/gm, "\n```").replaceAll(/\]\|/gm, "```\n");
|
|
16898
|
-
return
|
|
17034
|
+
return description9;
|
|
16899
17035
|
}
|
|
16900
17036
|
|
|
16901
17037
|
// ../lib/src/utils/objects.ts
|
|
@@ -17480,7 +17616,7 @@ function promisifyNamespaceFunctions(namespace) {
|
|
|
17480
17616
|
parameters: sync_parameters
|
|
17481
17617
|
}),
|
|
17482
17618
|
node.copy({
|
|
17483
|
-
return_type:
|
|
17619
|
+
return_type: makeUnion(async_return, node.return())
|
|
17484
17620
|
})
|
|
17485
17621
|
]);
|
|
17486
17622
|
}
|
|
@@ -17500,7 +17636,7 @@ function generatePromisifyOverloadedSignatures(node, async_parameters, sync_para
|
|
|
17500
17636
|
});
|
|
17501
17637
|
const unionOverload = node.copy({
|
|
17502
17638
|
parameters: [...async_parameters, sync_parameters[sync_parameters.length - 1].copy({ isOptional: true })],
|
|
17503
|
-
returnType:
|
|
17639
|
+
returnType: makeUnion(async_return, VoidType)
|
|
17504
17640
|
});
|
|
17505
17641
|
return [promiseOverload, callbackOverload, unionOverload];
|
|
17506
17642
|
}
|
|
@@ -20085,8 +20221,10 @@ var shellTemplate = (version) => ({
|
|
|
20085
20221
|
const addGlslSnippet = GLSLEffect.members.find((m) => m.name === "add_glsl_snippet");
|
|
20086
20222
|
if (addGlslSnippet) {
|
|
20087
20223
|
const updatedParameter = addGlslSnippet.parameters[0].copy({
|
|
20088
|
-
type:
|
|
20089
|
-
new
|
|
20224
|
+
type: makeUnion(
|
|
20225
|
+
new TypeIdentifier("SnippetHook", "Shell"),
|
|
20226
|
+
new TypeIdentifier("SnippetHook", "Cogl"),
|
|
20227
|
+
NullType
|
|
20090
20228
|
)
|
|
20091
20229
|
});
|
|
20092
20230
|
addGlslSnippet.parameters[0] = updatedParameter;
|
|
@@ -21058,6 +21196,7 @@ import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync
|
|
|
21058
21196
|
|
|
21059
21197
|
// src/config/config-loader.ts
|
|
21060
21198
|
import { dirname as dirname5, resolve as resolve4 } from "node:path";
|
|
21199
|
+
import { pathToFileURL } from "node:url";
|
|
21061
21200
|
import { cosmiconfig } from "cosmiconfig";
|
|
21062
21201
|
|
|
21063
21202
|
// src/config/config-writer.ts
|
|
@@ -21107,6 +21246,14 @@ function getDefaultGirDirectories() {
|
|
|
21107
21246
|
"/usr/lib/mutter-*",
|
|
21108
21247
|
"/usr/lib/x86_64-linux-gnu/mutter-*"
|
|
21109
21248
|
];
|
|
21249
|
+
if (process.env.FLATPAK_ID || existsSync("/.flatpak-info")) {
|
|
21250
|
+
girDirectories.unshift(
|
|
21251
|
+
"/run/host/usr/local/share/gir-1.0",
|
|
21252
|
+
"/run/host/usr/share/gir-1.0",
|
|
21253
|
+
"/run/host/usr/share/*/gir-1.0",
|
|
21254
|
+
"/run/host/usr/lib/x86_64-linux-gnu/mutter-*"
|
|
21255
|
+
);
|
|
21256
|
+
}
|
|
21110
21257
|
const dataDirs = process.env.XDG_DATA_DIRS?.split(":") || [];
|
|
21111
21258
|
for (let dataDir of dataDirs) {
|
|
21112
21259
|
dataDir = join5(dataDir, "gir-1.0");
|
|
@@ -21378,8 +21525,8 @@ var createOptions = {
|
|
|
21378
21525
|
template: {
|
|
21379
21526
|
type: "string",
|
|
21380
21527
|
alias: "t",
|
|
21381
|
-
description: "Template to scaffold (types-locally, types-npm, types-workspace)",
|
|
21382
|
-
choices: ["types-locally", "types-npm", "types-workspace"]
|
|
21528
|
+
description: "Template to scaffold (types-locally, types-npm, types-workspace, types-gjsify)",
|
|
21529
|
+
choices: ["types-locally", "types-npm", "types-workspace", "types-gjsify"]
|
|
21383
21530
|
},
|
|
21384
21531
|
install: {
|
|
21385
21532
|
type: "boolean",
|
|
@@ -21488,9 +21635,12 @@ var analyzeOptions = {
|
|
|
21488
21635
|
async function loadConfigFile(configName) {
|
|
21489
21636
|
const configSearchOptions = {
|
|
21490
21637
|
loaders: {
|
|
21491
|
-
// ESM loader
|
|
21638
|
+
// ESM loader. cosmiconfig hands us an absolute filesystem path; Node's import()
|
|
21639
|
+
// tolerates that as a non-spec extension, but spec-compliant runtimes (GJS /
|
|
21640
|
+
// SpiderMonkey) reject it with "Module not found: <abs-path>". Convert to a
|
|
21641
|
+
// file:// URL so the loader works in both runtimes.
|
|
21492
21642
|
".js": async (filepath) => {
|
|
21493
|
-
const file = await import(filepath);
|
|
21643
|
+
const file = await import(pathToFileURL(filepath).href);
|
|
21494
21644
|
if (file?.default?.default) {
|
|
21495
21645
|
return file.default.default;
|
|
21496
21646
|
}
|
|
@@ -21628,13 +21778,13 @@ async function load(cliOptions) {
|
|
|
21628
21778
|
}
|
|
21629
21779
|
|
|
21630
21780
|
// src/commands/command-builder.ts
|
|
21631
|
-
function createBuilder(options2,
|
|
21781
|
+
function createBuilder(options2, examples9) {
|
|
21632
21782
|
return (yargs2) => {
|
|
21633
21783
|
const optionNames = Object.keys(options2);
|
|
21634
21784
|
for (const optionName of optionNames) {
|
|
21635
21785
|
yargs2 = yargs2.option(optionName, options2[optionName]);
|
|
21636
21786
|
}
|
|
21637
|
-
return yargs2.example(
|
|
21787
|
+
return yargs2.example(examples9);
|
|
21638
21788
|
};
|
|
21639
21789
|
}
|
|
21640
21790
|
|
|
@@ -22474,14 +22624,15 @@ var copy = {
|
|
|
22474
22624
|
|
|
22475
22625
|
// src/commands/create.ts
|
|
22476
22626
|
import { spawnSync } from "node:child_process";
|
|
22477
|
-
import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
22627
|
+
import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync, readFileSync as readFileSync4, realpathSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
22478
22628
|
import { dirname as dirname6, join as join9, resolve as resolve5 } from "node:path";
|
|
22479
22629
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
22480
22630
|
import { input, select as select2 } from "@inquirer/prompts";
|
|
22481
22631
|
var command3 = "create [name]";
|
|
22482
22632
|
var description3 = "Scaffold a new GJS TypeScript project from a template";
|
|
22483
22633
|
var examples3 = [
|
|
22484
|
-
[`${APP_NAME} create my-app --template types-
|
|
22634
|
+
[`${APP_NAME} create my-app --template types-gjsify`, "Scaffold a Node-free GJS app via gjsify (recommended)"],
|
|
22635
|
+
[`${APP_NAME} create my-app --template types-npm`, "Scaffold using the @girs/* NPM types + node/esbuild"],
|
|
22485
22636
|
[`${APP_NAME} create my-app --template types-locally`, "Scaffold and generate types into ./@types/ locally"],
|
|
22486
22637
|
[
|
|
22487
22638
|
`${APP_NAME} create my-app --template types-workspace`,
|
|
@@ -22491,15 +22642,20 @@ var examples3 = [
|
|
|
22491
22642
|
];
|
|
22492
22643
|
var TEMPLATE_CHOICES = [
|
|
22493
22644
|
{
|
|
22494
|
-
value: "types-
|
|
22495
|
-
name: "types-
|
|
22496
|
-
description: "
|
|
22645
|
+
value: "types-gjsify",
|
|
22646
|
+
name: "types-gjsify",
|
|
22647
|
+
description: "Node-free: @girs/* from NPM, all dev scripts (install/build/run/format) routed through gjsify"
|
|
22497
22648
|
},
|
|
22498
22649
|
{
|
|
22499
22650
|
value: "types-npm",
|
|
22500
22651
|
name: "types-npm",
|
|
22501
22652
|
description: "Use pre-generated types from the @girs/* NPM packages"
|
|
22502
22653
|
},
|
|
22654
|
+
{
|
|
22655
|
+
value: "types-locally",
|
|
22656
|
+
name: "types-locally",
|
|
22657
|
+
description: "Generate GIR types directly into ./@types/ (no package format, no @girs/* deps)"
|
|
22658
|
+
},
|
|
22503
22659
|
{
|
|
22504
22660
|
value: "types-workspace",
|
|
22505
22661
|
name: "types-workspace",
|
|
@@ -22512,19 +22668,34 @@ var builder3 = createBuilder(createOptions, examples3);
|
|
|
22512
22668
|
function findTemplatesRoot() {
|
|
22513
22669
|
const __filename = fileURLToPath4(import.meta.url);
|
|
22514
22670
|
const __dirname3 = dirname6(__filename);
|
|
22671
|
+
let realDirname = __dirname3;
|
|
22672
|
+
try {
|
|
22673
|
+
realDirname = dirname6(realpathSync(__filename));
|
|
22674
|
+
} catch {
|
|
22675
|
+
}
|
|
22515
22676
|
const candidates = [
|
|
22516
|
-
//
|
|
22677
|
+
// Symlink-resolved binary (`npm i -g` / `gjsify install -g`): the
|
|
22678
|
+
// realpath-aware candidate is required when the CLI is launched via a
|
|
22679
|
+
// `~/.local/bin/<name>` symlink that points at the real package's
|
|
22680
|
+
// `bin/<name>`. Try it first so the success path is symmetric across
|
|
22681
|
+
// install modes.
|
|
22682
|
+
resolve5(realDirname, "..", "dist-templates"),
|
|
22683
|
+
// Bundled production binary invoked at its real path (no symlink),
|
|
22684
|
+
// or a tarball extracted into a flat `bin/` + `dist-templates/` layout.
|
|
22517
22685
|
resolve5(__dirname3, "..", "dist-templates"),
|
|
22518
22686
|
// Source layout (src/commands/create.ts): ../../dist-templates then ../../templates
|
|
22519
22687
|
resolve5(__dirname3, "..", "..", "dist-templates"),
|
|
22520
22688
|
resolve5(__dirname3, "..", "..", "templates")
|
|
22521
22689
|
];
|
|
22690
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22522
22691
|
for (const path of candidates) {
|
|
22692
|
+
if (seen.has(path)) continue;
|
|
22693
|
+
seen.add(path);
|
|
22523
22694
|
if (existsSync3(path)) return path;
|
|
22524
22695
|
}
|
|
22525
22696
|
throw new Error(
|
|
22526
22697
|
`Could not locate templates directory. Looked in:
|
|
22527
|
-
${
|
|
22698
|
+
${[...seen].join("\n ")}
|
|
22528
22699
|
If you are running from source, make sure packages/cli/templates/ exists. If you are running the published CLI, make sure dist-templates/ was packed.`
|
|
22529
22700
|
);
|
|
22530
22701
|
}
|
|
@@ -22565,7 +22736,19 @@ function walkAndSubstitute(rootDir, projectName) {
|
|
|
22565
22736
|
var handler3 = async (args) => {
|
|
22566
22737
|
const opts = args;
|
|
22567
22738
|
const log3 = new Logger(opts.verbose ?? false, "CreateCommand");
|
|
22568
|
-
|
|
22739
|
+
let templatesRoot;
|
|
22740
|
+
try {
|
|
22741
|
+
templatesRoot = findTemplatesRoot();
|
|
22742
|
+
} catch (err) {
|
|
22743
|
+
if (typeof __GJS_BUNDLE__ !== "undefined") {
|
|
22744
|
+
process.stderr.write(
|
|
22745
|
+
"The 'create' command needs templates that aren't shipped alongside this binary.\nInstall the full package instead so `dist-templates/` lives next to the bin:\n gjsify install -g @ts-for-gir/cli\n npm install -g @ts-for-gir/cli\n npx @ts-for-gir/cli create ... # one-shot, no install\n"
|
|
22746
|
+
);
|
|
22747
|
+
process.exitCode = 1;
|
|
22748
|
+
return;
|
|
22749
|
+
}
|
|
22750
|
+
throw err;
|
|
22751
|
+
}
|
|
22569
22752
|
const available = listTemplates(templatesRoot);
|
|
22570
22753
|
if (available.length === 0) {
|
|
22571
22754
|
throw new Error(`No templates found in ${templatesRoot}`);
|
|
@@ -22611,18 +22794,26 @@ var handler3 = async (args) => {
|
|
|
22611
22794
|
walkAndSubstitute(targetDir, projectName);
|
|
22612
22795
|
log3.success(`Scaffolded ${template2} into ${targetDir}`);
|
|
22613
22796
|
if (opts.install) {
|
|
22614
|
-
|
|
22615
|
-
const
|
|
22797
|
+
const installer = template2 === "types-gjsify" ? "gjsify" : "npm";
|
|
22798
|
+
const installerArgs = template2 === "types-gjsify" ? ["install"] : ["install", "--no-audit", "--no-fund"];
|
|
22799
|
+
log3.info(`Running ${installer} install...`);
|
|
22800
|
+
const result = spawnSync(installer, installerArgs, {
|
|
22616
22801
|
cwd: targetDir,
|
|
22617
22802
|
stdio: "inherit"
|
|
22618
22803
|
});
|
|
22619
22804
|
if (result.status !== 0) {
|
|
22620
|
-
log3.warn(
|
|
22805
|
+
log3.warn(`${installer} install failed; you can re-run it manually in the project directory.`);
|
|
22621
22806
|
}
|
|
22622
22807
|
}
|
|
22623
22808
|
log3.info("\nNext steps:");
|
|
22624
22809
|
log3.white(` cd ${projectName}`);
|
|
22625
|
-
if (!opts.install)
|
|
22810
|
+
if (!opts.install) {
|
|
22811
|
+
if (template2 === "types-gjsify") {
|
|
22812
|
+
log3.white(" gjsify install");
|
|
22813
|
+
} else {
|
|
22814
|
+
log3.white(" npm install");
|
|
22815
|
+
}
|
|
22816
|
+
}
|
|
22626
22817
|
switch (template2) {
|
|
22627
22818
|
case "types-locally":
|
|
22628
22819
|
log3.white(" npm run generate");
|
|
@@ -22637,6 +22828,10 @@ var handler3 = async (args) => {
|
|
|
22637
22828
|
log3.white(" npm run build:types && npm install");
|
|
22638
22829
|
log3.white(" npm run build:app && npm start");
|
|
22639
22830
|
break;
|
|
22831
|
+
case "types-gjsify":
|
|
22832
|
+
log3.white(" gjsify run check");
|
|
22833
|
+
log3.white(" gjsify run build && gjsify run start");
|
|
22834
|
+
break;
|
|
22640
22835
|
}
|
|
22641
22836
|
};
|
|
22642
22837
|
var create = {
|
|
@@ -23032,23 +23227,27 @@ var SignalGenerator = class {
|
|
|
23032
23227
|
return interfaceTypeIdentifier ? `${interfaceTypeIdentifier}.SignalSignatures` : null;
|
|
23033
23228
|
}).filter((sig) => !!sig);
|
|
23034
23229
|
parentSignatures.push(...interfaceSignatures);
|
|
23035
|
-
let
|
|
23230
|
+
let signatureDecl;
|
|
23036
23231
|
if (parentSignatures.length > 0) {
|
|
23037
|
-
|
|
23232
|
+
signatureDecl = `interface SignalSignatures extends ${parentSignatures.join(", ")}`;
|
|
23038
23233
|
} else {
|
|
23039
23234
|
const isGObjectObject = girClass.name === "Object" && girClass.namespace.namespace === "GObject";
|
|
23040
23235
|
if (isGObjectObject) {
|
|
23041
|
-
|
|
23236
|
+
signatureDecl = `interface SignalSignatures`;
|
|
23042
23237
|
} else {
|
|
23043
23238
|
const gobjectNamespace = this.namespace.assertInstalledImport("GObject");
|
|
23044
23239
|
const gobjectObjectClass = gobjectNamespace.assertClass("Object");
|
|
23045
23240
|
const gobjectRef = gobjectObjectClass.getType().resolveIdentifier(this.namespace, this.config)?.print(this.namespace, this.config);
|
|
23046
23241
|
const fallbackRef = gobjectRef ? `${gobjectRef}.SignalSignatures` : "GObject.Object.SignalSignatures";
|
|
23047
|
-
|
|
23242
|
+
signatureDecl = `interface SignalSignatures extends ${fallbackRef}`;
|
|
23048
23243
|
}
|
|
23049
23244
|
}
|
|
23050
|
-
def.push(signatureHead);
|
|
23051
23245
|
const allSignals = girClass.getAllSignals();
|
|
23246
|
+
if (allSignals.length === 0) {
|
|
23247
|
+
def.push(`${indent}${signatureDecl} {}`);
|
|
23248
|
+
return def;
|
|
23249
|
+
}
|
|
23250
|
+
def.push(`${indent}${signatureDecl} {`);
|
|
23052
23251
|
allSignals.forEach((signalInfo) => {
|
|
23053
23252
|
let cbType;
|
|
23054
23253
|
if (signalInfo.isNotifySignal) {
|
|
@@ -23389,6 +23588,9 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
23389
23588
|
}
|
|
23390
23589
|
generateDirectAllocationConstructor(node, indentCount = 1) {
|
|
23391
23590
|
const indent = generateIndent(indentCount);
|
|
23591
|
+
if (node.parameters.length === 0) {
|
|
23592
|
+
return [`${indent}constructor(properties?: Partial<{}>);`];
|
|
23593
|
+
}
|
|
23392
23594
|
const fieldIndent = generateIndent(indentCount + 1);
|
|
23393
23595
|
const constructorFields = node.parameters.flatMap((param) => param.asField().asString(this)).flatMap((line) => line.split("\n")).map((line) => line.replace(/^\s+/, "")).filter((line) => line.length > 0).map((line) => `${fieldIndent}${line}`).join("\n");
|
|
23394
23596
|
return ["", `${indent}constructor(properties?: Partial<{`, constructorFields, `${indent}}>);`];
|
|
@@ -23497,7 +23699,7 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
23497
23699
|
parameters: [
|
|
23498
23700
|
new IntrospectedFunctionParameter({
|
|
23499
23701
|
name: "options",
|
|
23500
|
-
type: NativeType.of("{ message: string
|
|
23702
|
+
type: NativeType.of("{ message: string; code: number }"),
|
|
23501
23703
|
direction: "in" /* In */
|
|
23502
23704
|
})
|
|
23503
23705
|
],
|
|
@@ -23565,24 +23767,24 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
23565
23767
|
case 3 /* FUNCTION_NAME_CONFLICT */:
|
|
23566
23768
|
case 2 /* FIELD_NAME_CONFLICT */:
|
|
23567
23769
|
getterSetterAnnotation = setterAnnotation = "// This accessor conflicts with a field or function name in a parent class or interface.\n";
|
|
23568
|
-
type =
|
|
23770
|
+
type = makeUnion(type.unwrap(), AnyType);
|
|
23569
23771
|
printAsProperty = true;
|
|
23570
23772
|
break;
|
|
23571
23773
|
case 4 /* ACCESSOR_PROPERTY_CONFLICT */:
|
|
23572
23774
|
getterSetterAnnotation = getterAnnotation = "// This accessor conflicts with a property or field in a parent class or interface.\n";
|
|
23573
|
-
type =
|
|
23775
|
+
type = makeUnion(type.unwrap(), AnyType);
|
|
23574
23776
|
printAsProperty = true;
|
|
23575
23777
|
break;
|
|
23576
23778
|
case 5 /* PROPERTY_ACCESSOR_CONFLICT */:
|
|
23577
|
-
type =
|
|
23779
|
+
type = makeUnion(type.unwrap(), AnyType);
|
|
23578
23780
|
break;
|
|
23579
23781
|
case 1 /* PROPERTY_NAME_CONFLICT */:
|
|
23580
23782
|
getterSetterAnnotation = setterAnnotation = getterAnnotation = "// This accessor conflicts with another accessor's type in a parent class or interface.\n";
|
|
23581
|
-
type =
|
|
23783
|
+
type = makeUnion(type.unwrap(), AnyType);
|
|
23582
23784
|
break;
|
|
23583
23785
|
}
|
|
23584
23786
|
if (construct && !(type instanceof BinaryType)) {
|
|
23585
|
-
type =
|
|
23787
|
+
type = makeUnion(type instanceof TypeConflict ? type.unwrap() : type, AnyType);
|
|
23586
23788
|
}
|
|
23587
23789
|
}
|
|
23588
23790
|
const Type = type.resolve(this.namespace, this.options).rootPrint(this.namespace, this.options) || "any";
|
|
@@ -23629,7 +23831,7 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
23629
23831
|
type = type.unwrap();
|
|
23630
23832
|
} else if (type.conflictType === 3 /* FUNCTION_NAME_CONFLICT */) {
|
|
23631
23833
|
commentOut = "\n// This field conflicts with a function in a parent class or interface.\n";
|
|
23632
|
-
type =
|
|
23834
|
+
type = makeUnion(type.unwrap(), AnyType);
|
|
23633
23835
|
} else {
|
|
23634
23836
|
type = type.unwrap();
|
|
23635
23837
|
}
|
|
@@ -24056,6 +24258,10 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
24056
24258
|
const { props } = girClass;
|
|
24057
24259
|
const memberIndent = generateIndent(indentCount + 1);
|
|
24058
24260
|
const constructorPropMembers = filterConflicts(girClass.namespace, girClass, props, 1 /* PRESERVE */).flatMap((v) => v.asString(this, true)).map((m) => `${memberIndent}${m}`).join("\n");
|
|
24261
|
+
if (constructorPropMembers.length === 0) {
|
|
24262
|
+
def.push(`${indent}${exp}interface ${constructPropInterfaceName}${genericTypes} ${ext} {}`);
|
|
24263
|
+
return def;
|
|
24264
|
+
}
|
|
24059
24265
|
def.push(`${indent}${exp}interface ${constructPropInterfaceName}${genericTypes} ${ext} {`);
|
|
24060
24266
|
def.push(constructorPropMembers);
|
|
24061
24267
|
def.push(`${indent}}`);
|
|
@@ -26099,9 +26305,9 @@ var GirMetadataSerializer = class _GirMetadataSerializer {
|
|
|
26099
26305
|
[IntrospectedAlias, (s, o) => s.buildBaseMetadata(o, "alias")]
|
|
26100
26306
|
];
|
|
26101
26307
|
buildMetadata(girObj) {
|
|
26102
|
-
for (const [ctor,
|
|
26308
|
+
for (const [ctor, handler9] of _GirMetadataSerializer.METADATA_DISPATCH) {
|
|
26103
26309
|
if (girObj instanceof ctor) {
|
|
26104
|
-
return
|
|
26310
|
+
return handler9(this, girObj);
|
|
26105
26311
|
}
|
|
26106
26312
|
}
|
|
26107
26313
|
return null;
|
|
@@ -27159,14 +27365,14 @@ function getModuleName(row, moduleNames) {
|
|
|
27159
27365
|
return void 0;
|
|
27160
27366
|
}
|
|
27161
27367
|
function buildChunk(rows) {
|
|
27162
|
-
const
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27368
|
+
const builder9 = new import_lunr.default.Builder();
|
|
27369
|
+
builder9.pipeline.add(import_lunr.default.trimmer);
|
|
27370
|
+
builder9.ref("id");
|
|
27371
|
+
builder9.field("name", { boost: 10 });
|
|
27166
27372
|
for (let i = 0; i < rows.length; i++) {
|
|
27167
|
-
|
|
27373
|
+
builder9.add({ id: i, name: rows[i].name });
|
|
27168
27374
|
}
|
|
27169
|
-
const index =
|
|
27375
|
+
const index = builder9.build();
|
|
27170
27376
|
const data = { rows, index };
|
|
27171
27377
|
const compressed = deflateSync(Buffer.from(JSON.stringify(data)));
|
|
27172
27378
|
return compressed.toString("base64");
|
|
@@ -27623,7 +27829,7 @@ function giDocgenModuleMemberSummary(context, member) {
|
|
|
27623
27829
|
}
|
|
27624
27830
|
const nsMeta = member.girNamespaceMetadata;
|
|
27625
27831
|
const commentSummary = context.commentShortSummary(member);
|
|
27626
|
-
const
|
|
27832
|
+
const description9 = commentSummary || (nsMeta?.description ? JSX4.createElement("p", null, nsMeta.description) : null);
|
|
27627
27833
|
return JSX4.createElement(
|
|
27628
27834
|
JSX4.Fragment,
|
|
27629
27835
|
null,
|
|
@@ -27635,7 +27841,7 @@ function giDocgenModuleMemberSummary(context, member) {
|
|
|
27635
27841
|
JSX4.createElement(
|
|
27636
27842
|
"dd",
|
|
27637
27843
|
{ class: classNames({ "tsd-member-summary": true }, context.getReflectionClasses(member)) },
|
|
27638
|
-
|
|
27844
|
+
description9
|
|
27639
27845
|
)
|
|
27640
27846
|
);
|
|
27641
27847
|
}
|
|
@@ -27750,10 +27956,14 @@ import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
|
27750
27956
|
import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind5 } from "typedoc";
|
|
27751
27957
|
function getTsForGirVersion() {
|
|
27752
27958
|
if (true) {
|
|
27753
|
-
return "4.0.0
|
|
27959
|
+
return "4.0.0";
|
|
27960
|
+
}
|
|
27961
|
+
try {
|
|
27962
|
+
const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
|
|
27963
|
+
return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
|
|
27964
|
+
} catch {
|
|
27965
|
+
return "";
|
|
27754
27966
|
}
|
|
27755
|
-
const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
|
|
27756
|
-
return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
|
|
27757
27967
|
}
|
|
27758
27968
|
var TSFOR_GIR_VERSION = getTsForGirVersion();
|
|
27759
27969
|
function giDocgenModuleInfo(context, mod, nsMeta) {
|
|
@@ -28622,14 +28832,132 @@ var list = {
|
|
|
28622
28832
|
examples: examples7
|
|
28623
28833
|
};
|
|
28624
28834
|
|
|
28835
|
+
// src/commands/self-update.ts
|
|
28836
|
+
import { chmodSync, existsSync as existsSync5, renameSync, writeFileSync as writeFileSync5 } from "node:fs";
|
|
28837
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
28838
|
+
import { join as join17 } from "node:path";
|
|
28839
|
+
var REPO = "gjsify/ts-for-gir";
|
|
28840
|
+
var GITHUB_API = "https://api.github.com";
|
|
28841
|
+
var GJS_ASSET_NAME = "ts-for-gir-gjs";
|
|
28842
|
+
function getCurrentBinaryPath() {
|
|
28843
|
+
const p = process.argv[1] ?? null;
|
|
28844
|
+
if (!p) return null;
|
|
28845
|
+
if (p.endsWith(".ts") || p.includes("node_modules")) return null;
|
|
28846
|
+
return p;
|
|
28847
|
+
}
|
|
28848
|
+
async function fetchJson(url) {
|
|
28849
|
+
const headers = {
|
|
28850
|
+
Accept: "application/vnd.github.v3+json",
|
|
28851
|
+
"User-Agent": `ts-for-gir/${APP_VERSION}`
|
|
28852
|
+
};
|
|
28853
|
+
const token = process.env.GITHUB_TOKEN;
|
|
28854
|
+
if (token) headers.Authorization = `token ${token}`;
|
|
28855
|
+
const response = await fetch(url, { headers });
|
|
28856
|
+
if (!response.ok) {
|
|
28857
|
+
throw new Error(`HTTP ${response.status} from ${url}`);
|
|
28858
|
+
}
|
|
28859
|
+
return response.json();
|
|
28860
|
+
}
|
|
28861
|
+
async function downloadBinary(url, destPath) {
|
|
28862
|
+
const response = await fetch(url, {
|
|
28863
|
+
headers: { "User-Agent": `ts-for-gir/${APP_VERSION}` }
|
|
28864
|
+
});
|
|
28865
|
+
if (!response.ok) {
|
|
28866
|
+
throw new Error(`HTTP ${response.status} downloading binary`);
|
|
28867
|
+
}
|
|
28868
|
+
const buffer = await response.arrayBuffer();
|
|
28869
|
+
const tmpPath = join17(tmpdir2(), `ts-for-gir-update-${Date.now()}`);
|
|
28870
|
+
writeFileSync5(tmpPath, Buffer.from(buffer));
|
|
28871
|
+
chmodSync(tmpPath, 493);
|
|
28872
|
+
renameSync(tmpPath, destPath);
|
|
28873
|
+
}
|
|
28874
|
+
var command8 = "self-update";
|
|
28875
|
+
var description8 = "Update ts-for-gir to the latest version from GitHub releases";
|
|
28876
|
+
var examples8 = [
|
|
28877
|
+
[`${APP_NAME} self-update`, "Check for updates and install the latest version"],
|
|
28878
|
+
[`${APP_NAME} self-update --check`, "Only check for a newer version, do not install"],
|
|
28879
|
+
[`${APP_NAME} self-update --force`, "Force reinstall even if already on the latest version"]
|
|
28880
|
+
];
|
|
28881
|
+
var builder8 = (yargs2) => yargs2.option("check", {
|
|
28882
|
+
description: "Only check for a newer version, do not install",
|
|
28883
|
+
type: "boolean",
|
|
28884
|
+
default: false
|
|
28885
|
+
}).option("force", {
|
|
28886
|
+
description: "Force reinstall even if already on the latest version",
|
|
28887
|
+
type: "boolean",
|
|
28888
|
+
default: false
|
|
28889
|
+
}).example(examples8);
|
|
28890
|
+
var handler8 = async (args) => {
|
|
28891
|
+
console.log(`Checking for updates... (current: v${APP_VERSION})`);
|
|
28892
|
+
let release;
|
|
28893
|
+
try {
|
|
28894
|
+
release = await fetchJson(`${GITHUB_API}/repos/${REPO}/releases/latest`);
|
|
28895
|
+
} catch (err) {
|
|
28896
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
28897
|
+
process.stderr.write(`Failed to fetch release information: ${msg}
|
|
28898
|
+
`);
|
|
28899
|
+
process.exitCode = 1;
|
|
28900
|
+
return;
|
|
28901
|
+
}
|
|
28902
|
+
const latestVersion = release.tag_name.replace(/^v/, "");
|
|
28903
|
+
if (latestVersion === APP_VERSION && !args.force) {
|
|
28904
|
+
console.log(`Already up to date (v${APP_VERSION})`);
|
|
28905
|
+
return;
|
|
28906
|
+
}
|
|
28907
|
+
if (args.check) {
|
|
28908
|
+
console.log(`New version available: v${latestVersion} (current: v${APP_VERSION})`);
|
|
28909
|
+
console.log(`Run \`${APP_NAME} self-update\` to install it.`);
|
|
28910
|
+
return;
|
|
28911
|
+
}
|
|
28912
|
+
console.log(`Updating to v${latestVersion}...`);
|
|
28913
|
+
const assets = release.assets;
|
|
28914
|
+
const asset = assets.find((a) => a.name === GJS_ASSET_NAME);
|
|
28915
|
+
if (!asset) {
|
|
28916
|
+
process.stderr.write(
|
|
28917
|
+
`No GJS binary found in release ${release.tag_name}.
|
|
28918
|
+
self-update requires the GJS bundle to be installed via install.js.
|
|
28919
|
+
For npm installations use: npm update -g @ts-for-gir/cli
|
|
28920
|
+
`
|
|
28921
|
+
);
|
|
28922
|
+
process.exitCode = 1;
|
|
28923
|
+
return;
|
|
28924
|
+
}
|
|
28925
|
+
const currentPath = getCurrentBinaryPath();
|
|
28926
|
+
if (!currentPath || !existsSync5(currentPath)) {
|
|
28927
|
+
process.stderr.write(
|
|
28928
|
+
"Cannot determine current binary path for update.\nself-update only works when running the installed GJS binary.\n"
|
|
28929
|
+
);
|
|
28930
|
+
process.exitCode = 1;
|
|
28931
|
+
return;
|
|
28932
|
+
}
|
|
28933
|
+
try {
|
|
28934
|
+
await downloadBinary(asset.browser_download_url, currentPath);
|
|
28935
|
+
console.log(`Successfully updated to v${latestVersion}`);
|
|
28936
|
+
} catch (err) {
|
|
28937
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
28938
|
+
process.stderr.write(`Update failed: ${msg}
|
|
28939
|
+
`);
|
|
28940
|
+
process.exitCode = 1;
|
|
28941
|
+
}
|
|
28942
|
+
};
|
|
28943
|
+
var selfUpdate = {
|
|
28944
|
+
command: command8,
|
|
28945
|
+
description: description8,
|
|
28946
|
+
builder: builder8,
|
|
28947
|
+
handler: handler8,
|
|
28948
|
+
examples: examples8
|
|
28949
|
+
};
|
|
28950
|
+
|
|
28625
28951
|
// src/start.ts
|
|
28626
28952
|
try {
|
|
28627
|
-
|
|
28953
|
+
const cli = yargs(hideBin(process.argv));
|
|
28954
|
+
await cli.scriptName(APP_NAME).strict().usage(APP_USAGE).version(APP_VERSION).wrap(cli.terminalWidth()).exitProcess(false).fail(false).command(analyze).command(create).command(generate).command(json2).command(list).command(copy).command(doc).command(selfUpdate).demandCommand(1).help().parseAsync();
|
|
28955
|
+
process.exit(0);
|
|
28628
28956
|
} catch (err) {
|
|
28629
28957
|
const message = err instanceof Error ? err.message : String(err);
|
|
28630
28958
|
process.stderr.write(`${message}
|
|
28631
28959
|
`);
|
|
28632
|
-
process.
|
|
28960
|
+
process.exit(1);
|
|
28633
28961
|
}
|
|
28634
28962
|
/*! Bundled license information:
|
|
28635
28963
|
|