@ts-for-gir/cli 4.0.0-rc.2 → 4.0.0-rc.4
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/bin/ts-for-gir +360 -179
- package/dist-templates/types-locally/.ts-for-girrc.js +6 -0
- package/dist-templates/types-locally/README.md +15 -0
- package/dist-templates/types-locally/esbuild.ts +10 -0
- package/dist-templates/types-locally/main.ts +21 -0
- package/dist-templates/types-locally/package.json +18 -0
- package/dist-templates/types-locally/tsconfig.json +17 -0
- package/dist-templates/types-npm/README.md +14 -0
- package/dist-templates/types-npm/esbuild.ts +10 -0
- package/dist-templates/types-npm/main.ts +19 -0
- package/dist-templates/types-npm/package.json +23 -0
- package/dist-templates/types-npm/tsconfig.json +15 -0
- package/dist-templates/types-workspace/.ts-for-girrc.js +12 -0
- package/dist-templates/types-workspace/README.md +26 -0
- package/dist-templates/types-workspace/package.json +22 -0
- package/dist-templates/types-workspace/packages/app/esbuild.ts +10 -0
- package/dist-templates/types-workspace/packages/app/main.ts +19 -0
- package/dist-templates/types-workspace/packages/app/package.json +23 -0
- package/dist-templates/types-workspace/packages/app/tsconfig.json +15 -0
- package/dist-templates/types-workspace/tsconfig.json +11 -0
- package/package.json +14 -11
- package/src/commands/create.ts +214 -0
- package/src/commands/index.ts +1 -0
- package/src/config/config-loader.ts +1 -0
- package/src/config/index.ts +9 -1
- package/src/config/options.ts +27 -0
- package/src/start.ts +2 -1
- package/src/types/command-args.ts +23 -0
package/bin/ts-for-gir
CHANGED
|
@@ -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 join17(array, separator) {
|
|
3350
3350
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
3351
3351
|
}
|
|
3352
3352
|
function last(array) {
|
|
@@ -4304,7 +4304,7 @@ var require_lodash = __commonJS({
|
|
|
4304
4304
|
copyObject(source, keys(source), object, customizer);
|
|
4305
4305
|
});
|
|
4306
4306
|
var at = flatRest(baseAt);
|
|
4307
|
-
function
|
|
4307
|
+
function create2(prototype, properties) {
|
|
4308
4308
|
var result2 = baseCreate(prototype);
|
|
4309
4309
|
return properties == null ? result2 : baseAssign(result2, properties);
|
|
4310
4310
|
}
|
|
@@ -5056,7 +5056,7 @@ var require_lodash = __commonJS({
|
|
|
5056
5056
|
lodash2.conforms = conforms;
|
|
5057
5057
|
lodash2.constant = constant;
|
|
5058
5058
|
lodash2.countBy = countBy;
|
|
5059
|
-
lodash2.create =
|
|
5059
|
+
lodash2.create = create2;
|
|
5060
5060
|
lodash2.curry = curry;
|
|
5061
5061
|
lodash2.curryRight = curryRight;
|
|
5062
5062
|
lodash2.debounce = debounce;
|
|
@@ -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 = join17;
|
|
5274
5274
|
lodash2.kebabCase = kebabCase;
|
|
5275
5275
|
lodash2.last = last;
|
|
5276
5276
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -5532,17 +5532,17 @@ var require_lunr = __commonJS({
|
|
|
5532
5532
|
"../../.yarn/cache/lunr-npm-2.3.9-fa3aa9c2d6-f2f6db34c0.zip/node_modules/lunr/lunr.js"(exports2, module) {
|
|
5533
5533
|
(function() {
|
|
5534
5534
|
var lunr2 = function(config) {
|
|
5535
|
-
var
|
|
5536
|
-
|
|
5535
|
+
var builder8 = new lunr2.Builder();
|
|
5536
|
+
builder8.pipeline.add(
|
|
5537
5537
|
lunr2.trimmer,
|
|
5538
5538
|
lunr2.stopWordFilter,
|
|
5539
5539
|
lunr2.stemmer
|
|
5540
5540
|
);
|
|
5541
|
-
|
|
5541
|
+
builder8.searchPipeline.add(
|
|
5542
5542
|
lunr2.stemmer
|
|
5543
5543
|
);
|
|
5544
|
-
config.call(
|
|
5545
|
-
return
|
|
5544
|
+
config.call(builder8, builder8);
|
|
5545
|
+
return builder8.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 builder8 = new lunr2.TokenSet.Builder();
|
|
6222
6222
|
for (var i = 0, len = arr.length; i < len; i++) {
|
|
6223
|
-
|
|
6223
|
+
builder8.insert(arr[i]);
|
|
6224
6224
|
}
|
|
6225
|
-
|
|
6226
|
-
return
|
|
6225
|
+
builder8.finish();
|
|
6226
|
+
return builder8.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-rc.
|
|
7271
|
+
return "4.0.0-rc.4";
|
|
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: examples8 }) => {
|
|
7883
7883
|
console.log(` ${yellow(conflictType)}: ${count} conflicts`);
|
|
7884
|
-
if (
|
|
7885
|
-
console.log(` \u2514\u2500 Examples: ${gray(
|
|
7884
|
+
if (examples8.length > 0) {
|
|
7885
|
+
console.log(` \u2514\u2500 Examples: ${gray(examples8.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-rc.
|
|
8168
|
+
return "4.0.0-rc.4";
|
|
8169
8169
|
}
|
|
8170
8170
|
const currentModulePath = fileURLToPath2(import.meta.url);
|
|
8171
8171
|
const currentDir = dirname2(currentModulePath);
|
|
@@ -11113,13 +11113,22 @@ var DependencyManager = class _DependencyManager {
|
|
|
11113
11113
|
return this.config.noNamespace ? `import type * as ${namespace} from '${importPath}'` : `import type ${namespace} from '${importPath}';`;
|
|
11114
11114
|
}
|
|
11115
11115
|
createPackageJsonImport(importPath, libraryVersion) {
|
|
11116
|
+
const pinnedVersion = libraryVersion ? `${libraryVersion.toString()}-${APP_VERSION}` : APP_VERSION;
|
|
11117
|
+
const format = this.config.depVersionFormat ?? (this.config.workspace ? "workspace" : "exact");
|
|
11116
11118
|
let depVersion;
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11119
|
+
switch (format) {
|
|
11120
|
+
case "workspace":
|
|
11121
|
+
depVersion = "workspace:^";
|
|
11122
|
+
break;
|
|
11123
|
+
case "caret":
|
|
11124
|
+
depVersion = `^${pinnedVersion}`;
|
|
11125
|
+
break;
|
|
11126
|
+
case "any":
|
|
11127
|
+
depVersion = "*";
|
|
11128
|
+
break;
|
|
11129
|
+
default:
|
|
11130
|
+
depVersion = pinnedVersion;
|
|
11131
|
+
break;
|
|
11123
11132
|
}
|
|
11124
11133
|
return `"${importPath}": "${depVersion}"`;
|
|
11125
11134
|
}
|
|
@@ -12101,6 +12110,8 @@ function resolvePrimitiveType(name) {
|
|
|
12101
12110
|
case "gint64":
|
|
12102
12111
|
case "gssize":
|
|
12103
12112
|
case "gsize":
|
|
12113
|
+
case "guintptr":
|
|
12114
|
+
// Integer of the same width as a pointer
|
|
12104
12115
|
case "time_t":
|
|
12105
12116
|
// C standard library time type (seconds since Unix epoch)
|
|
12106
12117
|
case "ulong":
|
|
@@ -12113,8 +12124,6 @@ function resolvePrimitiveType(name) {
|
|
|
12113
12124
|
return ObjectType;
|
|
12114
12125
|
case "va_list":
|
|
12115
12126
|
return AnyType;
|
|
12116
|
-
case "guintptr":
|
|
12117
|
-
return NeverType;
|
|
12118
12127
|
case "never":
|
|
12119
12128
|
return NeverType;
|
|
12120
12129
|
case "unknown":
|
|
@@ -15202,16 +15211,16 @@ function transformBacktickTypeRefs(text, ctx) {
|
|
|
15202
15211
|
});
|
|
15203
15212
|
return text;
|
|
15204
15213
|
}
|
|
15205
|
-
function transformGirDocHighlights(
|
|
15206
|
-
return
|
|
15214
|
+
function transformGirDocHighlights(description8) {
|
|
15215
|
+
return description8.replace(/(?<!\{)(?<!\w)@([A-Za-z_][A-Za-z0-9_]*)/g, "`$1`");
|
|
15207
15216
|
}
|
|
15208
|
-
function transformGirDocCodeBlocks(
|
|
15209
|
-
|
|
15217
|
+
function transformGirDocCodeBlocks(description8) {
|
|
15218
|
+
description8 = description8.replaceAll(/```\s*\{\s*\.(\w+)[^}]*\}/gm, "```$1").replaceAll(/\|\[<!-- language="([^"]+)" -->/gm, (_match, lang) => {
|
|
15210
15219
|
if (lang === "plain" || lang === "text") return "\n```";
|
|
15211
15220
|
return `
|
|
15212
15221
|
\`\`\`${lang.toLowerCase()}`;
|
|
15213
15222
|
}).replaceAll(/\|\[/gm, "\n```").replaceAll(/\]\|/gm, "```\n");
|
|
15214
|
-
return
|
|
15223
|
+
return description8;
|
|
15215
15224
|
}
|
|
15216
15225
|
|
|
15217
15226
|
// ../lib/src/utils/objects.ts
|
|
@@ -18662,33 +18671,6 @@ var ClassVisitor = class extends GirVisitor {
|
|
|
18662
18671
|
);
|
|
18663
18672
|
};
|
|
18664
18673
|
|
|
18665
|
-
// ../lib/src/validators/function-parameters.ts
|
|
18666
|
-
var FunctionParametersVisitor = class extends GirVisitor {
|
|
18667
|
-
makeEnumParamsNullable(node) {
|
|
18668
|
-
return node.copy({
|
|
18669
|
-
parameters: node.parameters.map((param) => {
|
|
18670
|
-
const type = param.type.deepUnwrap();
|
|
18671
|
-
if (type instanceof TypeIdentifier) {
|
|
18672
|
-
const ns = node.namespace.assertInstalledImport(type.namespace);
|
|
18673
|
-
const isEnumType = !!ns.getEnum(type.name);
|
|
18674
|
-
if (isEnumType) {
|
|
18675
|
-
return param.copy({
|
|
18676
|
-
type: new NullableType(param.type)
|
|
18677
|
-
});
|
|
18678
|
-
}
|
|
18679
|
-
}
|
|
18680
|
-
return param;
|
|
18681
|
-
})
|
|
18682
|
-
});
|
|
18683
|
-
}
|
|
18684
|
-
visitFunction = (node) => {
|
|
18685
|
-
return this.makeEnumParamsNullable(node);
|
|
18686
|
-
};
|
|
18687
|
-
visitClassFunction = (node) => {
|
|
18688
|
-
return this.makeEnumParamsNullable(node);
|
|
18689
|
-
};
|
|
18690
|
-
};
|
|
18691
|
-
|
|
18692
18674
|
// ../lib/src/validators/interface.ts
|
|
18693
18675
|
var InterfaceVisitor = class extends GirVisitor {
|
|
18694
18676
|
visitInterface = (node) => {
|
|
@@ -18783,8 +18765,6 @@ var NSRegistry = class {
|
|
|
18783
18765
|
this.registerTransformation(interfaceVisitor);
|
|
18784
18766
|
const classVisitor = new ClassVisitor();
|
|
18785
18767
|
this.registerTransformation(classVisitor);
|
|
18786
|
-
const enumParamsVisitor = new FunctionParametersVisitor();
|
|
18787
|
-
this.registerTransformation(enumParamsVisitor);
|
|
18788
18768
|
console.log("Adding generics...");
|
|
18789
18769
|
generify(this, options2.inferGenerics);
|
|
18790
18770
|
console.log("Injecting types...");
|
|
@@ -19534,6 +19514,11 @@ var options = {
|
|
|
19534
19514
|
default: defaults.workspace,
|
|
19535
19515
|
normalize: true
|
|
19536
19516
|
},
|
|
19517
|
+
depVersionFormat: {
|
|
19518
|
+
type: "string",
|
|
19519
|
+
description: "Dependency version spec format in generated package.json files. Defaults to 'workspace' when --workspace, else 'exact'",
|
|
19520
|
+
choices: ["workspace", "caret", "any", "exact"]
|
|
19521
|
+
},
|
|
19537
19522
|
onlyVersionPrefix: {
|
|
19538
19523
|
type: "boolean",
|
|
19539
19524
|
description: "Only use the version prefix for the ambient module exports. This is useful if, for whatever reason, you want to use different library versions of the same library in your project.",
|
|
@@ -19586,6 +19571,7 @@ var generateOptions = {
|
|
|
19586
19571
|
promisify: options.promisify,
|
|
19587
19572
|
npmScope: options.npmScope,
|
|
19588
19573
|
workspace: options.workspace,
|
|
19574
|
+
depVersionFormat: options.depVersionFormat,
|
|
19589
19575
|
onlyVersionPrefix: options.onlyVersionPrefix,
|
|
19590
19576
|
noPrettyPrint: options.noPrettyPrint,
|
|
19591
19577
|
noAdvancedVariants: options.noAdvancedVariants,
|
|
@@ -19641,6 +19627,25 @@ var docOptions = {
|
|
|
19641
19627
|
description: "Directory containing pre-generated TypeDoc JSON files for merge mode (from 'ts-for-gir json')"
|
|
19642
19628
|
}
|
|
19643
19629
|
};
|
|
19630
|
+
var createOptions = {
|
|
19631
|
+
template: {
|
|
19632
|
+
type: "string",
|
|
19633
|
+
alias: "t",
|
|
19634
|
+
description: "Template to scaffold (types-locally, types-npm, types-workspace)",
|
|
19635
|
+
choices: ["types-locally", "types-npm", "types-workspace"]
|
|
19636
|
+
},
|
|
19637
|
+
install: {
|
|
19638
|
+
type: "boolean",
|
|
19639
|
+
description: "Run npm install after scaffolding (use --no-install to skip)",
|
|
19640
|
+
default: true
|
|
19641
|
+
},
|
|
19642
|
+
force: {
|
|
19643
|
+
type: "boolean",
|
|
19644
|
+
description: "Allow scaffolding into a non-empty target directory",
|
|
19645
|
+
default: false
|
|
19646
|
+
},
|
|
19647
|
+
verbose: options.verbose
|
|
19648
|
+
};
|
|
19644
19649
|
var analyzeOptions = {
|
|
19645
19650
|
reportFile: {
|
|
19646
19651
|
type: "string",
|
|
@@ -19807,6 +19812,7 @@ async function load(cliOptions) {
|
|
|
19807
19812
|
const stringKeys = [
|
|
19808
19813
|
["npmScope", options.npmScope.default],
|
|
19809
19814
|
["reporterOutput", options.reporterOutput.default],
|
|
19815
|
+
["depVersionFormat", void 0],
|
|
19810
19816
|
["theme", docOptions.theme.default],
|
|
19811
19817
|
["sourceLinkTemplate", void 0],
|
|
19812
19818
|
["readme", void 0],
|
|
@@ -19845,13 +19851,13 @@ async function load(cliOptions) {
|
|
|
19845
19851
|
}
|
|
19846
19852
|
|
|
19847
19853
|
// src/commands/command-builder.ts
|
|
19848
|
-
function createBuilder(options2,
|
|
19854
|
+
function createBuilder(options2, examples8) {
|
|
19849
19855
|
return (yargs2) => {
|
|
19850
19856
|
const optionNames = Object.keys(options2);
|
|
19851
19857
|
for (const optionName of optionNames) {
|
|
19852
19858
|
yargs2 = yargs2.option(optionName, options2[optionName]);
|
|
19853
19859
|
}
|
|
19854
|
-
return yargs2.example(
|
|
19860
|
+
return yargs2.example(examples8);
|
|
19855
19861
|
};
|
|
19856
19862
|
}
|
|
19857
19863
|
|
|
@@ -20672,9 +20678,184 @@ var copy = {
|
|
|
20672
20678
|
examples: examples2
|
|
20673
20679
|
};
|
|
20674
20680
|
|
|
20681
|
+
// src/commands/create.ts
|
|
20682
|
+
import { spawnSync } from "node:child_process";
|
|
20683
|
+
import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
20684
|
+
import { dirname as dirname6, join as join9, resolve as resolve5 } from "node:path";
|
|
20685
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
20686
|
+
import { input, select as select2 } from "@inquirer/prompts";
|
|
20687
|
+
var command3 = "create [name]";
|
|
20688
|
+
var description3 = "Scaffold a new GJS TypeScript project from a template";
|
|
20689
|
+
var examples3 = [
|
|
20690
|
+
[`${APP_NAME} create my-app --template types-npm`, "Scaffold using the @girs/* NPM types"],
|
|
20691
|
+
[`${APP_NAME} create my-app --template types-locally`, "Scaffold and generate types into ./@types/ locally"],
|
|
20692
|
+
[
|
|
20693
|
+
`${APP_NAME} create my-app --template types-workspace`,
|
|
20694
|
+
"Scaffold an npm workspace with types as workspace packages"
|
|
20695
|
+
],
|
|
20696
|
+
[`${APP_NAME} create`, "Interactive: prompts for name and template"]
|
|
20697
|
+
];
|
|
20698
|
+
var TEMPLATE_CHOICES = [
|
|
20699
|
+
{
|
|
20700
|
+
value: "types-locally",
|
|
20701
|
+
name: "types-locally",
|
|
20702
|
+
description: "Generate GIR types directly into ./@types/ (no package format, no @girs/* deps)"
|
|
20703
|
+
},
|
|
20704
|
+
{
|
|
20705
|
+
value: "types-npm",
|
|
20706
|
+
name: "types-npm",
|
|
20707
|
+
description: "Use pre-generated types from the @girs/* NPM packages"
|
|
20708
|
+
},
|
|
20709
|
+
{
|
|
20710
|
+
value: "types-workspace",
|
|
20711
|
+
name: "types-workspace",
|
|
20712
|
+
description: "npm workspace; generate @girs/* as workspace packages under ./@girs/"
|
|
20713
|
+
}
|
|
20714
|
+
];
|
|
20715
|
+
var PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
|
|
20716
|
+
var TEXT_FILE_EXT = /* @__PURE__ */ new Set([".json", ".md", ".ts", ".tsx", ".js", ".mjs", ".cjs"]);
|
|
20717
|
+
var builder3 = createBuilder(createOptions, examples3);
|
|
20718
|
+
function findTemplatesRoot() {
|
|
20719
|
+
const __filename2 = fileURLToPath4(import.meta.url);
|
|
20720
|
+
const __dirname3 = dirname6(__filename2);
|
|
20721
|
+
const candidates = [
|
|
20722
|
+
// Bundled production binary (bin/ts-for-gir): ../dist-templates
|
|
20723
|
+
resolve5(__dirname3, "..", "dist-templates"),
|
|
20724
|
+
// Source layout (src/commands/create.ts): ../../dist-templates then ../../templates
|
|
20725
|
+
resolve5(__dirname3, "..", "..", "dist-templates"),
|
|
20726
|
+
resolve5(__dirname3, "..", "..", "templates")
|
|
20727
|
+
];
|
|
20728
|
+
for (const path of candidates) {
|
|
20729
|
+
if (existsSync3(path)) return path;
|
|
20730
|
+
}
|
|
20731
|
+
throw new Error(
|
|
20732
|
+
`Could not locate templates directory. Looked in:
|
|
20733
|
+
${candidates.join("\n ")}
|
|
20734
|
+
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.`
|
|
20735
|
+
);
|
|
20736
|
+
}
|
|
20737
|
+
function listTemplates(templatesRoot) {
|
|
20738
|
+
const knownIds = TEMPLATE_CHOICES.map((c) => c.value);
|
|
20739
|
+
return readdirSync(templatesRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => knownIds.includes(name));
|
|
20740
|
+
}
|
|
20741
|
+
function sanitizeProjectName(raw) {
|
|
20742
|
+
const trimmed = raw.trim();
|
|
20743
|
+
if (!trimmed) throw new Error("Project name cannot be empty");
|
|
20744
|
+
const cleaned = trimmed.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").replace(/[._-]+$/, "");
|
|
20745
|
+
if (!cleaned) throw new Error(`"${raw}" is not a valid npm package name`);
|
|
20746
|
+
return cleaned;
|
|
20747
|
+
}
|
|
20748
|
+
function isDirEmpty(path) {
|
|
20749
|
+
if (!existsSync3(path)) return true;
|
|
20750
|
+
return readdirSync(path).length === 0;
|
|
20751
|
+
}
|
|
20752
|
+
function substituteInFile(filePath, projectName) {
|
|
20753
|
+
const content = readFileSync4(filePath, "utf8");
|
|
20754
|
+
if (!content.includes(PROJECT_NAME_PLACEHOLDER)) return;
|
|
20755
|
+
writeFileSync2(filePath, content.replaceAll(PROJECT_NAME_PLACEHOLDER, projectName));
|
|
20756
|
+
}
|
|
20757
|
+
function walkAndSubstitute(rootDir, projectName) {
|
|
20758
|
+
for (const entry of readdirSync(rootDir, { withFileTypes: true })) {
|
|
20759
|
+
const full = join9(rootDir, entry.name);
|
|
20760
|
+
if (entry.isDirectory()) {
|
|
20761
|
+
if (entry.name === "node_modules") continue;
|
|
20762
|
+
walkAndSubstitute(full, projectName);
|
|
20763
|
+
continue;
|
|
20764
|
+
}
|
|
20765
|
+
if (!entry.isFile()) continue;
|
|
20766
|
+
const ext = entry.name.slice(entry.name.lastIndexOf("."));
|
|
20767
|
+
if (!TEXT_FILE_EXT.has(ext)) continue;
|
|
20768
|
+
substituteInFile(full, projectName);
|
|
20769
|
+
}
|
|
20770
|
+
}
|
|
20771
|
+
var handler3 = async (args) => {
|
|
20772
|
+
const opts = args;
|
|
20773
|
+
const log3 = new Logger(opts.verbose ?? false, "CreateCommand");
|
|
20774
|
+
const templatesRoot = findTemplatesRoot();
|
|
20775
|
+
const available = listTemplates(templatesRoot);
|
|
20776
|
+
if (available.length === 0) {
|
|
20777
|
+
throw new Error(`No templates found in ${templatesRoot}`);
|
|
20778
|
+
}
|
|
20779
|
+
let template2 = opts.template;
|
|
20780
|
+
if (template2 && !available.includes(template2)) {
|
|
20781
|
+
throw new Error(`Unknown template "${template2}". Available: ${available.join(", ")}`);
|
|
20782
|
+
}
|
|
20783
|
+
if (!template2) {
|
|
20784
|
+
if (!process.stdin.isTTY) {
|
|
20785
|
+
throw new Error(`--template is required (non-TTY). Available: ${available.join(", ")}`);
|
|
20786
|
+
}
|
|
20787
|
+
template2 = await select2({
|
|
20788
|
+
message: "Choose a template:",
|
|
20789
|
+
choices: TEMPLATE_CHOICES.filter((c) => available.includes(c.value)).map((c) => ({
|
|
20790
|
+
value: c.value,
|
|
20791
|
+
name: c.name,
|
|
20792
|
+
description: c.description
|
|
20793
|
+
}))
|
|
20794
|
+
});
|
|
20795
|
+
}
|
|
20796
|
+
let nameRaw = opts.name;
|
|
20797
|
+
if (!nameRaw) {
|
|
20798
|
+
if (!process.stdin.isTTY) {
|
|
20799
|
+
throw new Error("Project name is required (non-TTY). Pass it as the first positional argument.");
|
|
20800
|
+
}
|
|
20801
|
+
nameRaw = await input({
|
|
20802
|
+
message: "Project name:",
|
|
20803
|
+
default: "my-gjs-app",
|
|
20804
|
+
validate: (v) => v.trim().length > 0 ? true : "Project name cannot be empty"
|
|
20805
|
+
});
|
|
20806
|
+
}
|
|
20807
|
+
const projectName = sanitizeProjectName(nameRaw);
|
|
20808
|
+
const targetDir = resolve5(process.cwd(), projectName);
|
|
20809
|
+
if (existsSync3(targetDir) && !isDirEmpty(targetDir) && !opts.force) {
|
|
20810
|
+
throw new Error(
|
|
20811
|
+
`Target directory ${targetDir} exists and is not empty. Use --force to scaffold into a non-empty directory.`
|
|
20812
|
+
);
|
|
20813
|
+
}
|
|
20814
|
+
mkdirSync(targetDir, { recursive: true });
|
|
20815
|
+
const templateDir = join9(templatesRoot, template2);
|
|
20816
|
+
cpSync(templateDir, targetDir, { recursive: true });
|
|
20817
|
+
walkAndSubstitute(targetDir, projectName);
|
|
20818
|
+
log3.success(`Scaffolded ${template2} into ${targetDir}`);
|
|
20819
|
+
if (opts.install) {
|
|
20820
|
+
log3.info("Running npm install...");
|
|
20821
|
+
const result = spawnSync("npm", ["install", "--no-audit", "--no-fund"], {
|
|
20822
|
+
cwd: targetDir,
|
|
20823
|
+
stdio: "inherit"
|
|
20824
|
+
});
|
|
20825
|
+
if (result.status !== 0) {
|
|
20826
|
+
log3.warn("npm install failed; you can re-run it manually in the project directory.");
|
|
20827
|
+
}
|
|
20828
|
+
}
|
|
20829
|
+
log3.info("\nNext steps:");
|
|
20830
|
+
log3.white(` cd ${projectName}`);
|
|
20831
|
+
if (!opts.install) log3.white(" npm install");
|
|
20832
|
+
switch (template2) {
|
|
20833
|
+
case "types-locally":
|
|
20834
|
+
log3.white(" npm run generate");
|
|
20835
|
+
log3.white(" npm run check:types");
|
|
20836
|
+
log3.white(" npm run build && npm start");
|
|
20837
|
+
break;
|
|
20838
|
+
case "types-npm":
|
|
20839
|
+
log3.white(" npm run check");
|
|
20840
|
+
log3.white(" npm run build && npm start");
|
|
20841
|
+
break;
|
|
20842
|
+
case "types-workspace":
|
|
20843
|
+
log3.white(" npm run build:types && npm install");
|
|
20844
|
+
log3.white(" npm run build:app && npm start");
|
|
20845
|
+
break;
|
|
20846
|
+
}
|
|
20847
|
+
};
|
|
20848
|
+
var create = {
|
|
20849
|
+
command: command3,
|
|
20850
|
+
description: description3,
|
|
20851
|
+
builder: builder3,
|
|
20852
|
+
handler: handler3,
|
|
20853
|
+
examples: examples3
|
|
20854
|
+
};
|
|
20855
|
+
|
|
20675
20856
|
// ../generator-html-doc/src/html-doc-generator.ts
|
|
20676
20857
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
20677
|
-
import { join as
|
|
20858
|
+
import { join as join16 } from "node:path";
|
|
20678
20859
|
|
|
20679
20860
|
// ../generator-json/src/gir-metadata-deserializer.ts
|
|
20680
20861
|
import { DeclarationReflection } from "typedoc";
|
|
@@ -20700,16 +20881,16 @@ var GirMetadataDeserializer = class {
|
|
|
20700
20881
|
|
|
20701
20882
|
// ../generator-json/src/json-definition-generator.ts
|
|
20702
20883
|
import { mkdir as mkdir3, writeFile as writeFile5 } from "node:fs/promises";
|
|
20703
|
-
import { join as
|
|
20884
|
+
import { join as join12 } from "node:path";
|
|
20704
20885
|
|
|
20705
20886
|
// ../generator-json/src/typedoc-pipeline.ts
|
|
20706
|
-
import { readFileSync as
|
|
20887
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
20707
20888
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
20708
20889
|
import { tmpdir } from "node:os";
|
|
20709
|
-
import { join as
|
|
20890
|
+
import { join as join11 } from "node:path";
|
|
20710
20891
|
|
|
20711
20892
|
// ../generator-typescript/src/template-processor.ts
|
|
20712
|
-
import { dirname as
|
|
20893
|
+
import { dirname as dirname7, join as join10, relative } from "node:path";
|
|
20713
20894
|
var TemplateProcessor = class extends TemplateEngine {
|
|
20714
20895
|
data;
|
|
20715
20896
|
packageName;
|
|
@@ -20739,8 +20920,8 @@ var TemplateProcessor = class extends TemplateEngine {
|
|
|
20739
20920
|
dep,
|
|
20740
20921
|
deps,
|
|
20741
20922
|
typeDir,
|
|
20742
|
-
join:
|
|
20743
|
-
dirname:
|
|
20923
|
+
join: join10,
|
|
20924
|
+
dirname: dirname7,
|
|
20744
20925
|
...this.config,
|
|
20745
20926
|
packageName: this.packageName
|
|
20746
20927
|
};
|
|
@@ -20810,10 +20991,10 @@ ${append}`;
|
|
|
20810
20991
|
const rendered = await this.loadAll(templateDirname, fileExtension, ejsOptions, overrideTemplateData);
|
|
20811
20992
|
const result = {};
|
|
20812
20993
|
for (const filename of Object.keys(rendered)) {
|
|
20813
|
-
const destPath =
|
|
20994
|
+
const destPath = join10(baseOutputPath, outputDirname, filename);
|
|
20814
20995
|
result[destPath] = `${rendered[filename]}
|
|
20815
20996
|
${append}`;
|
|
20816
|
-
await this.write(result[destPath], baseOutputPath,
|
|
20997
|
+
await this.write(result[destPath], baseOutputPath, join10(outputDirname, filename));
|
|
20817
20998
|
}
|
|
20818
20999
|
return result;
|
|
20819
21000
|
}
|
|
@@ -20822,8 +21003,8 @@ ${append}`;
|
|
|
20822
21003
|
* This is TypeScript-specific logic for handling package.json mode
|
|
20823
21004
|
*/
|
|
20824
21005
|
getOutputPath(baseOutputPath, outputFilename) {
|
|
20825
|
-
const filePath = this.config.package ?
|
|
20826
|
-
const outputPath =
|
|
21006
|
+
const filePath = this.config.package ? join10(this.data?.importName || this.packageName, outputFilename) : outputFilename;
|
|
21007
|
+
const outputPath = join10(baseOutputPath, filePath);
|
|
20827
21008
|
return outputPath;
|
|
20828
21009
|
}
|
|
20829
21010
|
/**
|
|
@@ -24082,9 +24263,9 @@ var GirMetadataSerializer = class _GirMetadataSerializer {
|
|
|
24082
24263
|
[IntrospectedAlias, (s, o) => s.buildBaseMetadata(o, "alias")]
|
|
24083
24264
|
];
|
|
24084
24265
|
buildMetadata(girObj) {
|
|
24085
|
-
for (const [ctor,
|
|
24266
|
+
for (const [ctor, handler8] of _GirMetadataSerializer.METADATA_DISPATCH) {
|
|
24086
24267
|
if (girObj instanceof ctor) {
|
|
24087
|
-
return
|
|
24268
|
+
return handler8(this, girObj);
|
|
24088
24269
|
}
|
|
24089
24270
|
}
|
|
24090
24271
|
return null;
|
|
@@ -24209,7 +24390,7 @@ var TypeDocPipeline = class {
|
|
|
24209
24390
|
return this._modules;
|
|
24210
24391
|
}
|
|
24211
24392
|
async start() {
|
|
24212
|
-
this.tempDir = await mkdtemp(
|
|
24393
|
+
this.tempDir = await mkdtemp(join11(tmpdir(), "ts-for-gir-typedoc-"));
|
|
24213
24394
|
const tempConfig = {
|
|
24214
24395
|
...this.config,
|
|
24215
24396
|
outdir: this.tempDir,
|
|
@@ -24236,10 +24417,10 @@ var TypeDocPipeline = class {
|
|
|
24236
24417
|
* convert to ProjectReflection, and enrich with GIR metadata.
|
|
24237
24418
|
*/
|
|
24238
24419
|
async createTypeDocApp(module) {
|
|
24239
|
-
const moduleDir =
|
|
24240
|
-
const entryPoint =
|
|
24241
|
-
const tsconfigPath =
|
|
24242
|
-
const readmePath =
|
|
24420
|
+
const moduleDir = join11(this.tempDir, module.importName);
|
|
24421
|
+
const entryPoint = join11(moduleDir, `${module.importName}.d.ts`);
|
|
24422
|
+
const tsconfigPath = join11(moduleDir, "tsconfig.json");
|
|
24423
|
+
const readmePath = join11(moduleDir, "README.md");
|
|
24243
24424
|
const result = await this.bootstrapAndConvert(
|
|
24244
24425
|
{
|
|
24245
24426
|
entryPoints: [entryPoint],
|
|
@@ -24265,13 +24446,13 @@ var TypeDocPipeline = class {
|
|
|
24265
24446
|
* Useful for TypeDoc's `projectToObject()` base path.
|
|
24266
24447
|
*/
|
|
24267
24448
|
getModuleDir(module) {
|
|
24268
|
-
return normalizePath(
|
|
24449
|
+
return normalizePath(join11(this.tempDir, module.importName));
|
|
24269
24450
|
}
|
|
24270
24451
|
/**
|
|
24271
24452
|
* Get the normalized path to the GJS package temporary directory.
|
|
24272
24453
|
*/
|
|
24273
24454
|
getGjsDir() {
|
|
24274
|
-
return normalizePath(
|
|
24455
|
+
return normalizePath(join11(this.tempDir, "gjs"));
|
|
24275
24456
|
}
|
|
24276
24457
|
/**
|
|
24277
24458
|
* Bootstrap a TypeDoc Application for the GJS core types package.
|
|
@@ -24284,16 +24465,16 @@ var TypeDocPipeline = class {
|
|
|
24284
24465
|
* Returns null if the GJS package was not generated (e.g. temp dir missing).
|
|
24285
24466
|
*/
|
|
24286
24467
|
async createGjsTypeDocApp() {
|
|
24287
|
-
const gjsDir =
|
|
24288
|
-
const tsconfigPath =
|
|
24289
|
-
const readmePath =
|
|
24468
|
+
const gjsDir = join11(this.tempDir, "gjs");
|
|
24469
|
+
const tsconfigPath = join11(gjsDir, "tsconfig.json");
|
|
24470
|
+
const readmePath = join11(gjsDir, "README.md");
|
|
24290
24471
|
const entryPoints = [
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
|
|
24294
|
-
|
|
24295
|
-
|
|
24296
|
-
|
|
24472
|
+
join11(gjsDir, "gjs.d.ts"),
|
|
24473
|
+
join11(gjsDir, "cairo.d.ts"),
|
|
24474
|
+
join11(gjsDir, "gettext.d.ts"),
|
|
24475
|
+
join11(gjsDir, "system.d.ts"),
|
|
24476
|
+
join11(gjsDir, "dom.d.ts"),
|
|
24477
|
+
join11(gjsDir, "console.d.ts")
|
|
24297
24478
|
];
|
|
24298
24479
|
try {
|
|
24299
24480
|
const result = await this.bootstrapAndConvert(
|
|
@@ -24322,7 +24503,7 @@ var TypeDocPipeline = class {
|
|
|
24322
24503
|
async createCombinedTypeDocApp() {
|
|
24323
24504
|
const result = await this.bootstrapAndConvert(
|
|
24324
24505
|
{
|
|
24325
|
-
entryPoints: [
|
|
24506
|
+
entryPoints: [join11(this.tempDir, "*")],
|
|
24326
24507
|
entryPointStrategy: "packages",
|
|
24327
24508
|
name: "TypeScript API Documentation for GJS",
|
|
24328
24509
|
...this.sourceLinkOptions,
|
|
@@ -24348,7 +24529,7 @@ var TypeDocPipeline = class {
|
|
|
24348
24529
|
async createMergedTypeDocApp(jsonDir) {
|
|
24349
24530
|
const app = await this.bootstrapApp(
|
|
24350
24531
|
{
|
|
24351
|
-
entryPoints: [
|
|
24532
|
+
entryPoints: [join11(jsonDir, "*.json")],
|
|
24352
24533
|
entryPointStrategy: "merge",
|
|
24353
24534
|
name: "TypeScript API Documentation for GJS"
|
|
24354
24535
|
},
|
|
@@ -24717,7 +24898,7 @@ var TypeDocPipeline = class {
|
|
|
24717
24898
|
/** Try to read the generated package.json for a module from the temp directory. */
|
|
24718
24899
|
readPackageJson(importName) {
|
|
24719
24900
|
try {
|
|
24720
|
-
const content =
|
|
24901
|
+
const content = readFileSync5(join11(this.tempDir, importName, "package.json"), "utf8");
|
|
24721
24902
|
return JSON.parse(content);
|
|
24722
24903
|
} catch {
|
|
24723
24904
|
return null;
|
|
@@ -24784,7 +24965,7 @@ var JsonDefinitionGenerator = class _JsonDefinitionGenerator {
|
|
|
24784
24965
|
const jsonStr = `${JSON.stringify(jsonOutput, null, pretty ? " " : "")}
|
|
24785
24966
|
`;
|
|
24786
24967
|
if (this.config.outdir) {
|
|
24787
|
-
const filepath =
|
|
24968
|
+
const filepath = join12(this.config.outdir, "Gjs.json");
|
|
24788
24969
|
await writeFile5(filepath, jsonStr, "utf8");
|
|
24789
24970
|
this.log.info(`Generated ${filepath}`);
|
|
24790
24971
|
} else {
|
|
@@ -24799,7 +24980,7 @@ var JsonDefinitionGenerator = class _JsonDefinitionGenerator {
|
|
|
24799
24980
|
const jsonStr = `${JSON.stringify(jsonOutput, null, pretty ? " " : "")}
|
|
24800
24981
|
`;
|
|
24801
24982
|
if (this.config.outdir) {
|
|
24802
|
-
const filepath =
|
|
24983
|
+
const filepath = join12(this.config.outdir, `${module.packageName}.json`);
|
|
24803
24984
|
await writeFile5(filepath, jsonStr, "utf8");
|
|
24804
24985
|
this.log.info(`Generated ${filepath}`);
|
|
24805
24986
|
} else {
|
|
@@ -24809,9 +24990,9 @@ var JsonDefinitionGenerator = class _JsonDefinitionGenerator {
|
|
|
24809
24990
|
};
|
|
24810
24991
|
|
|
24811
24992
|
// ../typedoc-theme/src/theme.ts
|
|
24812
|
-
import { copyFileSync, existsSync as
|
|
24813
|
-
import { dirname as
|
|
24814
|
-
import { fileURLToPath as
|
|
24993
|
+
import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
24994
|
+
import { dirname as dirname9, join as join15 } from "node:path";
|
|
24995
|
+
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
24815
24996
|
import { DefaultTheme, RendererEvent } from "typedoc";
|
|
24816
24997
|
|
|
24817
24998
|
// ../typedoc-theme/src/context.ts
|
|
@@ -25084,8 +25265,8 @@ import { JSX as JSX3 } from "typedoc";
|
|
|
25084
25265
|
|
|
25085
25266
|
// ../typedoc-theme/src/search-splitter.ts
|
|
25086
25267
|
var import_lunr = __toESM(require_lunr(), 1);
|
|
25087
|
-
import { readFileSync as
|
|
25088
|
-
import { join as
|
|
25268
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
25269
|
+
import { join as join13 } from "node:path";
|
|
25089
25270
|
import { deflateSync, inflateSync } from "node:zlib";
|
|
25090
25271
|
var KIND_MODULE = 2;
|
|
25091
25272
|
function sanitizeModuleName(name) {
|
|
@@ -25102,20 +25283,20 @@ function getModuleName(row, moduleNames) {
|
|
|
25102
25283
|
return void 0;
|
|
25103
25284
|
}
|
|
25104
25285
|
function buildChunk(rows) {
|
|
25105
|
-
const
|
|
25106
|
-
|
|
25107
|
-
|
|
25108
|
-
|
|
25286
|
+
const builder8 = new import_lunr.default.Builder();
|
|
25287
|
+
builder8.pipeline.add(import_lunr.default.trimmer);
|
|
25288
|
+
builder8.ref("id");
|
|
25289
|
+
builder8.field("name", { boost: 10 });
|
|
25109
25290
|
for (let i = 0; i < rows.length; i++) {
|
|
25110
|
-
|
|
25291
|
+
builder8.add({ id: i, name: rows[i].name });
|
|
25111
25292
|
}
|
|
25112
|
-
const index =
|
|
25293
|
+
const index = builder8.build();
|
|
25113
25294
|
const data = { rows, index };
|
|
25114
25295
|
const compressed = deflateSync(Buffer.from(JSON.stringify(data)));
|
|
25115
25296
|
return compressed.toString("base64");
|
|
25116
25297
|
}
|
|
25117
25298
|
function readSearchData(assetsDir) {
|
|
25118
|
-
const raw =
|
|
25299
|
+
const raw = readFileSync6(join13(assetsDir, "search.js"), "utf-8");
|
|
25119
25300
|
const match = raw.match(/window\.searchData\s*=\s*"([^"]+)"/);
|
|
25120
25301
|
if (!match?.[1]) {
|
|
25121
25302
|
throw new Error("Could not extract searchData from search.js");
|
|
@@ -25125,7 +25306,7 @@ function readSearchData(assetsDir) {
|
|
|
25125
25306
|
return JSON.parse(decompressed.toString("utf-8"));
|
|
25126
25307
|
}
|
|
25127
25308
|
async function splitSearchIndex(outputDir) {
|
|
25128
|
-
const assetsDir =
|
|
25309
|
+
const assetsDir = join13(outputDir, "assets");
|
|
25129
25310
|
let searchData;
|
|
25130
25311
|
try {
|
|
25131
25312
|
searchData = readSearchData(assetsDir);
|
|
@@ -25157,11 +25338,11 @@ async function splitSearchIndex(outputDir) {
|
|
|
25157
25338
|
for (const [moduleName, moduleRows] of moduleMap) {
|
|
25158
25339
|
const chunk = buildChunk(moduleRows);
|
|
25159
25340
|
const filename = `search-${sanitizeModuleName(moduleName)}.js`;
|
|
25160
|
-
|
|
25341
|
+
writeFileSync3(join13(assetsDir, filename), `window.searchData = "${chunk}";`);
|
|
25161
25342
|
}
|
|
25162
25343
|
const modulesChunk = buildChunk(moduleEntries);
|
|
25163
|
-
|
|
25164
|
-
|
|
25344
|
+
writeFileSync3(join13(assetsDir, "search-modules.js"), `window.searchData = "${modulesChunk}";`);
|
|
25345
|
+
writeFileSync3(join13(assetsDir, "search.js"), "window.searchData = null;");
|
|
25165
25346
|
const totalChunks = moduleMap.size + 1;
|
|
25166
25347
|
console.log(`[search-splitter] Split ${rows.length} entries into ${totalChunks} chunks (${moduleMap.size} modules)`);
|
|
25167
25348
|
}
|
|
@@ -25566,7 +25747,7 @@ function giDocgenModuleMemberSummary(context, member) {
|
|
|
25566
25747
|
}
|
|
25567
25748
|
const nsMeta = member.girNamespaceMetadata;
|
|
25568
25749
|
const commentSummary = context.commentShortSummary(member);
|
|
25569
|
-
const
|
|
25750
|
+
const description8 = commentSummary || (nsMeta?.description ? JSX4.createElement("p", null, nsMeta.description) : null);
|
|
25570
25751
|
return JSX4.createElement(
|
|
25571
25752
|
JSX4.Fragment,
|
|
25572
25753
|
null,
|
|
@@ -25578,7 +25759,7 @@ function giDocgenModuleMemberSummary(context, member) {
|
|
|
25578
25759
|
JSX4.createElement(
|
|
25579
25760
|
"dd",
|
|
25580
25761
|
{ class: classNames({ "tsd-member-summary": true }, context.getReflectionClasses(member)) },
|
|
25581
|
-
|
|
25762
|
+
description8
|
|
25582
25763
|
)
|
|
25583
25764
|
);
|
|
25584
25765
|
}
|
|
@@ -25687,16 +25868,16 @@ import { JSX as JSX7 } from "typedoc";
|
|
|
25687
25868
|
var giDocgenPageSidebar = (context, props) => JSX7.createElement(JSX7.Fragment, null, context.pageNavigation(props));
|
|
25688
25869
|
|
|
25689
25870
|
// ../typedoc-theme/src/partials/sidebar.ts
|
|
25690
|
-
import { readFileSync as
|
|
25691
|
-
import { dirname as
|
|
25692
|
-
import { fileURLToPath as
|
|
25871
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
25872
|
+
import { dirname as dirname8, join as join14 } from "node:path";
|
|
25873
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
25693
25874
|
import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind4 } from "typedoc";
|
|
25694
25875
|
function getTsForGirVersion() {
|
|
25695
25876
|
if (true) {
|
|
25696
|
-
return "4.0.0-rc.
|
|
25877
|
+
return "4.0.0-rc.4";
|
|
25697
25878
|
}
|
|
25698
|
-
const __dirname3 =
|
|
25699
|
-
return JSON.parse(
|
|
25879
|
+
const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
|
|
25880
|
+
return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
|
|
25700
25881
|
}
|
|
25701
25882
|
var TSFOR_GIR_VERSION = getTsForGirVersion();
|
|
25702
25883
|
function giDocgenModuleInfo(context, mod, nsMeta) {
|
|
@@ -26129,7 +26310,7 @@ var GiDocgenThemeRenderContext = class extends DefaultThemeRenderContext {
|
|
|
26129
26310
|
};
|
|
26130
26311
|
|
|
26131
26312
|
// ../typedoc-theme/src/theme.ts
|
|
26132
|
-
var __dirname2 =
|
|
26313
|
+
var __dirname2 = dirname9(fileURLToPath6(import.meta.url));
|
|
26133
26314
|
var FAVICON_FILES = [
|
|
26134
26315
|
"favicon.ico",
|
|
26135
26316
|
"favicon-96x96.png",
|
|
@@ -26152,21 +26333,21 @@ var GiDocgenTheme = class extends DefaultTheme {
|
|
|
26152
26333
|
constructor(renderer) {
|
|
26153
26334
|
super(renderer);
|
|
26154
26335
|
this.owner.on(RendererEvent.END, (event) => {
|
|
26155
|
-
const assetsDir =
|
|
26156
|
-
copyFileSync(
|
|
26157
|
-
copyFileSync(
|
|
26158
|
-
copyFileSync(
|
|
26159
|
-
const faviconDir =
|
|
26336
|
+
const assetsDir = join15(event.outputDirectory, "assets");
|
|
26337
|
+
copyFileSync(join15(__dirname2, "static", "style.css"), join15(assetsDir, "gi-docgen.css"));
|
|
26338
|
+
copyFileSync(join15(__dirname2, "static", "gi-docgen-inherited.js"), join15(assetsDir, "gi-docgen-inherited.js"));
|
|
26339
|
+
copyFileSync(join15(__dirname2, "static", "logo_x4.png"), join15(assetsDir, "logo_x4.png"));
|
|
26340
|
+
const faviconDir = join15(__dirname2, "static", "favicon");
|
|
26160
26341
|
for (const file of FAVICON_FILES) {
|
|
26161
|
-
copyFileSync(
|
|
26342
|
+
copyFileSync(join15(faviconDir, file), join15(assetsDir, file));
|
|
26162
26343
|
}
|
|
26163
|
-
const iconsSourceDir =
|
|
26164
|
-
const iconsOutputDir =
|
|
26165
|
-
if (
|
|
26166
|
-
|
|
26167
|
-
for (const file of
|
|
26344
|
+
const iconsSourceDir = join15(__dirname2, "..", "..", "..", "refs", "library-icons", "library-icons");
|
|
26345
|
+
const iconsOutputDir = join15(assetsDir, "library-icons");
|
|
26346
|
+
if (existsSync4(iconsSourceDir)) {
|
|
26347
|
+
mkdirSync2(iconsOutputDir, { recursive: true });
|
|
26348
|
+
for (const file of readdirSync2(iconsSourceDir)) {
|
|
26168
26349
|
if (file.endsWith("-r.svg")) {
|
|
26169
|
-
copyFileSync(
|
|
26350
|
+
copyFileSync(join15(iconsSourceDir, file), join15(iconsOutputDir, file));
|
|
26170
26351
|
}
|
|
26171
26352
|
}
|
|
26172
26353
|
}
|
|
@@ -26182,7 +26363,7 @@ var GiDocgenTheme = class extends DefaultTheme {
|
|
|
26182
26363
|
background_color: "#1e1e1e",
|
|
26183
26364
|
display: "standalone"
|
|
26184
26365
|
};
|
|
26185
|
-
|
|
26366
|
+
writeFileSync4(join15(assetsDir, "site.webmanifest"), JSON.stringify(manifest, null, 2));
|
|
26186
26367
|
});
|
|
26187
26368
|
}
|
|
26188
26369
|
getNavigation(project) {
|
|
@@ -26236,7 +26417,7 @@ var HtmlDocGenerator = class _HtmlDocGenerator {
|
|
|
26236
26417
|
} else {
|
|
26237
26418
|
for (const module of this.pipeline.modules) {
|
|
26238
26419
|
const result = await this.pipeline.createTypeDocApp(module);
|
|
26239
|
-
await this.generateDocsWithTheme(result,
|
|
26420
|
+
await this.generateDocsWithTheme(result, join16(outdir, module.packageName));
|
|
26240
26421
|
}
|
|
26241
26422
|
}
|
|
26242
26423
|
this.log.success(`HTML documentation generated for ${this.pipeline.modules.length} modules in ${outdir}`);
|
|
@@ -26281,9 +26462,9 @@ var HtmlDocGenerator = class _HtmlDocGenerator {
|
|
|
26281
26462
|
import prettier from "prettier";
|
|
26282
26463
|
var logger4 = new Logger(false, "TypeScriptFormatter");
|
|
26283
26464
|
var TypeScriptFormatter = class extends Formatter {
|
|
26284
|
-
format(
|
|
26465
|
+
format(input2) {
|
|
26285
26466
|
try {
|
|
26286
|
-
return prettier.format(
|
|
26467
|
+
return prettier.format(input2, {
|
|
26287
26468
|
singleQuote: true,
|
|
26288
26469
|
parser: "typescript",
|
|
26289
26470
|
printWidth: 120,
|
|
@@ -26291,7 +26472,7 @@ var TypeScriptFormatter = class extends Formatter {
|
|
|
26291
26472
|
});
|
|
26292
26473
|
} catch (error) {
|
|
26293
26474
|
logger4.warn("Failed to format with prettier, returning original input", error);
|
|
26294
|
-
return Promise.resolve(
|
|
26475
|
+
return Promise.resolve(input2);
|
|
26295
26476
|
}
|
|
26296
26477
|
}
|
|
26297
26478
|
};
|
|
@@ -26420,9 +26601,9 @@ async function runGenerationCommand(args, options2) {
|
|
|
26420
26601
|
}
|
|
26421
26602
|
|
|
26422
26603
|
// src/commands/doc.ts
|
|
26423
|
-
var
|
|
26424
|
-
var
|
|
26425
|
-
var
|
|
26604
|
+
var command4 = "doc [modules..]";
|
|
26605
|
+
var description4 = "Generates HTML documentation from GIR files using TypeDoc";
|
|
26606
|
+
var examples4 = [
|
|
26426
26607
|
[`${APP_NAME} doc Gtk-4.0 --outdir ./docs`, "Generate HTML documentation for Gtk-4.0"],
|
|
26427
26608
|
[`${APP_NAME} doc '*' --outdir ./docs`, "Generate documentation for all locally installed GIR modules"],
|
|
26428
26609
|
[
|
|
@@ -26430,8 +26611,8 @@ var examples3 = [
|
|
|
26430
26611
|
"Generate HTML from pre-generated JSON files (low memory)"
|
|
26431
26612
|
]
|
|
26432
26613
|
];
|
|
26433
|
-
var
|
|
26434
|
-
var
|
|
26614
|
+
var builder4 = createBuilder(docOptions, examples4);
|
|
26615
|
+
var handler4 = async (args) => {
|
|
26435
26616
|
const config = getOptionsGeneration(await load(args));
|
|
26436
26617
|
if (config.merge) {
|
|
26437
26618
|
if (!config.jsonDir) {
|
|
@@ -26450,17 +26631,17 @@ var handler3 = async (args) => {
|
|
|
26450
26631
|
});
|
|
26451
26632
|
};
|
|
26452
26633
|
var doc = {
|
|
26453
|
-
command:
|
|
26454
|
-
description:
|
|
26455
|
-
builder:
|
|
26456
|
-
handler:
|
|
26457
|
-
examples:
|
|
26634
|
+
command: command4,
|
|
26635
|
+
description: description4,
|
|
26636
|
+
builder: builder4,
|
|
26637
|
+
handler: handler4,
|
|
26638
|
+
examples: examples4
|
|
26458
26639
|
};
|
|
26459
26640
|
|
|
26460
26641
|
// src/commands/generate.ts
|
|
26461
|
-
var
|
|
26462
|
-
var
|
|
26463
|
-
var
|
|
26642
|
+
var command5 = "generate [modules..]";
|
|
26643
|
+
var description5 = "Generates Typescript type definition .d.ts files from GIR for GJS";
|
|
26644
|
+
var examples5 = [
|
|
26464
26645
|
[
|
|
26465
26646
|
`${APP_NAME} generate`,
|
|
26466
26647
|
`Run '${APP_NAME} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`
|
|
@@ -26470,8 +26651,8 @@ var examples4 = [
|
|
|
26470
26651
|
[`${APP_NAME} generate --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
26471
26652
|
[`${APP_NAME} generate --ignore=Gtk-4.0 xrandr-1.3`, "Generate .d.ts. files but not for Gtk-4.0 and xrandr-1.3"]
|
|
26472
26653
|
];
|
|
26473
|
-
var
|
|
26474
|
-
var
|
|
26654
|
+
var builder5 = createBuilder(generateOptions, examples5);
|
|
26655
|
+
var handler5 = async (args) => {
|
|
26475
26656
|
await runGenerationCommand(args, {
|
|
26476
26657
|
generatorType: 0 /* TYPES */,
|
|
26477
26658
|
loggerName: "GenerateCommand",
|
|
@@ -26481,25 +26662,25 @@ var handler4 = async (args) => {
|
|
|
26481
26662
|
});
|
|
26482
26663
|
};
|
|
26483
26664
|
var generate = {
|
|
26484
|
-
command:
|
|
26485
|
-
description:
|
|
26486
|
-
builder:
|
|
26487
|
-
handler:
|
|
26488
|
-
examples:
|
|
26665
|
+
command: command5,
|
|
26666
|
+
description: description5,
|
|
26667
|
+
builder: builder5,
|
|
26668
|
+
handler: handler5,
|
|
26669
|
+
examples: examples5
|
|
26489
26670
|
};
|
|
26490
26671
|
|
|
26491
26672
|
// src/commands/json.ts
|
|
26492
|
-
var
|
|
26493
|
-
var
|
|
26494
|
-
var
|
|
26673
|
+
var command6 = "json [modules..]";
|
|
26674
|
+
var description6 = "Generates JSON representation from GIR files for analysis and tooling";
|
|
26675
|
+
var examples6 = [
|
|
26495
26676
|
[`${APP_NAME} json`, `Run '${APP_NAME} json' in your gjs project to generate JSON files for your project`],
|
|
26496
26677
|
[`${APP_NAME} json 'Gtk*'`, "You can also use wild cards"],
|
|
26497
26678
|
[`${APP_NAME} json '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
26498
26679
|
[`${APP_NAME} json --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
26499
26680
|
[`${APP_NAME} json --ignore=Gtk-4.0 xrandr-1.3`, "Generate JSON files but not for Gtk-4.0 and xrandr-1.3"]
|
|
26500
26681
|
];
|
|
26501
|
-
var
|
|
26502
|
-
var
|
|
26682
|
+
var builder6 = createBuilder(generateOptions, examples6);
|
|
26683
|
+
var handler6 = async (args) => {
|
|
26503
26684
|
await runGenerationCommand(args, {
|
|
26504
26685
|
generatorType: 2 /* JSON */,
|
|
26505
26686
|
loggerName: "JsonCommand",
|
|
@@ -26509,26 +26690,26 @@ var handler5 = async (args) => {
|
|
|
26509
26690
|
});
|
|
26510
26691
|
};
|
|
26511
26692
|
var json2 = {
|
|
26512
|
-
command:
|
|
26513
|
-
description:
|
|
26514
|
-
builder:
|
|
26515
|
-
handler:
|
|
26516
|
-
examples:
|
|
26693
|
+
command: command6,
|
|
26694
|
+
description: description6,
|
|
26695
|
+
builder: builder6,
|
|
26696
|
+
handler: handler6,
|
|
26697
|
+
examples: examples6
|
|
26517
26698
|
};
|
|
26518
26699
|
|
|
26519
26700
|
// src/commands/list.ts
|
|
26520
|
-
var
|
|
26521
|
-
var
|
|
26701
|
+
var command7 = "list [modules..]";
|
|
26702
|
+
var description7 = "Lists all available GIR modules";
|
|
26522
26703
|
var logger5 = new Logger(true, "ListCommand");
|
|
26523
|
-
var
|
|
26704
|
+
var examples7 = [
|
|
26524
26705
|
[`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
|
|
26525
26706
|
[
|
|
26526
26707
|
`${APP_NAME} list --ignore=Gtk-3.0 xrandr-1.3`,
|
|
26527
26708
|
"Lists all available GIR modules in /usr/share/gir-1.0 but not Gtk-3.0 and xrandr-1.3"
|
|
26528
26709
|
]
|
|
26529
26710
|
];
|
|
26530
|
-
var
|
|
26531
|
-
var
|
|
26711
|
+
var builder7 = createBuilder(listOptions, examples7);
|
|
26712
|
+
var handler7 = async (args) => {
|
|
26532
26713
|
const config = await load(args);
|
|
26533
26714
|
const generateConfig = getOptionsGeneration(config);
|
|
26534
26715
|
const registry = new NSRegistry();
|
|
@@ -26569,15 +26750,15 @@ var handler6 = async (args) => {
|
|
|
26569
26750
|
}
|
|
26570
26751
|
};
|
|
26571
26752
|
var list = {
|
|
26572
|
-
command:
|
|
26573
|
-
description:
|
|
26574
|
-
builder:
|
|
26575
|
-
handler:
|
|
26576
|
-
examples:
|
|
26753
|
+
command: command7,
|
|
26754
|
+
description: description7,
|
|
26755
|
+
builder: builder7,
|
|
26756
|
+
handler: handler7,
|
|
26757
|
+
examples: examples7
|
|
26577
26758
|
};
|
|
26578
26759
|
|
|
26579
26760
|
// src/start.ts
|
|
26580
|
-
void yargs(hideBin(process.argv)).scriptName(APP_NAME).strict().usage(APP_USAGE).version(APP_VERSION).command(analyze).command(generate).command(json2).command(list).command(copy).command(doc).demandCommand(1).help().argv;
|
|
26761
|
+
void yargs(hideBin(process.argv)).scriptName(APP_NAME).strict().usage(APP_USAGE).version(APP_VERSION).command(analyze).command(create).command(generate).command(json2).command(list).command(copy).command(doc).demandCommand(1).help().argv;
|
|
26581
26762
|
/*! Bundled license information:
|
|
26582
26763
|
|
|
26583
26764
|
lodash/lodash.js:
|