@openpkg-ts/sdk 0.47.2 → 0.48.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/dist/index.d.ts +10 -0
- package/dist/index.js +20 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,16 @@ interface ExportVerification {
|
|
|
156
156
|
interface OpenpkgConfig {
|
|
157
157
|
/** Configuration for resolving external package re-exports */
|
|
158
158
|
externals?: ExternalsConfig;
|
|
159
|
+
/**
|
|
160
|
+
* Expand referenced types from third-party packages instead of recording
|
|
161
|
+
* them as opaque stubs. `true` follows every dependency; a string[] follows
|
|
162
|
+
* only the named packages (by declaring package name). Default: stub.
|
|
163
|
+
*/
|
|
164
|
+
followExternal?: boolean | string[];
|
|
165
|
+
/** Only extract these exports (supports * wildcards). */
|
|
166
|
+
only?: string[];
|
|
167
|
+
/** Ignore these exports (supports * wildcards). */
|
|
168
|
+
ignore?: string[];
|
|
159
169
|
}
|
|
160
170
|
/** Default config filename */
|
|
161
171
|
declare const CONFIG_FILENAME = "openpkg.config.json";
|
package/dist/index.js
CHANGED
|
@@ -79,7 +79,12 @@ function mergeConfig(fileConfig, cliOptions) {
|
|
|
79
79
|
depth: cliOptions.externals?.depth ?? fileConfig.externals?.depth
|
|
80
80
|
};
|
|
81
81
|
const hasExternals = externals.include || externals.exclude || externals.depth !== undefined;
|
|
82
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
...hasExternals ? { externals } : {},
|
|
84
|
+
followExternal: cliOptions.followExternal ?? fileConfig.followExternal,
|
|
85
|
+
only: cliOptions.only ?? fileConfig.only,
|
|
86
|
+
ignore: cliOptions.ignore ?? fileConfig.ignore
|
|
87
|
+
};
|
|
83
88
|
}
|
|
84
89
|
// src/core/loader.ts
|
|
85
90
|
import * as fs2 from "node:fs";
|
|
@@ -3090,12 +3095,18 @@ class TypeRegistry {
|
|
|
3090
3095
|
if (this.has(name))
|
|
3091
3096
|
return name;
|
|
3092
3097
|
if (ctx.shouldExpandExternal && !ctx.shouldExpandExternal(symbol)) {
|
|
3098
|
+
const origin = getTypeOrigin(type, ctx.typeChecker);
|
|
3099
|
+
const schema = {
|
|
3100
|
+
"x-ts-type": renderTypeText(type, ctx.typeChecker)
|
|
3101
|
+
};
|
|
3102
|
+
if (origin)
|
|
3103
|
+
schema["x-ts-package"] = origin;
|
|
3093
3104
|
this.add({
|
|
3094
3105
|
id: name,
|
|
3095
3106
|
name,
|
|
3096
3107
|
kind: "external",
|
|
3097
3108
|
external: true,
|
|
3098
|
-
schema
|
|
3109
|
+
schema
|
|
3099
3110
|
});
|
|
3100
3111
|
return name;
|
|
3101
3112
|
}
|
|
@@ -6223,12 +6234,18 @@ function isLibFile(fileName) {
|
|
|
6223
6234
|
return fileName.includes("/typescript/lib/lib.") || fileName.includes("\\typescript\\lib\\lib.");
|
|
6224
6235
|
}
|
|
6225
6236
|
function createExternalExpansionPredicate(opts) {
|
|
6237
|
+
const matchesEntry = (entry, pkg) => {
|
|
6238
|
+
if (!entry.includes("*"))
|
|
6239
|
+
return entry === pkg;
|
|
6240
|
+
const rx = new RegExp(`^${entry.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`);
|
|
6241
|
+
return rx.test(pkg);
|
|
6242
|
+
};
|
|
6226
6243
|
const packageAllowed = (pkg) => {
|
|
6227
6244
|
if (pkg === "typescript")
|
|
6228
6245
|
return false;
|
|
6229
6246
|
if (opts.followExternal === true)
|
|
6230
6247
|
return true;
|
|
6231
|
-
if (Array.isArray(opts.followExternal) && opts.followExternal.
|
|
6248
|
+
if (Array.isArray(opts.followExternal) && opts.followExternal.some((e) => matchesEntry(e, pkg)))
|
|
6232
6249
|
return true;
|
|
6233
6250
|
return opts.workspacePackages.has(pkg);
|
|
6234
6251
|
};
|