@davidwells/extract-deps 0.1.11 → 0.1.13

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.
@@ -2,7 +2,7 @@
2
2
  const { test } = require('uvu')
3
3
  const assert = require('uvu/assert')
4
4
  const path = require('path')
5
- const { depGraph, resolveDepPaths } = require('../src/dep-graph.js')
5
+ const { depGraph, resolveDepPaths, clearDepGraphCache } = require('../src/dep-graph.js')
6
6
 
7
7
  const CJS_FIXTURE_PATH = path.resolve(__dirname, './fixtures/cjs-example/index.js')
8
8
  const ESM_FIXTURE_PATH = path.resolve(__dirname, './fixtures/esm-fixture/index.js')
@@ -654,6 +654,7 @@ test('dynamic import should still build the dep edge', () => {
654
654
 
655
655
  // TypeScript patterns fixture — exercises all fixed false positive patterns
656
656
  const TS_PATTERNS_FIXTURE = path.resolve(__dirname, './fixtures/ts-patterns-fixture/index.ts')
657
+ const TS_REGEX_EXPORT_FIXTURE = path.resolve(__dirname, './fixtures/ts-regex-export-fixture/index.ts')
657
658
 
658
659
  test('TS patterns: import type, inline type, import * as, $-prefixed names should all pass', () => {
659
660
  // This fixture contains:
@@ -700,4 +701,58 @@ test('TS patterns: resolveDepPaths with returnErrors should have zero errors', (
700
701
  assert.is(result.errors.length, 0, 'Should have zero verification errors')
701
702
  })
702
703
 
704
+ test('TS regex exports: verifies named imports from .js specifier resolved to .ts file', () => {
705
+ assert.not.throws(() => {
706
+ depGraph(TS_REGEX_EXPORT_FIXTURE, { verifyGraph: true })
707
+ }, 'Regex literals in the target module should not hide later exports')
708
+ })
709
+
710
+ test('TS regex exports: should build dependency edge to resolved .ts module', () => {
711
+ const graph = depGraph(TS_REGEX_EXPORT_FIXTURE, { verifyGraph: true })
712
+
713
+ const indexPath = Array.from(graph.keys()).find(key => key.includes('ts-regex-export-fixture/index.ts'))
714
+ assert.ok(indexPath, 'Should have index.ts in graph')
715
+
716
+ const deps = graph.get(indexPath)
717
+ assert.ok(deps.some(d => d.includes('ts-regex-export-fixture/message-builder.ts')), 'Should depend on message-builder.ts')
718
+ })
719
+
720
+ test('TS regex exports: resolveDepPaths with returnErrors should have zero errors', () => {
721
+ const result = resolveDepPaths(TS_REGEX_EXPORT_FIXTURE, { returnErrors: true })
722
+
723
+ assert.ok(Array.isArray(result.errors), 'Should have errors array')
724
+ if (result.errors.length > 0) {
725
+ console.log('Unexpected errors:', result.errors.map(e => e.message))
726
+ }
727
+ assert.is(result.errors.length, 0, 'Should have zero verification errors')
728
+ })
729
+
730
+ test('memoized walks see edited files and new files after clearDepGraphCache', () => {
731
+ const fs = require('fs')
732
+ const os = require('os')
733
+ const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'dep-graph-memo-')))
734
+ const entry = path.join(dir, 'index.js')
735
+ fs.writeFileSync(entry, "const a = require('./a')\nmodule.exports = a")
736
+ fs.writeFileSync(path.join(dir, 'a.js'), 'module.exports = 1')
737
+ try {
738
+ assert.equal(resolveDepPaths(entry).files.map(f => path.basename(f)), ['a.js', 'index.js'])
739
+ // Edit: a new import. mtime moves, so the file is parsed again.
740
+ fs.writeFileSync(path.join(dir, 'b.js'), 'module.exports = 2')
741
+ fs.writeFileSync(entry, "const a = require('./a')\nconst b = require('./b')\nmodule.exports = a + b")
742
+ const later = new Date(Date.now() + 5000)
743
+ fs.utimesSync(entry, later, later)
744
+ assert.equal(resolveDepPaths(entry).files.map(f => path.basename(f)).sort(), ['a.js', 'b.js', 'index.js'])
745
+ // A missing import stays missing until the cache is cleared.
746
+ fs.writeFileSync(entry, "const c = require('./c')\nmodule.exports = c")
747
+ const later2 = new Date(Date.now() + 10000)
748
+ fs.utimesSync(entry, later2, later2)
749
+ assert.is(resolveDepPaths(entry, { returnErrors: true }).errors.length, 1)
750
+ fs.writeFileSync(path.join(dir, 'c.js'), 'module.exports = 3')
751
+ clearDepGraphCache()
752
+ assert.is(resolveDepPaths(entry, { returnErrors: true }).errors.length, 0)
753
+ } finally {
754
+ fs.rmSync(dir, { recursive: true, force: true })
755
+ }
756
+ })
757
+
703
758
  test.run()
@@ -0,0 +1,8 @@
1
+ import { buildRawMessage, DeliveryStatus, sanitizeEmailHtml } from './message-builder.js'
2
+
3
+ const clean = sanitizeEmailHtml('<a href="https://example.com">ok</a>')
4
+
5
+ export const result = buildRawMessage({
6
+ htmlBody: clean,
7
+ status: DeliveryStatus.Ready,
8
+ })
@@ -0,0 +1,23 @@
1
+ export enum DeliveryStatus {
2
+ Ready = 'ready',
3
+ }
4
+
5
+ function escapeHtmlAttribute(value: string): string {
6
+ return value.replace(/`/g, '&#96;')
7
+ }
8
+
9
+ export function sanitizeEmailHtml(html: string): string {
10
+ return html.replace(/<!--[\s\S]*?-->/g, '').replace(/<(script|style)\b[\s\S]*?<\/\1>/gi, '').replace(
11
+ /<\/?([a-z][a-z0-9]*)\b([^>]*)>/gi,
12
+ (tag, rawName: string, rawAttributes: string) => {
13
+ const hrefMatch = rawAttributes.match(/\shref\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))/i)
14
+ const href = hrefMatch?.[2] ?? hrefMatch?.[3] ?? hrefMatch?.[4] ?? ''
15
+ if (!/^https?:\/\//i.test(href)) return '<a>'
16
+ return `<a href="${escapeHtmlAttribute(href)}">`
17
+ },
18
+ )
19
+ }
20
+
21
+ export function buildRawMessage({ htmlBody, status }: { htmlBody: string; status: DeliveryStatus }): string {
22
+ return `${status}:${htmlBody}`
23
+ }
@@ -78,11 +78,13 @@ export var thirdVariable = 'value'
78
78
  export function myFunction() {}
79
79
  export class MyClass {}
80
80
  export async function asyncFunction() {}
81
+ export enum MyEnum {}
82
+ export const enum MyConstEnum {}
81
83
  `
82
84
 
83
85
  const foundExports = getNamedExports(code)
84
86
 
85
- assert.ok(foundExports.length === 6, 'Should find 6 named exports')
87
+ assert.ok(foundExports.length === 8, 'Should find 8 named exports')
86
88
 
87
89
  const exportNames = foundExports.map(exp => exp.exportName)
88
90
  assert.ok(exportNames.includes('myVariable'), 'Should find const export')
@@ -91,6 +93,8 @@ export async function asyncFunction() {}
91
93
  assert.ok(exportNames.includes('myFunction'), 'Should find function export')
92
94
  assert.ok(exportNames.includes('MyClass'), 'Should find class export')
93
95
  assert.ok(exportNames.includes('asyncFunction'), 'Should find async function export')
96
+ assert.ok(exportNames.includes('MyEnum'), 'Should find enum export')
97
+ assert.ok(exportNames.includes('MyConstEnum'), 'Should find const enum export')
94
98
 
95
99
  foundExports.forEach(exp => {
96
100
  assert.equal(exp.exportType, 'named')
@@ -615,4 +619,25 @@ const dq = "export { foo } from 'fake'"
615
619
  assert.equal(names, ['real'], 'Only the real export should be detected')
616
620
  })
617
621
 
618
- test.run()
622
+ test('finds exports after regex literals that contain //', () => {
623
+ const code = `
624
+ export function sanitizeEmailHtml(html: string): string {
625
+ return html.replace(/<!--[\\s\\S]*?-->/g, '')
626
+ .replace(/<(script|style)\\b[\\s\\S]*?<\\/\\1>/gi, '')
627
+ .replace(/<\\/?([a-z][a-z0-9]*)\\b([^>]*)>/gi, (tag, rawName: string) => {
628
+ if (!/^https?:\\/\\//i.test(tag)) return '<a>'
629
+ return '<a>'
630
+ })
631
+ }
632
+
633
+ export function buildRawMessage(input: { htmlBody: string }): string {
634
+ return input.htmlBody
635
+ }
636
+ `
637
+
638
+ const found = getExports(code)
639
+ const names = found.map(e => e.exportName).sort()
640
+ assert.equal(names, ['buildRawMessage', 'sanitizeEmailHtml'])
641
+ })
642
+
643
+ test.run()
@@ -199,4 +199,15 @@ test('should handle packages with no dependencies gracefully', async () => {
199
199
  }
200
200
  })
201
201
 
202
+ test('extractDeps - repeat calls on same code return equal, independent results', () => {
203
+ const code = `const path = require('path')\nimport foo from './foo'\nexport const bar = 1\n`
204
+ const first = extractDeps(code)
205
+ first.requires[0].from = 'mutated'
206
+ first.imports.length = 0
207
+ const second = extractDeps(code)
208
+ assert.is(second.requires[0].from, 'path')
209
+ assert.is(second.imports.length, 1)
210
+ assert.equal(extractDeps(code), second)
211
+ })
212
+
202
213
  test.run()
@@ -0,0 +1,101 @@
1
+ const { test } = require('uvu')
2
+ const assert = require('uvu/assert')
3
+ const { detectSyntax, extractDeps } = require('../src')
4
+
5
+ function exportNames(code) {
6
+ return extractDeps(code).exports.map(exp => exp.exportName).filter(Boolean).sort()
7
+ }
8
+
9
+ function cjsExportNames(code) {
10
+ return extractDeps(code).moduleExports.map(exp => exp.exportName).filter(Boolean).sort()
11
+ }
12
+
13
+ test('regex literals with // do not hide later ESM exports', () => {
14
+ const code = `
15
+ const protocol = /^https?:\\/\\//i
16
+ const slashy = /\\/\\*not-a-comment\\*\\//
17
+ export function sanitizeEmailHtml(html: string): string {
18
+ return html
19
+ }
20
+ export function buildRawMessage(): string {
21
+ return ''
22
+ }
23
+ `
24
+
25
+ assert.equal(exportNames(code), ['buildRawMessage', 'sanitizeEmailHtml'])
26
+ })
27
+
28
+ test('regex literals with // do not hide later imports, requires, or CJS exports', () => {
29
+ const code = `
30
+ const protocol = /^https?:\\/\\//i
31
+ const commentText = /\\/\\/ not really a comment/
32
+ import real from './real.js'
33
+ const actual = require('./actual.js')
34
+ module.exports.afterRegex = { real, actual }
35
+ `
36
+
37
+ const deps = extractDeps(code)
38
+ assert.equal(deps.imports.map(dep => dep.from), ['./real.js'])
39
+ assert.equal(deps.requires.map(dep => dep.from), ['./actual.js'])
40
+ assert.equal(cjsExportNames(code), ['afterRegex'])
41
+ })
42
+
43
+ test('regex literals with backticks do not start fake template literals', () => {
44
+ const code = `
45
+ function escapeHtmlAttribute(value: string): string {
46
+ return value.replace(/\\\`/g, '&#96;')
47
+ }
48
+
49
+ export const afterBacktickRegex = true
50
+ `
51
+
52
+ assert.equal(exportNames(code), ['afterBacktickRegex'])
53
+ })
54
+
55
+ test('regex literals containing parser keywords are not imports/requires/exports', () => {
56
+ const code = `
57
+ const importPattern = /import\\s+fake\\s+from/
58
+ const exportPattern = /export\\s+const\\s+fake/
59
+ const requirePattern = /require\\(['"]fake['"]\\)/
60
+ const cjsPattern = /module\\.exports\\.fake/
61
+
62
+ import real from './real.js'
63
+ const actual = require('./actual.js')
64
+ export const realExport = true
65
+ module.exports.cjsExport = actual
66
+ `
67
+
68
+ const deps = extractDeps(code)
69
+ assert.equal(deps.imports.map(dep => dep.from), ['./real.js'])
70
+ assert.equal(deps.requires.map(dep => dep.from), ['./actual.js'])
71
+ assert.equal(exportNames(code), ['realExport'])
72
+ assert.equal(cjsExportNames(code), ['cjsExport'])
73
+ })
74
+
75
+ test('detectSyntax ignores parser keywords inside regex literals', () => {
76
+ const result = detectSyntax(`
77
+ const importPattern = /import\\s+fake\\s+from/
78
+ const exportPattern = /export\\s+const\\s+fake/
79
+ const requirePattern = /require\\(['"]fake['"]\\)/
80
+ const cjsPattern = /module\\.exports\\.fake/
81
+ `)
82
+
83
+ assert.equal(result, { hasESM: false, hasCJS: false, isMixed: false })
84
+ })
85
+
86
+ test('TypeScript enum exports are named exports', () => {
87
+ const code = `
88
+ export enum DeliveryStatus {
89
+ Pending = 'pending',
90
+ Sent = 'sent',
91
+ }
92
+
93
+ export const enum InlineStatus {
94
+ Ready = 'ready',
95
+ }
96
+ `
97
+
98
+ assert.equal(exportNames(code), ['DeliveryStatus', 'InlineStatus'])
99
+ })
100
+
101
+ test.run()
@@ -142,4 +142,12 @@ test('stripStringContents — neutralizes // inside code-bearing strings so stri
142
142
  assert.ok(after.includes('"\nconst y = 1'), 'closing quote and following code survive')
143
143
  })
144
144
 
145
+ test('stripComments — preserves regex literals that contain //', () => {
146
+ const input = `if (!/^https?:\\/\\//i.test(href)) return '<a>'\nexport function afterRegex() {}`
147
+ const output = stripComments(input)
148
+
149
+ assert.ok(output.includes('/^https?:\\/\\//i.test(href)'), 'regex literal survives')
150
+ assert.ok(output.includes('export function afterRegex() {}'), 'following export survives')
151
+ })
152
+
145
153
  test.run()
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Build dependency graph for a file and its dependencies
3
+ * @param {string} filePath - File to analyze
4
+ * @param {object} options - Options
5
+ * @param {boolean} [options.buildGraph] - If true, build and return dependency graph. Default: true
6
+ * @param {boolean} [options.verifyGraph] - If true, verify imports/exports. Default: true
7
+ * @param {boolean} [options.verifyNodeModules] - If true, verify node_modules packages can be resolved. Default: false
8
+ * @param {boolean} [options.includeNodeModules] - If true, include node_modules package names in the graph. Default: false
9
+ * @param {boolean} [options.throwOnFirstError] - If true, throw immediately on first error. Default: false
10
+ * @param {boolean} [options.returnErrors] - If true, return { graph, errors } instead of throwing. Default: false
11
+ * @returns {Map<string, string[]>|{graph: Map, errors: Error[]}|undefined} - Dependency graph, or { graph, errors } if returnErrors is true. Returns undefined if buildGraph is false.
12
+ */
13
+ export function depGraph(filePath: string, options?: {
14
+ buildGraph?: boolean;
15
+ verifyGraph?: boolean;
16
+ verifyNodeModules?: boolean;
17
+ includeNodeModules?: boolean;
18
+ throwOnFirstError?: boolean;
19
+ returnErrors?: boolean;
20
+ }): Map<string, string[]> | {
21
+ graph: Map<any, any>;
22
+ errors: Error[];
23
+ } | undefined;
24
+ /**
25
+ * Get all dependency file paths in build order (dependencies first), deduplicated
26
+ * @param {string} filePath - Entry file path
27
+ * @param {object} options - Options to pass to depGraph
28
+ * @param {boolean} [options.verifyGraph] - If true, verify imports/exports. Default: true
29
+ * @param {boolean} [options.verifyNodeModules] - If true, verify node_modules packages can be resolved. Default: false
30
+ * @param {boolean} [options.throwOnFirstError] - If true, throw immediately on first error. Default: false
31
+ * @param {boolean} [options.returnErrors] - If true, include errors array in result instead of throwing
32
+ * @returns {{ files: string[], nodeModules: string[], builtIns: string[], errors?: Error[] }} - Object with files in topological order, npm packages, and Node.js built-ins
33
+ */
34
+ export function resolveDepPaths(filePath: string, options?: {
35
+ verifyGraph?: boolean;
36
+ verifyNodeModules?: boolean;
37
+ throwOnFirstError?: boolean;
38
+ returnErrors?: boolean;
39
+ }): {
40
+ files: string[];
41
+ nodeModules: string[];
42
+ builtIns: string[];
43
+ errors?: Error[];
44
+ };
45
+ //# sourceMappingURL=dep-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dep-graph.d.ts","sourceRoot":"","sources":["../src/dep-graph.js"],"names":[],"mappings":"AAmUA;;;;;;;;;;;GAWG;AACH,mCAVW,MAAM,YAEd;IAA0B,UAAU,GAA5B,OAAO;IACW,WAAW,GAA7B,OAAO;IACW,iBAAiB,GAAnC,OAAO;IACW,kBAAkB,GAApC,OAAO;IACW,iBAAiB,GAAnC,OAAO;IACW,YAAY,GAA9B,OAAO;CACf,GAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAC;IAAC,KAAK,gBAAM;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAC,GAAC,SAAS,CA8BzE;AAGD;;;;;;;;;GASG;AACH,0CARW,MAAM,YAEd;IAA0B,WAAW,GAA7B,OAAO;IACW,iBAAiB,GAAnC,OAAO;IACW,iBAAiB,GAAnC,OAAO;IACW,YAAY,GAA9B,OAAO;CACf,GAAU;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;CAAE,CAkF5F"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Options for detecting syntax within a code string.
3
+ */
4
+ export type DetectSyntaxOptions = {
5
+ /**
6
+ * - Indicates whether comments should be stripped from the code before syntax checking.
7
+ */
8
+ stripComments?: boolean;
9
+ };
10
+ /**
11
+ * Options for detecting syntax within a code string.
12
+ * @typedef {Object} DetectSyntaxOptions
13
+ * @property {boolean} [stripComments=false] - Indicates whether comments should be stripped from the code before syntax checking.
14
+ */
15
+ /**
16
+ * Determines if a given code string contains ECMAScript module syntax.
17
+ *
18
+ * @param {string} code - The source code to analyze.
19
+ * @param {DetectSyntaxOptions} opts - See {@link DetectSyntaxOptions}.
20
+ * @returns {boolean} `true` if the code contains ESM syntax, otherwise `false`.
21
+ */
22
+ export function hasESMSyntax(code: string, opts?: DetectSyntaxOptions): boolean;
23
+ /**
24
+ * Determines if a given string of code contains CommonJS syntax.
25
+ *
26
+ * @param {string} code - The source code to analyze.
27
+ * @param {DetectSyntaxOptions} opts - See {@link DetectSyntaxOptions}.
28
+ * @returns {boolean} `true` if the code contains CommonJS syntax, `false` otherwise.
29
+ */
30
+ export function hasCJSSyntax(code: string, opts?: DetectSyntaxOptions): boolean;
31
+ /**
32
+ * Analyzes the supplied code to determine if it contains ECMAScript module syntax, CommonJS syntax, or both.
33
+ *
34
+ * @param {string} code - The source code to analyze.
35
+ * @param {DetectSyntaxOptions} opts - See {@link DetectSyntaxOptions}.
36
+ * @returns {Object} An object indicating the presence of ESM syntax (`hasESM`), CJS syntax (`hasCJS`) and whether both syntaxes are present (`isMixed`).
37
+ */
38
+ export function detectSyntax(code: string, opts?: DetectSyntaxOptions): any;
39
+ //# sourceMappingURL=detect-syntax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-syntax.d.ts","sourceRoot":"","sources":["../src/detect-syntax.js"],"names":[],"mappings":";;;;;;;oBAcc,OAAO;;AAHrB;;;;GAIG;AAEH;;;;;;GAMG;AACH,mCAJW,MAAM,SACN,mBAAmB,GACjB,OAAO,CAMnB;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,SACN,mBAAmB,GACjB,OAAO,CAMnB;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,SACN,mBAAmB,OAe7B"}
@@ -0,0 +1,45 @@
1
+ export function getCjsExports(code: any): any[];
2
+ export function getModuleExportsAssignment(originalText?: string, sanitizedText?: string): {
3
+ line: string;
4
+ exportType: string;
5
+ exportName: string;
6
+ exportDefinitionName: any;
7
+ exportValue: string;
8
+ index: number;
9
+ isExport: boolean;
10
+ }[];
11
+ export function getModuleExportsProperty(originalText?: string, sanitizedText?: string): {
12
+ line: string;
13
+ exportType: string;
14
+ exportName: string;
15
+ exportValue: string;
16
+ index: number;
17
+ isExport: boolean;
18
+ }[];
19
+ export function getExportsProperty(originalText?: string, sanitizedText?: string): {
20
+ line: string;
21
+ exportType: string;
22
+ exportName: string;
23
+ exportValue: string;
24
+ index: number;
25
+ isExport: boolean;
26
+ }[];
27
+ export function getObjectAssignExports(originalText?: string, sanitizedText?: string): {
28
+ line: string;
29
+ exportType: string;
30
+ exportName: string;
31
+ exportValue: string;
32
+ index: number;
33
+ isExport: boolean;
34
+ }[];
35
+ export function getDefinePropertyExports(originalText?: string, sanitizedText?: string): {
36
+ line: string;
37
+ exportType: string;
38
+ exportName: string;
39
+ exportValue: string;
40
+ exportDefinitionName: string;
41
+ index: number;
42
+ isExport: boolean;
43
+ isDefineProperty: boolean;
44
+ }[];
45
+ //# sourceMappingURL=get-cjs-exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-cjs-exports.d.ts","sourceRoot":"","sources":["../src/get-cjs-exports.js"],"names":[],"mappings":"AAoCA,gDAgDC;AA+BD;;;;;;;;IAqGC;AAED;;;;;;;IAqBC;AAED;;;;;;;IAqBC;AAED;;;;;;;IAiDC;AAED;;;;;;;;;IAwEC"}
@@ -0,0 +1,54 @@
1
+ export function getExports(code?: string, options?: {}): any[];
2
+ export function getDefaultExports(targetText?: string): {
3
+ line: string;
4
+ exportType: string;
5
+ exportName: string;
6
+ exportDefinitionName: any;
7
+ exportValue: string;
8
+ index: number;
9
+ isExport: boolean;
10
+ }[];
11
+ export function getNamedExports(targetText?: string): {
12
+ line: string;
13
+ exportType: string;
14
+ exportName: string;
15
+ index: number;
16
+ isExport: boolean;
17
+ }[];
18
+ export function getNamedDeclarationExports(targetText?: string): any[];
19
+ export function getAllExports(targetText?: string): {
20
+ line: string;
21
+ exportType: string;
22
+ from: string;
23
+ index: number;
24
+ isExport: boolean;
25
+ }[];
26
+ export function getNamespaceExports(targetText?: string): {
27
+ line: string;
28
+ exportType: string;
29
+ namespace: string;
30
+ from: string;
31
+ index: number;
32
+ isExport: boolean;
33
+ }[];
34
+ export function getTypeExports(targetText?: string): {
35
+ line: string;
36
+ exportType: string;
37
+ exportName: string;
38
+ index: number;
39
+ isExport: boolean;
40
+ }[];
41
+ export function getAssertionExports(targetText?: string): {
42
+ line: string;
43
+ exportType: string;
44
+ exportName: string;
45
+ definitions: any;
46
+ keys: any;
47
+ from: string;
48
+ assertion: string;
49
+ assertionType: string;
50
+ index: number;
51
+ isExport: boolean;
52
+ isAssertion: boolean;
53
+ }[];
54
+ //# sourceMappingURL=get-exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-exports.d.ts","sourceRoot":"","sources":["../src/get-exports.js"],"names":[],"mappings":"AAiBA,+DAqCC;AAED;;;;;;;;IAqDC;AAED;;;;;;IAeC;AAED,uEAuBC;AAED;;;;;;IAeC;AAED;;;;;;;IAgBC;AAED;;;;;;IAeC;AAED;;;;;;;;;;;;IA0BC"}
@@ -0,0 +1,59 @@
1
+ export function getImports(code?: string, options?: {}): {
2
+ line: string;
3
+ varType: string;
4
+ varName: string;
5
+ definitions: any;
6
+ from: string;
7
+ index: number;
8
+ isImport: boolean;
9
+ isRelative: boolean;
10
+ isBuiltIn: boolean;
11
+ }[];
12
+ export function getStaticImports(targetText?: string): {
13
+ line: string;
14
+ varType: string;
15
+ varName: string;
16
+ definitions: any;
17
+ from: string;
18
+ index: number;
19
+ isImport: boolean;
20
+ isRelative: boolean;
21
+ isBuiltIn: boolean;
22
+ }[];
23
+ export function getTypeImports(targetText?: string): {
24
+ importStatement: string;
25
+ importPath: string;
26
+ importName: string;
27
+ index: number;
28
+ isImport: boolean;
29
+ isTypeImport: boolean;
30
+ isRelative: boolean;
31
+ isBuiltIn: boolean;
32
+ }[];
33
+ export function getDynamicImports(targetText?: string): {
34
+ line: string;
35
+ varType: string;
36
+ varName: string;
37
+ definitions: any;
38
+ from: string;
39
+ index: number;
40
+ isImport: boolean;
41
+ isRelative: boolean;
42
+ isBuiltIn: boolean;
43
+ isDynamic: boolean;
44
+ }[];
45
+ export function getAssertionImports(targetText?: string): {
46
+ line: string;
47
+ varType: string;
48
+ varName: string;
49
+ definitions: any;
50
+ from: string;
51
+ assertion: string;
52
+ assertionType: string;
53
+ index: number;
54
+ isImport: boolean;
55
+ isRelative: boolean;
56
+ isBuiltIn: boolean;
57
+ isAssertion: boolean;
58
+ }[];
59
+ //# sourceMappingURL=get-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-imports.d.ts","sourceRoot":"","sources":["../src/get-imports.js"],"names":[],"mappings":"AAsCA;;;;;;;;;;IAcC;AAGD;;;;;;;;;;IAsCC;AAED;;;;;;;;;IAkBC;AAED;;;;;;;;;;;IAuBC;AAED;;;;;;;;;;;;;IA0BC"}
@@ -0,0 +1,37 @@
1
+ export function getRequires(code: any): {
2
+ line: string;
3
+ varType: string;
4
+ varName: string;
5
+ definitions: any;
6
+ from: string;
7
+ index: number;
8
+ isRequire: boolean;
9
+ isRelative: boolean;
10
+ isBuiltIn: boolean;
11
+ isDynamic: boolean;
12
+ }[];
13
+ export function getStaticRequires(targetText?: string): {
14
+ line: string;
15
+ varType: string;
16
+ varName: string;
17
+ definitions: any;
18
+ from: string;
19
+ index: number;
20
+ isRequire: boolean;
21
+ isRelative: boolean;
22
+ isBuiltIn: boolean;
23
+ isDynamic: boolean;
24
+ }[];
25
+ export function getDynamicRequires(code: any): {
26
+ line: string;
27
+ varType: string;
28
+ varName: string;
29
+ definitions: any;
30
+ from: string;
31
+ index: number;
32
+ isRequire: boolean;
33
+ isRelative: boolean;
34
+ isBuiltIn: boolean;
35
+ isDynamic: boolean;
36
+ }[];
37
+ //# sourceMappingURL=get-requires.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-requires.d.ts","sourceRoot":"","sources":["../src/get-requires.js"],"names":[],"mappings":"AA0GA;;;;;;;;;;;IAUC;AArCD;;;;;;;;;;;IAyBC;AA/FD;;;;;;;;;;;IA6BC"}
@@ -0,0 +1,25 @@
1
+ export function extractDeps(code: any, filePath?: string): any;
2
+ /**
3
+ * Cached extraction. Returns a shared object — callers must treat it as
4
+ * read-only. Use `extractDeps` for a private copy.
5
+ * @param {string} code
6
+ */
7
+ export function extractDepsShared(code: string): any;
8
+ import { hasESMSyntax } from "./detect-syntax";
9
+ import { hasCJSSyntax } from "./detect-syntax";
10
+ import { detectSyntax } from "./detect-syntax";
11
+ import { getRequires } from "./get-requires";
12
+ import { getDynamicRequires } from "./get-requires";
13
+ import { getStaticRequires } from "./get-requires";
14
+ import { getImports } from "./get-imports";
15
+ import { getStaticImports } from "./get-imports";
16
+ import { getDynamicImports } from "./get-imports";
17
+ import { getExports } from "./get-exports";
18
+ import { getDefaultExports } from "./get-exports";
19
+ import { getNamedExports } from "./get-exports";
20
+ import { getNamedDeclarationExports } from "./get-exports";
21
+ import { getAllExports } from "./get-exports";
22
+ import { getNamespaceExports } from "./get-exports";
23
+ import { getTypeExports } from "./get-exports";
24
+ export { hasESMSyntax, hasCJSSyntax, detectSyntax, getRequires, getDynamicRequires, getStaticRequires, getImports, getStaticImports, getDynamicImports, getExports, getDefaultExports, getNamedExports, getNamedDeclarationExports, getAllExports, getNamespaceExports, getTypeExports };
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA0CA,+DAEC;AAnBD;;;;GAIG;AACH,wCAFW,MAAM,OAYhB"}