@openpkg-ts/extract 0.23.0 → 0.23.1

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/bin/tspec.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  extract
4
- } from "../shared/chunk-y5d5qgyt.js";
4
+ } from "../shared/chunk-qwkv7jxy.js";
5
5
 
6
6
  // src/cli/spec.ts
7
7
  import * as fs from "node:fs";
@@ -2768,7 +2768,8 @@ async function extract(options) {
2768
2768
  }
2769
2769
  const meta = await getPackageMeta(entryFile, baseDir);
2770
2770
  const types = ctx.typeRegistry.getAll();
2771
- const forgottenExports = collectForgottenExports(exports, types, program, sourceFile, exportedIds);
2771
+ const projectBaseDir = baseDir ?? path3.dirname(entryFile);
2772
+ const forgottenExports = collectForgottenExports(exports, types, program, sourceFile, exportedIds, projectBaseDir);
2772
2773
  for (const forgotten of forgottenExports) {
2773
2774
  const refSummary = forgotten.referencedBy.slice(0, 3).map((r) => `${r.exportName} (${r.location})`).join(", ");
2774
2775
  const moreRefs = forgotten.referencedBy.length > 3 ? ` +${forgotten.referencedBy.length - 3} more` : "";
@@ -2799,8 +2800,8 @@ async function extract(options) {
2799
2800
  }
2800
2801
  let runtimeMetadata;
2801
2802
  if (options.schemaExtraction === "hybrid") {
2802
- const projectBaseDir = baseDir || path3.dirname(entryFile);
2803
- const runtimeResult = await extractStandardSchemasFromProject(entryFile, projectBaseDir, {
2803
+ const projectBaseDir2 = baseDir || path3.dirname(entryFile);
2804
+ const runtimeResult = await extractStandardSchemasFromProject(entryFile, projectBaseDir2, {
2804
2805
  target: options.schemaTarget || "draft-2020-12",
2805
2806
  timeout: 15000
2806
2807
  });
@@ -2916,10 +2917,14 @@ function findTypeDefinition(typeName, program, sourceFile) {
2916
2917
  }
2917
2918
  return;
2918
2919
  }
2919
- function isExternalType2(definedIn) {
2920
+ function isExternalType2(definedIn, baseDir) {
2920
2921
  if (!definedIn)
2921
2922
  return true;
2922
- return definedIn.includes("node_modules");
2923
+ if (definedIn.includes("node_modules"))
2924
+ return true;
2925
+ const normalizedDefined = path3.resolve(definedIn);
2926
+ const normalizedBase = path3.resolve(baseDir);
2927
+ return !normalizedDefined.startsWith(normalizedBase);
2923
2928
  }
2924
2929
  function hasInternalTag(typeName, program, sourceFile) {
2925
2930
  const checker = program.getTypeChecker();
@@ -2929,7 +2934,7 @@ function hasInternalTag(typeName, program, sourceFile) {
2929
2934
  const jsTags = symbol.getJsDocTags();
2930
2935
  return jsTags.some((tag) => tag.name === "internal");
2931
2936
  }
2932
- function collectForgottenExports(exports, types, program, sourceFile, exportedIds) {
2937
+ function collectForgottenExports(exports, types, program, sourceFile, exportedIds, baseDir) {
2933
2938
  const definedTypes = new Set(types.map((t) => t.id));
2934
2939
  const referencedTypes = new Map;
2935
2940
  for (const exp of exports) {
@@ -2959,7 +2964,7 @@ function collectForgottenExports(exports, types, program, sourceFile, exportedId
2959
2964
  if (exportedIds.has(typeName))
2960
2965
  continue;
2961
2966
  const definedIn = findTypeDefinition(typeName, program, sourceFile);
2962
- const isExternal = isExternalType2(definedIn);
2967
+ const isExternal = isExternalType2(definedIn, baseDir);
2963
2968
  forgottenExports.push({
2964
2969
  name: typeName,
2965
2970
  definedIn,
package/dist/src/index.js CHANGED
@@ -46,7 +46,7 @@ import {
46
46
  valibotAdapter,
47
47
  withDescription,
48
48
  zodAdapter
49
- } from "../shared/chunk-y5d5qgyt.js";
49
+ } from "../shared/chunk-qwkv7jxy.js";
50
50
  // src/types/utils.ts
51
51
  function isExported(node) {
52
52
  const modifiers = node.modifiers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/extract",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "description": "TypeScript export extraction to OpenPkg spec",
5
5
  "keywords": [
6
6
  "openpkg",