@nhtio/vite-plugins 0.1.0-master-78c49aee → 0.1.0-master-830ce62d
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/dts_complex.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { fileURLToPath } from "node:url";
|
|
|
10
10
|
import require$$0$1 from "path";
|
|
11
11
|
import require$$0 from "constants";
|
|
12
12
|
import { ExtractorConfig, Extractor } from "@microsoft/api-extractor";
|
|
13
|
-
import { readFile,
|
|
13
|
+
import { readFile, readdir, mkdtemp, symlink, unlink, rm, mkdir, writeFile as writeFile$1 } from "node:fs/promises";
|
|
14
14
|
const ANSI_BACKGROUND_OFFSET = 10;
|
|
15
15
|
const wrapAnsi16 = (offset3 = 0) => (code2) => `\x1B[${code2 + offset3}m`;
|
|
16
16
|
const wrapAnsi256 = (offset3 = 0) => (code2) => `\x1B[${38 + offset3};5;${code2}m`;
|
|
@@ -335474,6 +335474,10 @@ init_esm$1();
|
|
|
335474
335474
|
__toESM$1(require_lib$8());
|
|
335475
335475
|
var import_lib$1 = __toESM$1(require_lib$7());
|
|
335476
335476
|
import_lib$1.location;
|
|
335477
|
+
const writeFile = async (filePath, data2, encoding) => {
|
|
335478
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
335479
|
+
await writeFile$1(filePath, data2, encoding);
|
|
335480
|
+
};
|
|
335477
335481
|
const defaultOptions = {
|
|
335478
335482
|
packageJsonPath: "./package.json",
|
|
335479
335483
|
tsConfigJsonPath: "./tsconfig.json",
|
|
@@ -336079,34 +336083,52 @@ const unpluginFactory = (options2) => {
|
|
|
336079
336083
|
return result;
|
|
336080
336084
|
}
|
|
336081
336085
|
if (targetFile.startsWith(runtimeConfiguration.root)) {
|
|
336082
|
-
const
|
|
336086
|
+
const relativeToRoot = relative(runtimeConfiguration.root, targetFile).replace(
|
|
336083
336087
|
/\.(ts|tsx|cts|mts)$/,
|
|
336084
336088
|
".d.ts"
|
|
336085
336089
|
);
|
|
336086
|
-
const
|
|
336087
|
-
|
|
336088
|
-
|
|
336090
|
+
const potentialPaths = [
|
|
336091
|
+
// Direct relative to project root
|
|
336092
|
+
join(runtimeConfiguration.tempDirPath, relativeToRoot),
|
|
336093
|
+
// Without first directory (e.g., src/)
|
|
336094
|
+
join(runtimeConfiguration.tempDirPath, relativeToRoot.replace(/^[^/]+\//, ""))
|
|
336095
|
+
];
|
|
336096
|
+
const matchingFiles = Array.from(tmpDirRootNames).filter(
|
|
336097
|
+
(emittedPath) => emittedPath.endsWith(relativeToRoot)
|
|
336089
336098
|
);
|
|
336090
336099
|
if (runtimeConfiguration.debug) {
|
|
336091
|
-
console.log("[dts_complex]
|
|
336092
|
-
console.log("[dts_complex]
|
|
336093
|
-
console.log(
|
|
336094
|
-
"[dts_complex] exists in tmpDirRootNames:",
|
|
336095
|
-
tmpDirRootNames.has(possibleEmittedPath)
|
|
336096
|
-
);
|
|
336100
|
+
console.log("[dts_complex] relativeToRoot:", relativeToRoot);
|
|
336101
|
+
console.log("[dts_complex] potentialPaths:", potentialPaths);
|
|
336102
|
+
console.log("[dts_complex] matchingFiles:", matchingFiles);
|
|
336097
336103
|
}
|
|
336098
|
-
|
|
336099
|
-
|
|
336104
|
+
for (const possiblePath of potentialPaths) {
|
|
336105
|
+
if (tmpDirRootNames.has(possiblePath)) {
|
|
336106
|
+
const relativeSpec = computeRelativePath(possiblePath);
|
|
336107
|
+
if (relativeSpec !== moduleName) {
|
|
336108
|
+
if (runtimeConfiguration.debug) {
|
|
336109
|
+
console.log("[dts_complex] -> Using emitted (exact):", relativeSpec);
|
|
336110
|
+
}
|
|
336111
|
+
return relativeSpec;
|
|
336112
|
+
}
|
|
336113
|
+
}
|
|
336114
|
+
}
|
|
336115
|
+
if (matchingFiles.length === 1) {
|
|
336116
|
+
const relativeSpec = computeRelativePath(matchingFiles[0]);
|
|
336100
336117
|
if (relativeSpec !== moduleName) {
|
|
336101
336118
|
if (runtimeConfiguration.debug) {
|
|
336102
|
-
console.log("[dts_complex] -> Using emitted:", relativeSpec);
|
|
336119
|
+
console.log("[dts_complex] -> Using emitted (suffix):", relativeSpec);
|
|
336103
336120
|
}
|
|
336104
336121
|
return relativeSpec;
|
|
336105
336122
|
}
|
|
336106
|
-
}
|
|
336123
|
+
}
|
|
336124
|
+
if (runtimeConfiguration.debug) {
|
|
336107
336125
|
console.log("[dts_complex] -> Emitted file not found in tmpDirRootNames");
|
|
336108
336126
|
}
|
|
336109
336127
|
}
|
|
336128
|
+
} else if (runtimeConfiguration.debug) {
|
|
336129
|
+
console.log("[dts_complex] Resolving:", moduleName);
|
|
336130
|
+
console.log("[dts_complex] From file:", sourceFile.fileName);
|
|
336131
|
+
console.log("[dts_complex] -> Symbol not found, keeping as-is");
|
|
336110
336132
|
}
|
|
336111
336133
|
return void 0;
|
|
336112
336134
|
};
|
|
@@ -336163,12 +336185,15 @@ const unpluginFactory = (options2) => {
|
|
|
336163
336185
|
};
|
|
336164
336186
|
try {
|
|
336165
336187
|
await pMap(
|
|
336166
|
-
|
|
336167
|
-
async (
|
|
336168
|
-
if (!dirent.isFile() || !dirent.name.endsWith(".d.ts")) return;
|
|
336169
|
-
const absolutePath = join(dirent.parentPath, dirent.name);
|
|
336188
|
+
Array.from(tmpDirRootNames),
|
|
336189
|
+
async (absolutePath) => {
|
|
336170
336190
|
const sourceFile = tmpDirProgram.getSourceFile(absolutePath);
|
|
336171
|
-
if (!sourceFile)
|
|
336191
|
+
if (!sourceFile) {
|
|
336192
|
+
if (runtimeConfiguration.debug) {
|
|
336193
|
+
console.log("[dts_complex] Skipping file not in program:", absolutePath);
|
|
336194
|
+
}
|
|
336195
|
+
return;
|
|
336196
|
+
}
|
|
336172
336197
|
const transformResult = ts.transform(sourceFile, [tmpDirTransformer]);
|
|
336173
336198
|
const printer = ts.createPrinter();
|
|
336174
336199
|
const newContent = printer.printFile(transformResult.transformed[0]);
|
|
@@ -336234,4 +336259,4 @@ const dtsComplex = /* @__PURE__ */ createVitePlugin(unpluginFactory);
|
|
|
336234
336259
|
export {
|
|
336235
336260
|
dtsComplex as d
|
|
336236
336261
|
};
|
|
336237
|
-
//# sourceMappingURL=index-
|
|
336262
|
+
//# sourceMappingURL=index-C3j0_U_i.mjs.map
|